diff --git a/src/components/admin/DesignerForm.tsx b/src/components/admin/DesignerForm.tsx index 946f25e5..9b6d5a14 100644 --- a/src/components/admin/DesignerForm.tsx +++ b/src/components/admin/DesignerForm.tsx @@ -46,6 +46,28 @@ const designerSchema = z.object({ type DesignerFormData = z.infer; +// Input type for the form (before transformation) +type DesignerFormInput = { + name: string; + slug: string; + description?: string; + person_type: 'company' | 'individual' | 'firm' | 'organization'; + website_url?: string; + founded_year?: string; + headquarters_location?: string; + images?: { + uploaded: Array<{ + url: string; + cloudflare_id?: string; + file?: any; + isLocal?: boolean; + caption?: string; + }>; + banner_assignment?: number | null; + card_assignment?: number | null; + }; +}; + interface DesignerFormProps { onSubmit: (data: DesignerFormData) => void; onCancel: () => void; @@ -66,7 +88,7 @@ export function DesignerForm({ onSubmit, onCancel, initialData }: DesignerFormPr setValue, watch, formState: { errors } - } = useForm({ + } = useForm({ resolver: zodResolver(designerSchema), defaultValues: { name: initialData?.name || '', @@ -77,7 +99,7 @@ export function DesignerForm({ onSubmit, onCancel, initialData }: DesignerFormPr founded_year: initialData?.founded_year ? String(initialData.founded_year) : '', headquarters_location: initialData?.headquarters_location || '', images: initialData?.images || { uploaded: [] } - } as Partial + } }); @@ -90,7 +112,7 @@ export function DesignerForm({ onSubmit, onCancel, initialData }: DesignerFormPr -
+ onSubmit(data as unknown as DesignerFormData))} className="space-y-6"> {/* Basic Information */}
diff --git a/src/components/admin/ManufacturerForm.tsx b/src/components/admin/ManufacturerForm.tsx index c75fa473..151b2626 100644 --- a/src/components/admin/ManufacturerForm.tsx +++ b/src/components/admin/ManufacturerForm.tsx @@ -46,6 +46,28 @@ const manufacturerSchema = z.object({ type ManufacturerFormData = z.infer; +// Input type for the form (before transformation) +type ManufacturerFormInput = { + name: string; + slug: string; + description?: string; + person_type: 'company' | 'individual' | 'firm' | 'organization'; + website_url?: string; + founded_year?: string; + headquarters_location?: string; + images?: { + uploaded: Array<{ + url: string; + cloudflare_id?: string; + file?: any; + isLocal?: boolean; + caption?: string; + }>; + banner_assignment?: number | null; + card_assignment?: number | null; + }; +}; + interface ManufacturerFormProps { onSubmit: (data: ManufacturerFormData) => void; onCancel: () => void; @@ -66,7 +88,7 @@ export function ManufacturerForm({ onSubmit, onCancel, initialData }: Manufactur setValue, watch, formState: { errors } - } = useForm({ + } = useForm({ resolver: zodResolver(manufacturerSchema), defaultValues: { name: initialData?.name || '', @@ -77,7 +99,7 @@ export function ManufacturerForm({ onSubmit, onCancel, initialData }: Manufactur founded_year: initialData?.founded_year ? String(initialData.founded_year) : '', headquarters_location: initialData?.headquarters_location || '', images: initialData?.images || { uploaded: [] } - } as Partial + } }); @@ -90,7 +112,7 @@ export function ManufacturerForm({ onSubmit, onCancel, initialData }: Manufactur - + onSubmit(data as unknown as ManufacturerFormData))} className="space-y-6"> {/* Basic Information */}
diff --git a/src/components/admin/OperatorForm.tsx b/src/components/admin/OperatorForm.tsx index 3612f373..73481f5f 100644 --- a/src/components/admin/OperatorForm.tsx +++ b/src/components/admin/OperatorForm.tsx @@ -46,6 +46,28 @@ const operatorSchema = z.object({ type OperatorFormData = z.infer; +// Input type for the form (before transformation) +type OperatorFormInput = { + name: string; + slug: string; + description?: string; + person_type: 'company' | 'individual' | 'firm' | 'organization'; + website_url?: string; + founded_year?: string; + headquarters_location?: string; + images?: { + uploaded: Array<{ + url: string; + cloudflare_id?: string; + file?: any; + isLocal?: boolean; + caption?: string; + }>; + banner_assignment?: number | null; + card_assignment?: number | null; + }; +}; + interface OperatorFormProps { onSubmit: (data: OperatorFormData) => void; onCancel: () => void; @@ -66,7 +88,7 @@ export function OperatorForm({ onSubmit, onCancel, initialData }: OperatorFormPr setValue, watch, formState: { errors } - } = useForm({ + } = useForm({ resolver: zodResolver(operatorSchema), defaultValues: { name: initialData?.name || '', @@ -77,7 +99,7 @@ export function OperatorForm({ onSubmit, onCancel, initialData }: OperatorFormPr founded_year: initialData?.founded_year ? String(initialData.founded_year) : '', headquarters_location: initialData?.headquarters_location || '', images: initialData?.images || { uploaded: [] } - } as Partial + } }); @@ -90,7 +112,7 @@ export function OperatorForm({ onSubmit, onCancel, initialData }: OperatorFormPr - + onSubmit(data as unknown as OperatorFormData))} className="space-y-6"> {/* Basic Information */}
diff --git a/src/components/admin/PropertyOwnerForm.tsx b/src/components/admin/PropertyOwnerForm.tsx index 4e3755c1..7fd39cca 100644 --- a/src/components/admin/PropertyOwnerForm.tsx +++ b/src/components/admin/PropertyOwnerForm.tsx @@ -46,6 +46,28 @@ const propertyOwnerSchema = z.object({ type PropertyOwnerFormData = z.infer; +// Input type for the form (before transformation) +type PropertyOwnerFormInput = { + name: string; + slug: string; + description?: string; + person_type: 'company' | 'individual' | 'firm' | 'organization'; + website_url?: string; + founded_year?: string; + headquarters_location?: string; + images?: { + uploaded: Array<{ + url: string; + cloudflare_id?: string; + file?: any; + isLocal?: boolean; + caption?: string; + }>; + banner_assignment?: number | null; + card_assignment?: number | null; + }; +}; + interface PropertyOwnerFormProps { onSubmit: (data: PropertyOwnerFormData) => void; onCancel: () => void; @@ -66,7 +88,7 @@ export function PropertyOwnerForm({ onSubmit, onCancel, initialData }: PropertyO setValue, watch, formState: { errors } - } = useForm({ + } = useForm({ resolver: zodResolver(propertyOwnerSchema), defaultValues: { name: initialData?.name || '', @@ -77,7 +99,7 @@ export function PropertyOwnerForm({ onSubmit, onCancel, initialData }: PropertyO founded_year: initialData?.founded_year ? String(initialData.founded_year) : '', headquarters_location: initialData?.headquarters_location || '', images: initialData?.images || { uploaded: [] } - } as Partial + } }); @@ -90,7 +112,7 @@ export function PropertyOwnerForm({ onSubmit, onCancel, initialData }: PropertyO - + onSubmit(data as unknown as PropertyOwnerFormData))} className="space-y-6"> {/* Basic Information */}