mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 17:11:13 -05:00
Fix designer form validation
This commit is contained in:
@@ -101,17 +101,17 @@ export function DesignerForm({ onSubmit, onCancel, initialData }: DesignerFormPr
|
|||||||
try {
|
try {
|
||||||
const formData = {
|
const formData = {
|
||||||
...data,
|
...data,
|
||||||
|
company_type: 'designer' as const,
|
||||||
founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined,
|
founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (initialData?.id) {
|
await onSubmit(formData);
|
||||||
await submitDesignerUpdate(initialData.id, formData, user.id);
|
|
||||||
toast.success('Designer update submitted for review');
|
// Only show success toast and close if not editing through moderation queue
|
||||||
} else {
|
if (!initialData?.id) {
|
||||||
await submitDesignerCreation(formData, user.id);
|
|
||||||
toast.success('Designer submitted for review');
|
toast.success('Designer submitted for review');
|
||||||
}
|
|
||||||
onCancel();
|
onCancel();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Submission error:', error);
|
console.error('Submission error:', error);
|
||||||
toast.error(error instanceof Error ? error.message : 'Failed to submit designer');
|
toast.error(error instanceof Error ? error.message : 'Failed to submit designer');
|
||||||
|
|||||||
@@ -104,17 +104,17 @@ export function ManufacturerForm({ onSubmit, onCancel, initialData }: Manufactur
|
|||||||
try {
|
try {
|
||||||
const formData = {
|
const formData = {
|
||||||
...data,
|
...data,
|
||||||
|
company_type: 'manufacturer' as const,
|
||||||
founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined,
|
founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (initialData?.id) {
|
await onSubmit(formData);
|
||||||
await submitManufacturerUpdate(initialData.id, formData, user.id);
|
|
||||||
toast.success('Manufacturer update submitted for review');
|
// Only show success toast and close if not editing through moderation queue
|
||||||
} else {
|
if (!initialData?.id) {
|
||||||
await submitManufacturerCreation(formData, user.id);
|
|
||||||
toast.success('Manufacturer submitted for review');
|
toast.success('Manufacturer submitted for review');
|
||||||
}
|
|
||||||
onCancel();
|
onCancel();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Submission error:', error);
|
console.error('Submission error:', error);
|
||||||
toast.error(error instanceof Error ? error.message : 'Failed to submit manufacturer');
|
toast.error(error instanceof Error ? error.message : 'Failed to submit manufacturer');
|
||||||
|
|||||||
@@ -101,17 +101,17 @@ export function OperatorForm({ onSubmit, onCancel, initialData }: OperatorFormPr
|
|||||||
try {
|
try {
|
||||||
const formData = {
|
const formData = {
|
||||||
...data,
|
...data,
|
||||||
|
company_type: 'operator' as const,
|
||||||
founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined,
|
founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (initialData?.id) {
|
await onSubmit(formData);
|
||||||
await submitOperatorUpdate(initialData.id, formData, user.id);
|
|
||||||
toast.success('Operator update submitted for review');
|
// Only show success toast and close if not editing through moderation queue
|
||||||
} else {
|
if (!initialData?.id) {
|
||||||
await submitOperatorCreation(formData, user.id);
|
|
||||||
toast.success('Operator submitted for review');
|
toast.success('Operator submitted for review');
|
||||||
}
|
|
||||||
onCancel();
|
onCancel();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Submission error:', error);
|
console.error('Submission error:', error);
|
||||||
toast.error(error instanceof Error ? error.message : 'Failed to submit operator');
|
toast.error(error instanceof Error ? error.message : 'Failed to submit operator');
|
||||||
|
|||||||
@@ -127,17 +127,17 @@ export function PropertyOwnerForm({ onSubmit, onCancel, initialData }: PropertyO
|
|||||||
try {
|
try {
|
||||||
const formData = {
|
const formData = {
|
||||||
...data,
|
...data,
|
||||||
|
company_type: 'property_owner' as const,
|
||||||
founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined,
|
founded_year: data.founded_year ? parseInt(String(data.founded_year)) : undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (initialData?.id) {
|
await onSubmit(formData);
|
||||||
await submitPropertyOwnerUpdate(initialData.id, formData, user.id);
|
|
||||||
toast.success('Property owner update submitted for review');
|
// Only show success toast and close if not editing through moderation queue
|
||||||
} else {
|
if (!initialData?.id) {
|
||||||
await submitPropertyOwnerCreation(formData, user.id);
|
|
||||||
toast.success('Property owner submitted for review');
|
toast.success('Property owner submitted for review');
|
||||||
}
|
|
||||||
onCancel();
|
onCancel();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Submission error:', error);
|
console.error('Submission error:', error);
|
||||||
toast.error(error instanceof Error ? error.message : 'Failed to submit property owner');
|
toast.error(error instanceof Error ? error.message : 'Failed to submit property owner');
|
||||||
|
|||||||
Reference in New Issue
Block a user