-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEventEditModal.vue
More file actions
65 lines (61 loc) · 1.74 KB
/
Copy pathEventEditModal.vue
File metadata and controls
65 lines (61 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<script setup lang="ts">
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogDescription,
} from '@/shared/ui/dialog'
import type { EventFormValues } from '@/modules/events/validation/eventSchema.ts'
import EventForm from './EventForm.vue'
import type { Event } from '@/modules/events/types'
import type { Field } from '@/modules/fields/types'
import { fieldApi } from '@/modules/fields/api'
import { ref, onMounted } from 'vue'
import type { Tag } from '@/modules/tags/types'
import { tagApi } from '@/modules/tags/api'
import { useAsyncTask } from '@/shared/composables/useAsyncTask'
defineProps<{
description?: string
event: Event
open: boolean
onClose: () => void
onSubmit: (values: EventFormValues) => void
isSaving?: boolean
}>()
const fields = ref<Field[]>([])
const tags = ref<Tag[]>([])
const { run: loadFields, isLoading: isLoadingFields } = useAsyncTask()
const { run: loadTags, isLoading: isLoadingTags } = useAsyncTask()
onMounted(() => {
loadFields(async () => {
fields.value = await fieldApi.getAll()
})
loadTags(async () => {
tags.value = await tagApi.getAll()
})
})
</script>
<template>
<Dialog :open="open" @update:open="onClose">
<DialogContent class="max-h-[80vh] overflow-y-auto">
<DialogHeader>
<DialogTitle>Edit Event</DialogTitle>
<DialogDescription>
{{ description }}
</DialogDescription>
</DialogHeader>
<EventForm
v-if="event"
:event="event"
:availableFields="fields"
:availableTags="tags"
:isLoadingFields="isLoadingFields"
:isLoadingTags="isLoadingTags"
:onSubmit="onSubmit"
:isLoading="isSaving"
button-text="Save"
/>
</DialogContent>
</Dialog>
</template>