diff --git a/src/components/admin/DesignerForm.tsx b/src/components/admin/DesignerForm.tsx index 29df72a5..2d09fa5f 100644 --- a/src/components/admin/DesignerForm.tsx +++ b/src/components/admin/DesignerForm.tsx @@ -99,19 +99,19 @@ export function DesignerForm({ onSubmit, onCancel, initialData }: DesignerFormPr setIsSubmitting(true); try { - const formData = { - ...data, - founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined, - }; - - if (initialData?.id) { - await submitDesignerUpdate(initialData.id, formData, user.id); - toast.success('Designer update submitted for review'); - } else { - await submitDesignerCreation(formData, user.id); - toast.success('Designer submitted for review'); - } - onCancel(); + const formData = { + ...data, + company_type: 'designer' as const, + founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined, + }; + + await onSubmit(formData); + + // Only show success toast and close if not editing through moderation queue + if (!initialData?.id) { + toast.success('Designer submitted for review'); + onCancel(); + } } catch (error) { console.error('Submission error:', error); toast.error(error instanceof Error ? error.message : 'Failed to submit designer'); diff --git a/src/components/admin/ManufacturerForm.tsx b/src/components/admin/ManufacturerForm.tsx index 185aef09..a33f89e0 100644 --- a/src/components/admin/ManufacturerForm.tsx +++ b/src/components/admin/ManufacturerForm.tsx @@ -102,19 +102,19 @@ export function ManufacturerForm({ onSubmit, onCancel, initialData }: Manufactur setIsSubmitting(true); try { - const formData = { - ...data, - founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined, - }; - - if (initialData?.id) { - await submitManufacturerUpdate(initialData.id, formData, user.id); - toast.success('Manufacturer update submitted for review'); - } else { - await submitManufacturerCreation(formData, user.id); - toast.success('Manufacturer submitted for review'); - } - onCancel(); + const formData = { + ...data, + company_type: 'manufacturer' as const, + founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined, + }; + + await onSubmit(formData); + + // Only show success toast and close if not editing through moderation queue + if (!initialData?.id) { + toast.success('Manufacturer submitted for review'); + onCancel(); + } } catch (error) { console.error('Submission error:', error); toast.error(error instanceof Error ? error.message : 'Failed to submit manufacturer'); diff --git a/src/components/admin/OperatorForm.tsx b/src/components/admin/OperatorForm.tsx index 367b77a6..90e1286d 100644 --- a/src/components/admin/OperatorForm.tsx +++ b/src/components/admin/OperatorForm.tsx @@ -99,19 +99,19 @@ export function OperatorForm({ onSubmit, onCancel, initialData }: OperatorFormPr setIsSubmitting(true); try { - const formData = { - ...data, - founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined, - }; - - if (initialData?.id) { - await submitOperatorUpdate(initialData.id, formData, user.id); - toast.success('Operator update submitted for review'); - } else { - await submitOperatorCreation(formData, user.id); - toast.success('Operator submitted for review'); - } - onCancel(); + const formData = { + ...data, + company_type: 'operator' as const, + founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined, + }; + + await onSubmit(formData); + + // Only show success toast and close if not editing through moderation queue + if (!initialData?.id) { + toast.success('Operator submitted for review'); + onCancel(); + } } catch (error) { console.error('Submission error:', error); toast.error(error instanceof Error ? error.message : 'Failed to submit operator'); diff --git a/src/components/admin/PropertyOwnerForm.tsx b/src/components/admin/PropertyOwnerForm.tsx index a15b76f5..6ab088c8 100644 --- a/src/components/admin/PropertyOwnerForm.tsx +++ b/src/components/admin/PropertyOwnerForm.tsx @@ -125,19 +125,19 @@ export function PropertyOwnerForm({ onSubmit, onCancel, initialData }: PropertyO setIsSubmitting(true); try { - const formData = { - ...data, - founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined, - }; - - if (initialData?.id) { - await submitPropertyOwnerUpdate(initialData.id, formData, user.id); - toast.success('Property owner update submitted for review'); - } else { - await submitPropertyOwnerCreation(formData, user.id); - toast.success('Property owner submitted for review'); - } - onCancel(); + const formData = { + ...data, + company_type: 'property_owner' as const, + founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined, + }; + + await onSubmit(formData); + + // Only show success toast and close if not editing through moderation queue + if (!initialData?.id) { + toast.success('Property owner submitted for review'); + onCancel(); + } } catch (error) { console.error('Submission error:', error); toast.error(error instanceof Error ? error.message : 'Failed to submit property owner');