feat(portal): multi-step volunteer registration form with public event endpoint
- Add GET /api/v1/public/events/{slug}/registration-data endpoint for fetching
event sections and time slots without auth
- Create 5-step registration form: personal info, details, motivation, section
preferences, availability
- VeeValidate + Zod validation per step with Dutch error messages
- Auth-aware: pre-fills name/email for authenticated users
- Mobile responsive with custom chip-based step indicator
- Success page with contextual actions (dashboard vs login)
- Types, composable (TanStack Query), and Zod schemas
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
36
apps/portal/src/composables/api/useVolunteerRegistration.ts
Normal file
36
apps/portal/src/composables/api/useVolunteerRegistration.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { useQuery, useMutation } from '@tanstack/vue-query'
|
||||
import type { Ref } from 'vue'
|
||||
import { apiClient } from '@/lib/axios'
|
||||
import type { EventRegistrationData, VolunteerRegistrationForm } from '@/types/registration'
|
||||
|
||||
interface ApiResponse<T> {
|
||||
data: T
|
||||
}
|
||||
|
||||
export function useRegistrationData(eventSlug: Ref<string>) {
|
||||
return useQuery({
|
||||
queryKey: ['registration-data', eventSlug],
|
||||
queryFn: async () => {
|
||||
const { data } = await apiClient.get<ApiResponse<EventRegistrationData>>(
|
||||
`/public/events/${eventSlug.value}/registration-data`,
|
||||
)
|
||||
|
||||
return data.data
|
||||
},
|
||||
enabled: () => !!eventSlug.value,
|
||||
retry: false,
|
||||
})
|
||||
}
|
||||
|
||||
export function useSubmitRegistration() {
|
||||
return useMutation({
|
||||
mutationFn: async ({ eventId, form }: { eventId: string; form: VolunteerRegistrationForm }) => {
|
||||
const { data } = await apiClient.post<ApiResponse<Record<string, unknown>>>(
|
||||
`/events/${eventId}/volunteer-register`,
|
||||
form,
|
||||
)
|
||||
|
||||
return data.data
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user