feat: schema v1.7 + sections/shifts frontend

- Universeel festival/event model (parent_event_id, event_type)
- event_person_activations pivot tabel
- Event model: parent/children relaties + helper scopes
- DevSeeder: festival structuur met sub-events
- Sections & Shifts frontend (twee-kolom layout)
- BACKLOG.md aangemaakt met 22 gedocumenteerde wensen
This commit is contained in:
2026-04-08 07:23:56 +02:00
parent 6f69b30fb6
commit 6848bc2c49
19 changed files with 2560 additions and 87 deletions

View File

@@ -0,0 +1,92 @@
import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query'
import type { Ref } from 'vue'
import { apiClient } from '@/lib/axios'
import type { CreateSectionPayload, FestivalSection, UpdateSectionPayload } from '@/types/section'
interface ApiResponse<T> {
success: boolean
data: T
message?: string
}
interface PaginatedResponse<T> {
data: T[]
}
export function useSectionList(eventId: Ref<string>) {
return useQuery({
queryKey: ['sections', eventId],
queryFn: async () => {
const { data } = await apiClient.get<PaginatedResponse<FestivalSection>>(
`/events/${eventId.value}/sections`,
)
return data.data
},
enabled: () => !!eventId.value,
})
}
export function useCreateSection(eventId: Ref<string>) {
const queryClient = useQueryClient()
return useMutation({
mutationFn: async (payload: CreateSectionPayload) => {
const { data } = await apiClient.post<ApiResponse<FestivalSection>>(
`/events/${eventId.value}/sections`,
payload,
)
return data.data
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['sections', eventId.value] })
},
})
}
export function useUpdateSection(eventId: Ref<string>) {
const queryClient = useQueryClient()
return useMutation({
mutationFn: async ({ id, ...payload }: UpdateSectionPayload & { id: string }) => {
const { data } = await apiClient.put<ApiResponse<FestivalSection>>(
`/events/${eventId.value}/sections/${id}`,
payload,
)
return data.data
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['sections', eventId.value] })
},
})
}
export function useDeleteSection(eventId: Ref<string>) {
const queryClient = useQueryClient()
return useMutation({
mutationFn: async (id: string) => {
await apiClient.delete(`/events/${eventId.value}/sections/${id}`)
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['sections', eventId.value] })
},
})
}
export function useReorderSections(eventId: Ref<string>) {
const queryClient = useQueryClient()
return useMutation({
mutationFn: async (orderedIds: string[]) => {
await apiClient.post(`/events/${eventId.value}/sections/reorder`, {
ordered_ids: orderedIds,
})
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['sections', eventId.value] })
},
})
}