security: A01-13 — nest all event routes under organisation prefix
Move all authenticated organiser-facing event sub-resource routes from
/events/{event}/... to /organisations/{organisation}/events/{event}/...
to enforce multi-tenancy at the routing layer.
Changes:
- Routes: restructured api.php to nest all event sub-resources under
the existing organisation prefix group
- Controllers: added Organisation parameter and VerifiesOrganisationEvent
trait to all 12 affected controllers (sections, time-slots, shifts,
persons, crowd-lists, locations, shift-assignments, registration-fields,
availabilities, field-values, section-preferences, stats)
- Tests: updated all 20 feature test files with new route paths
- Frontend: updated 8 API composables and 20 Vue components/pages
- API.md: updated documentation to reflect new route structure
Portal routes, public routes (volunteer-register), and invitation routes
remain unchanged as they operate without organisation context.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -21,26 +21,26 @@ interface PaginatedResponse<T> {
|
||||
}
|
||||
}
|
||||
|
||||
export function useCrowdLists(eventId: Ref<string>) {
|
||||
export function useCrowdLists(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
return useQuery({
|
||||
queryKey: ['crowd-lists', eventId],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.get<{ data: CrowdList[] }>(
|
||||
`/events/${eventId.value}/crowd-lists`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/crowd-lists`,
|
||||
)
|
||||
|
||||
return data.data
|
||||
},
|
||||
enabled: () => !!eventId.value,
|
||||
enabled: () => !!orgId.value && !!eventId.value,
|
||||
})
|
||||
}
|
||||
|
||||
export function useCrowdListPersons(eventId: Ref<string>, crowdListId: Ref<string>) {
|
||||
export function useCrowdListPersons(orgId: Ref<string>, eventId: Ref<string>, crowdListId: Ref<string>) {
|
||||
return useQuery({
|
||||
queryKey: ['crowd-lists', eventId, 'persons', crowdListId],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.get<PaginatedResponse<Person>>(
|
||||
`/events/${eventId.value}/crowd-lists/${crowdListId.value}/persons`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/crowd-lists/${crowdListId.value}/persons`,
|
||||
)
|
||||
|
||||
return data
|
||||
@@ -49,13 +49,13 @@ export function useCrowdListPersons(eventId: Ref<string>, crowdListId: Ref<strin
|
||||
})
|
||||
}
|
||||
|
||||
export function useCreateCrowdList(eventId: Ref<string>) {
|
||||
export function useCreateCrowdList(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (payload: CreateCrowdListDto) => {
|
||||
const { data } = await apiClient.post<ApiResponse<CrowdList>>(
|
||||
`/events/${eventId.value}/crowd-lists`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/crowd-lists`,
|
||||
payload,
|
||||
)
|
||||
|
||||
@@ -67,13 +67,13 @@ export function useCreateCrowdList(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useUpdateCrowdList(eventId: Ref<string>) {
|
||||
export function useUpdateCrowdList(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({ id, ...payload }: UpdateCrowdListDto & { id: string }) => {
|
||||
const { data } = await apiClient.put<ApiResponse<CrowdList>>(
|
||||
`/events/${eventId.value}/crowd-lists/${id}`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/crowd-lists/${id}`,
|
||||
payload,
|
||||
)
|
||||
|
||||
@@ -85,12 +85,12 @@ export function useUpdateCrowdList(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useDeleteCrowdList(eventId: Ref<string>) {
|
||||
export function useDeleteCrowdList(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (id: string) => {
|
||||
await apiClient.delete(`/events/${eventId.value}/crowd-lists/${id}`)
|
||||
await apiClient.delete(`/organisations/${orgId.value}/events/${eventId.value}/crowd-lists/${id}`)
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['crowd-lists', eventId.value] })
|
||||
@@ -98,13 +98,13 @@ export function useDeleteCrowdList(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useAddPersonToCrowdList(eventId: Ref<string>) {
|
||||
export function useAddPersonToCrowdList(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({ listId, personId }: { listId: string; personId: string }) => {
|
||||
const { data } = await apiClient.post<ApiResponse<CrowdList>>(
|
||||
`/events/${eventId.value}/crowd-lists/${listId}/persons`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/crowd-lists/${listId}/persons`,
|
||||
{ person_id: personId },
|
||||
)
|
||||
|
||||
@@ -116,13 +116,13 @@ export function useAddPersonToCrowdList(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useRemovePersonFromCrowdList(eventId: Ref<string>) {
|
||||
export function useRemovePersonFromCrowdList(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({ listId, personId }: { listId: string; personId: string }) => {
|
||||
await apiClient.delete(
|
||||
`/events/${eventId.value}/crowd-lists/${listId}/persons/${personId}`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/crowd-lists/${listId}/persons/${personId}`,
|
||||
)
|
||||
},
|
||||
onSuccess: (_data, variables) => {
|
||||
@@ -134,7 +134,7 @@ export function useRemovePersonFromCrowdList(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useApproveAllPending(eventId: Ref<string>) {
|
||||
export function useApproveAllPending(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
@@ -142,7 +142,7 @@ export function useApproveAllPending(eventId: Ref<string>) {
|
||||
const results = await Promise.allSettled(
|
||||
personIds.map(id =>
|
||||
apiClient.post<ApiResponse<Person>>(
|
||||
`/events/${eventId.value}/persons/${id}/approve`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/persons/${id}/approve`,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -175,15 +175,15 @@ export function useUploadEventImage(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useEventStats(eventId: Ref<string>) {
|
||||
export function useEventStats(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
return useQuery({
|
||||
queryKey: ['events', eventId, 'stats'],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.get<{ data: EventStats }>(
|
||||
`/events/${eventId.value}/stats`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/stats`,
|
||||
)
|
||||
return data.data
|
||||
},
|
||||
enabled: () => !!eventId.value,
|
||||
enabled: () => !!orgId.value && !!eventId.value,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ interface PaginatedResponse<T> {
|
||||
}
|
||||
|
||||
export function usePersonList(
|
||||
orgId: Ref<string>,
|
||||
eventId: Ref<string>,
|
||||
filters?: Ref<{ crowd_type_id?: string; status?: string }>,
|
||||
) {
|
||||
@@ -37,37 +38,37 @@ export function usePersonList(
|
||||
params.status = filters.value.status
|
||||
|
||||
const { data } = await apiClient.get<PaginatedResponse<Person>>(
|
||||
`/events/${eventId.value}/persons`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/persons`,
|
||||
{ params },
|
||||
)
|
||||
|
||||
return data
|
||||
},
|
||||
enabled: () => !!eventId.value,
|
||||
enabled: () => !!orgId.value && !!eventId.value,
|
||||
})
|
||||
}
|
||||
|
||||
export function usePersonDetail(eventId: Ref<string>, id: Ref<string>) {
|
||||
export function usePersonDetail(orgId: Ref<string>, eventId: Ref<string>, id: Ref<string>) {
|
||||
return useQuery({
|
||||
queryKey: ['persons', eventId, 'detail', id],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.get<ApiResponse<Person>>(
|
||||
`/events/${eventId.value}/persons/${id.value}`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/persons/${id.value}`,
|
||||
)
|
||||
|
||||
return data.data
|
||||
},
|
||||
enabled: () => !!eventId.value && !!id.value,
|
||||
enabled: () => !!orgId.value && !!eventId.value && !!id.value,
|
||||
})
|
||||
}
|
||||
|
||||
export function useCreatePerson(eventId: Ref<string>) {
|
||||
export function useCreatePerson(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (payload: CreatePersonPayload) => {
|
||||
const { data } = await apiClient.post<ApiResponse<Person>>(
|
||||
`/events/${eventId.value}/persons`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/persons`,
|
||||
payload,
|
||||
)
|
||||
|
||||
@@ -79,13 +80,13 @@ export function useCreatePerson(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useUpdatePerson(eventId: Ref<string>) {
|
||||
export function useUpdatePerson(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({ id, ...payload }: UpdatePersonPayload & { id: string }) => {
|
||||
const { data } = await apiClient.put<ApiResponse<Person>>(
|
||||
`/events/${eventId.value}/persons/${id}`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/persons/${id}`,
|
||||
payload,
|
||||
)
|
||||
|
||||
@@ -98,13 +99,13 @@ export function useUpdatePerson(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useApprovePerson(eventId: Ref<string>) {
|
||||
export function useApprovePerson(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (id: string) => {
|
||||
const { data } = await apiClient.post<ApiResponse<Person>>(
|
||||
`/events/${eventId.value}/persons/${id}/approve`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/persons/${id}/approve`,
|
||||
)
|
||||
|
||||
return data.data
|
||||
@@ -115,12 +116,12 @@ export function useApprovePerson(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useDeletePerson(eventId: Ref<string>) {
|
||||
export function useDeletePerson(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (id: string) => {
|
||||
await apiClient.delete(`/events/${eventId.value}/persons/${id}`)
|
||||
await apiClient.delete(`/organisations/${orgId.value}/events/${eventId.value}/persons/${id}`)
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['persons', eventId.value] })
|
||||
|
||||
@@ -13,28 +13,28 @@ interface ApiResponse<T> {
|
||||
message?: string
|
||||
}
|
||||
|
||||
export function useRegistrationFormFields(eventId: Ref<string>) {
|
||||
export function useRegistrationFormFields(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
return useQuery({
|
||||
queryKey: ['registration-form-fields', eventId],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.get<{ data: RegistrationFormField[] }>(
|
||||
`/events/${eventId.value}/registration-fields`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/registration-fields`,
|
||||
)
|
||||
|
||||
return data.data
|
||||
},
|
||||
enabled: () => !!eventId.value,
|
||||
enabled: () => !!orgId.value && !!eventId.value,
|
||||
staleTime: Infinity,
|
||||
})
|
||||
}
|
||||
|
||||
export function useCreateRegistrationFormField(eventId: Ref<string>) {
|
||||
export function useCreateRegistrationFormField(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (payload: RegistrationFormFieldCreateDTO) => {
|
||||
const { data } = await apiClient.post<ApiResponse<RegistrationFormField>>(
|
||||
`/events/${eventId.value}/registration-fields`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/registration-fields`,
|
||||
payload,
|
||||
)
|
||||
|
||||
@@ -46,13 +46,13 @@ export function useCreateRegistrationFormField(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useUpdateRegistrationFormField(eventId: Ref<string>) {
|
||||
export function useUpdateRegistrationFormField(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({ id, ...payload }: RegistrationFormFieldUpdateDTO & { id: string }) => {
|
||||
const { data } = await apiClient.put<ApiResponse<RegistrationFormField>>(
|
||||
`/events/${eventId.value}/registration-fields/${id}`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/registration-fields/${id}`,
|
||||
payload,
|
||||
)
|
||||
|
||||
@@ -64,12 +64,12 @@ export function useUpdateRegistrationFormField(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useDeleteRegistrationFormField(eventId: Ref<string>) {
|
||||
export function useDeleteRegistrationFormField(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (id: string) => {
|
||||
await apiClient.delete(`/events/${eventId.value}/registration-fields/${id}`)
|
||||
await apiClient.delete(`/organisations/${orgId.value}/events/${eventId.value}/registration-fields/${id}`)
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['registration-form-fields', eventId] })
|
||||
@@ -77,13 +77,13 @@ export function useDeleteRegistrationFormField(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useReorderRegistrationFormFields(eventId: Ref<string>) {
|
||||
export function useReorderRegistrationFormFields(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
let previousFields: RegistrationFormField[] | undefined
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (orderedIds: string[]) => {
|
||||
await apiClient.post(`/events/${eventId.value}/registration-fields/reorder`, {
|
||||
await apiClient.post(`/organisations/${orgId.value}/events/${eventId.value}/registration-fields/reorder`, {
|
||||
ids: orderedIds,
|
||||
})
|
||||
},
|
||||
@@ -107,13 +107,13 @@ export function useReorderRegistrationFormFields(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useCreateFieldFromTemplate(eventId: Ref<string>) {
|
||||
export function useCreateFieldFromTemplate(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (templateId: string) => {
|
||||
const { data } = await apiClient.post<ApiResponse<RegistrationFormField>>(
|
||||
`/events/${eventId.value}/registration-fields/from-template`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/registration-fields/from-template`,
|
||||
{ template_id: templateId },
|
||||
)
|
||||
|
||||
@@ -125,13 +125,13 @@ export function useCreateFieldFromTemplate(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useImportFieldsFromEvent(eventId: Ref<string>) {
|
||||
export function useImportFieldsFromEvent(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (sourceEventId: string) => {
|
||||
const { data } = await apiClient.post<ApiResponse<RegistrationFormField[]>>(
|
||||
`/events/${eventId.value}/registration-fields/import-from-event`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/registration-fields/import-from-event`,
|
||||
{ source_event_id: sourceEventId },
|
||||
)
|
||||
|
||||
|
||||
@@ -27,17 +27,17 @@ export function useSectionCategories(orgId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useSectionList(eventId: Ref<string>) {
|
||||
export function useSectionList(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
return useQuery({
|
||||
queryKey: ['sections', eventId],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.get<PaginatedResponse<FestivalSection>>(
|
||||
`/events/${eventId.value}/sections`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/sections`,
|
||||
)
|
||||
|
||||
return data.data
|
||||
},
|
||||
enabled: () => !!eventId.value,
|
||||
enabled: () => !!orgId.value && !!eventId.value,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@ export interface CreateSectionResult {
|
||||
parentEventName?: string
|
||||
}
|
||||
|
||||
export function useCreateSection(eventId: Ref<string>) {
|
||||
export function useCreateSection(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (payload: CreateSectionPayload): Promise<CreateSectionResult> => {
|
||||
const { data } = await apiClient.post<ApiResponse<FestivalSection> & { meta?: { redirected_to_parent?: boolean; parent_event_name?: string } }>(
|
||||
`/events/${eventId.value}/sections`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/sections`,
|
||||
payload,
|
||||
)
|
||||
|
||||
@@ -69,13 +69,13 @@ export function useCreateSection(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useUpdateSection(eventId: Ref<string>) {
|
||||
export function useUpdateSection(orgId: Ref<string>, 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}`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/sections/${id}`,
|
||||
payload,
|
||||
)
|
||||
|
||||
@@ -88,12 +88,12 @@ export function useUpdateSection(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useDeleteSection(eventId: Ref<string>) {
|
||||
export function useDeleteSection(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (id: string) => {
|
||||
await apiClient.delete(`/events/${eventId.value}/sections/${id}`)
|
||||
await apiClient.delete(`/organisations/${orgId.value}/events/${eventId.value}/sections/${id}`)
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['sections', eventId.value] })
|
||||
@@ -101,13 +101,13 @@ export function useDeleteSection(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useReorderSections(eventId: Ref<string>) {
|
||||
export function useReorderSections(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
let previousSections: FestivalSection[] | undefined
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (orderedIds: string[]) => {
|
||||
await apiClient.post(`/events/${eventId.value}/sections/reorder`, {
|
||||
await apiClient.post(`/organisations/${orgId.value}/events/${eventId.value}/sections/reorder`, {
|
||||
sections: orderedIds,
|
||||
})
|
||||
},
|
||||
|
||||
@@ -29,6 +29,7 @@ export interface ShiftAssignmentFilters {
|
||||
}
|
||||
|
||||
export function useShiftAssignmentList(
|
||||
orgId: Ref<string>,
|
||||
eventId: Ref<string>,
|
||||
filters?: Ref<ShiftAssignmentFilters>,
|
||||
) {
|
||||
@@ -42,23 +43,23 @@ export function useShiftAssignmentList(
|
||||
if (filters?.value?.status) params.status = filters.value.status
|
||||
|
||||
const { data } = await apiClient.get<PaginatedResponse<ShiftAssignment>>(
|
||||
`/events/${eventId.value}/shift-assignments`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/shift-assignments`,
|
||||
{ params },
|
||||
)
|
||||
|
||||
return data
|
||||
},
|
||||
enabled: () => !!eventId.value,
|
||||
enabled: () => !!orgId.value && !!eventId.value,
|
||||
})
|
||||
}
|
||||
|
||||
export function useApproveAssignment(eventId: Ref<string>) {
|
||||
export function useApproveAssignment(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (assignmentId: string) => {
|
||||
const { data } = await apiClient.post<ApiResponse<ShiftAssignment>>(
|
||||
`/events/${eventId.value}/shift-assignments/${assignmentId}/approve`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/shift-assignments/${assignmentId}/approve`,
|
||||
)
|
||||
|
||||
return data.data
|
||||
@@ -70,13 +71,13 @@ export function useApproveAssignment(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useRejectAssignment(eventId: Ref<string>) {
|
||||
export function useRejectAssignment(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({ assignmentId, reason }: { assignmentId: string; reason?: string }) => {
|
||||
const { data } = await apiClient.post<ApiResponse<ShiftAssignment>>(
|
||||
`/events/${eventId.value}/shift-assignments/${assignmentId}/reject`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/shift-assignments/${assignmentId}/reject`,
|
||||
{ reason },
|
||||
)
|
||||
|
||||
@@ -89,13 +90,13 @@ export function useRejectAssignment(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useCancelAssignment(eventId: Ref<string>) {
|
||||
export function useCancelAssignment(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (assignmentId: string) => {
|
||||
const { data } = await apiClient.post<ApiResponse<ShiftAssignment>>(
|
||||
`/events/${eventId.value}/shift-assignments/${assignmentId}/cancel`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/shift-assignments/${assignmentId}/cancel`,
|
||||
)
|
||||
|
||||
return data.data
|
||||
@@ -107,13 +108,13 @@ export function useCancelAssignment(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useBulkApproveAssignments(eventId: Ref<string>) {
|
||||
export function useBulkApproveAssignments(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (assignmentIds: string[]) => {
|
||||
const { data } = await apiClient.post<ApiResponse<unknown>>(
|
||||
`/events/${eventId.value}/shift-assignments/bulk-approve`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/shift-assignments/bulk-approve`,
|
||||
{ assignment_ids: assignmentIds },
|
||||
)
|
||||
|
||||
@@ -126,13 +127,13 @@ export function useBulkApproveAssignments(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useAssignPersonToShift(eventId: Ref<string>) {
|
||||
export function useAssignPersonToShift(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({ sectionId, shiftId, personId }: { sectionId: string; shiftId: string; personId: string }) => {
|
||||
const { data } = await apiClient.post<ApiResponse<ShiftAssignment>>(
|
||||
`/events/${eventId.value}/sections/${sectionId}/shifts/${shiftId}/assign`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/sections/${sectionId}/shifts/${shiftId}/assign`,
|
||||
{ person_id: personId },
|
||||
)
|
||||
|
||||
@@ -147,12 +148,12 @@ export function useAssignPersonToShift(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useAssignablePersons(eventId: MaybeRef<string>, shiftId: MaybeRef<string>) {
|
||||
export function useAssignablePersons(orgId: MaybeRef<string>, eventId: MaybeRef<string>, shiftId: MaybeRef<string>) {
|
||||
return useQuery({
|
||||
queryKey: ['assignable-persons', eventId, shiftId],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.get<{ data: AssignablePerson[]; meta: AssignablePersonsMeta }>(
|
||||
`/events/${unref(eventId)}/shifts/${unref(shiftId)}/assignable-persons`,
|
||||
`/organisations/${unref(orgId)}/events/${unref(eventId)}/shifts/${unref(shiftId)}/assignable-persons`,
|
||||
)
|
||||
|
||||
return {
|
||||
@@ -160,6 +161,6 @@ export function useAssignablePersons(eventId: MaybeRef<string>, shiftId: MaybeRe
|
||||
meta: data.meta,
|
||||
}
|
||||
},
|
||||
enabled: () => !!unref(eventId) && !!unref(shiftId),
|
||||
enabled: () => !!unref(orgId) && !!unref(eventId) && !!unref(shiftId),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -13,27 +13,27 @@ interface PaginatedResponse<T> {
|
||||
data: T[]
|
||||
}
|
||||
|
||||
export function useShiftList(eventId: Ref<string>, sectionId: Ref<string>) {
|
||||
export function useShiftList(orgId: Ref<string>, eventId: Ref<string>, sectionId: Ref<string>) {
|
||||
return useQuery({
|
||||
queryKey: ['shifts', sectionId],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.get<PaginatedResponse<Shift>>(
|
||||
`/events/${eventId.value}/sections/${sectionId.value}/shifts`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/sections/${sectionId.value}/shifts`,
|
||||
)
|
||||
|
||||
return data.data
|
||||
},
|
||||
enabled: () => !!eventId.value && !!sectionId.value,
|
||||
enabled: () => !!orgId.value && !!eventId.value && !!sectionId.value,
|
||||
})
|
||||
}
|
||||
|
||||
export function useCreateShift(eventId: Ref<string>, sectionId: Ref<string>) {
|
||||
export function useCreateShift(orgId: Ref<string>, eventId: Ref<string>, sectionId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (payload: CreateShiftPayload) => {
|
||||
const { data } = await apiClient.post<ApiResponse<Shift>>(
|
||||
`/events/${eventId.value}/sections/${sectionId.value}/shifts`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/sections/${sectionId.value}/shifts`,
|
||||
payload,
|
||||
)
|
||||
|
||||
@@ -45,13 +45,13 @@ export function useCreateShift(eventId: Ref<string>, sectionId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useUpdateShift(eventId: Ref<string>, sectionId: Ref<string>) {
|
||||
export function useUpdateShift(orgId: Ref<string>, eventId: Ref<string>, sectionId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({ id, ...payload }: UpdateShiftPayload & { id: string }) => {
|
||||
const { data } = await apiClient.put<ApiResponse<Shift>>(
|
||||
`/events/${eventId.value}/sections/${sectionId.value}/shifts/${id}`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/sections/${sectionId.value}/shifts/${id}`,
|
||||
payload,
|
||||
)
|
||||
|
||||
@@ -63,13 +63,13 @@ export function useUpdateShift(eventId: Ref<string>, sectionId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useDeleteShift(eventId: Ref<string>, sectionId: Ref<string>) {
|
||||
export function useDeleteShift(orgId: Ref<string>, eventId: Ref<string>, sectionId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (id: string) => {
|
||||
await apiClient.delete(
|
||||
`/events/${eventId.value}/sections/${sectionId.value}/shifts/${id}`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/sections/${sectionId.value}/shifts/${id}`,
|
||||
)
|
||||
},
|
||||
onSuccess: () => {
|
||||
@@ -78,13 +78,13 @@ export function useDeleteShift(eventId: Ref<string>, sectionId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useAssignShift(eventId: Ref<string>, sectionId: Ref<string>) {
|
||||
export function useAssignShift(orgId: Ref<string>, eventId: Ref<string>, sectionId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({ shiftId, personId }: { shiftId: string; personId: string }) => {
|
||||
const { data } = await apiClient.post<ApiResponse<unknown>>(
|
||||
`/events/${eventId.value}/sections/${sectionId.value}/shifts/${shiftId}/assign`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/sections/${sectionId.value}/shifts/${shiftId}/assign`,
|
||||
{ person_id: personId },
|
||||
)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ interface PaginatedResponse<T> {
|
||||
data: T[]
|
||||
}
|
||||
|
||||
export function useTimeSlotList(eventId: Ref<string>, options?: { includeParent?: Ref<boolean> }) {
|
||||
export function useTimeSlotList(orgId: Ref<string>, eventId: Ref<string>, options?: { includeParent?: Ref<boolean> }) {
|
||||
const includeParent = options?.includeParent
|
||||
|
||||
return useQuery({
|
||||
@@ -21,23 +21,23 @@ export function useTimeSlotList(eventId: Ref<string>, options?: { includeParent?
|
||||
queryFn: async () => {
|
||||
const params = includeParent?.value ? { include_parent: 'true' } : {}
|
||||
const { data } = await apiClient.get<PaginatedResponse<TimeSlot>>(
|
||||
`/events/${eventId.value}/time-slots`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/time-slots`,
|
||||
{ params },
|
||||
)
|
||||
|
||||
return data.data
|
||||
},
|
||||
enabled: () => !!eventId.value,
|
||||
enabled: () => !!orgId.value && !!eventId.value,
|
||||
})
|
||||
}
|
||||
|
||||
export function useCreateTimeSlot(eventId: Ref<string>) {
|
||||
export function useCreateTimeSlot(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (payload: CreateTimeSlotPayload) => {
|
||||
const { data } = await apiClient.post<ApiResponse<TimeSlot>>(
|
||||
`/events/${eventId.value}/time-slots`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/time-slots`,
|
||||
payload,
|
||||
)
|
||||
|
||||
@@ -49,13 +49,13 @@ export function useCreateTimeSlot(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useUpdateTimeSlot(eventId: Ref<string>) {
|
||||
export function useUpdateTimeSlot(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({ id, ...payload }: UpdateTimeSlotPayload & { id: string }) => {
|
||||
const { data } = await apiClient.put<ApiResponse<TimeSlot>>(
|
||||
`/events/${eventId.value}/time-slots/${id}`,
|
||||
`/organisations/${orgId.value}/events/${eventId.value}/time-slots/${id}`,
|
||||
payload,
|
||||
)
|
||||
|
||||
@@ -67,12 +67,12 @@ export function useUpdateTimeSlot(eventId: Ref<string>) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useDeleteTimeSlot(eventId: Ref<string>) {
|
||||
export function useDeleteTimeSlot(orgId: Ref<string>, eventId: Ref<string>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (id: string) => {
|
||||
await apiClient.delete(`/events/${eventId.value}/time-slots/${id}`)
|
||||
await apiClient.delete(`/organisations/${orgId.value}/events/${eventId.value}/time-slots/${id}`)
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['time-slots', eventId.value] })
|
||||
|
||||
Reference in New Issue
Block a user