Moves formBuilder types, formValidation, useConditionalLogic, useFormSteps, and formatFieldValue from apps/portal/src to packages/form-schema/src. Adds @form-schema path alias to both apps/portal and apps/app. Vue field components remain per-app to allow independent visual evolution. Behavior-neutral: all 35 Vitest tests green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
28 lines
910 B
TypeScript
28 lines
910 B
TypeScript
import { useQuery } from '@tanstack/vue-query'
|
|
import type { Ref } from 'vue'
|
|
import { apiClient } from '@/lib/axios'
|
|
import type { PublicFormSectionOption } from '@form-schema/types/formBuilder'
|
|
|
|
interface ApiResponse<T> {
|
|
data: T
|
|
}
|
|
|
|
// Sibling endpoint for SECTION_PRIORITY — festival-aware and dedup-by-name
|
|
// per PublicFormController::sections (show_in_registration=true, standard).
|
|
export function usePublicFormSections(token: Ref<string>) {
|
|
return useQuery({
|
|
queryKey: ['public-form', token, 'sections'],
|
|
queryFn: async (): Promise<PublicFormSectionOption[]> => {
|
|
const t = token.value
|
|
if (!t) throw new Error('Missing public_token')
|
|
const { data } = await apiClient.get<ApiResponse<PublicFormSectionOption[]>>(
|
|
`/public/forms/${t}/sections`,
|
|
)
|
|
|
|
return data.data
|
|
},
|
|
enabled: computed(() => !!token.value),
|
|
staleTime: 1000 * 60 * 5,
|
|
})
|
|
}
|