mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 09:11:13 -05:00
Wrap forms with error boundaries
This commit is contained in:
@@ -22,6 +22,7 @@ import { jsonToFormData } from '@/lib/typeConversions';
|
||||
import { PropertyOwnerForm } from '@/components/admin/PropertyOwnerForm';
|
||||
import { RideModelForm } from '@/components/admin/RideModelForm';
|
||||
import { Save, X, Edit } from 'lucide-react';
|
||||
import { SubmissionErrorBoundary } from '@/components/error/SubmissionErrorBoundary';
|
||||
|
||||
interface ItemEditDialogProps {
|
||||
item?: SubmissionItemWithDeps | null;
|
||||
@@ -131,66 +132,70 @@ export function ItemEditDialog({ item, items, open, onOpenChange, onComplete }:
|
||||
switch (editItem.item_type) {
|
||||
case 'park':
|
||||
return (
|
||||
<ParkForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
// Convert Json to form-compatible object (null → undefined)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
isEditing
|
||||
/>
|
||||
<SubmissionErrorBoundary submissionId={editItem.id}>
|
||||
<ParkForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
isEditing
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
);
|
||||
|
||||
case 'ride':
|
||||
return (
|
||||
<RideForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
// Convert Json to form-compatible object (null → undefined)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
isEditing
|
||||
/>
|
||||
<SubmissionErrorBoundary submissionId={editItem.id}>
|
||||
<RideForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
isEditing
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
);
|
||||
|
||||
case 'manufacturer':
|
||||
return (
|
||||
<ManufacturerForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
/>
|
||||
<SubmissionErrorBoundary submissionId={editItem.id}>
|
||||
<ManufacturerForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
);
|
||||
|
||||
case 'designer':
|
||||
return (
|
||||
<DesignerForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
/>
|
||||
<SubmissionErrorBoundary submissionId={editItem.id}>
|
||||
<DesignerForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
);
|
||||
|
||||
case 'operator':
|
||||
return (
|
||||
<OperatorForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
/>
|
||||
<SubmissionErrorBoundary submissionId={editItem.id}>
|
||||
<OperatorForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
);
|
||||
|
||||
case 'property_owner':
|
||||
return (
|
||||
<PropertyOwnerForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
/>
|
||||
<SubmissionErrorBoundary submissionId={editItem.id}>
|
||||
<PropertyOwnerForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
);
|
||||
|
||||
case 'ride_model':
|
||||
@@ -201,14 +206,15 @@ export function ItemEditDialog({ item, items, open, onOpenChange, onComplete }:
|
||||
? itemData.manufacturer_id
|
||||
: '';
|
||||
return (
|
||||
<RideModelForm
|
||||
manufacturerName={manufacturerName}
|
||||
manufacturerId={manufacturerId}
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
initialData={itemData as any}
|
||||
/>
|
||||
<SubmissionErrorBoundary submissionId={editItem.id}>
|
||||
<RideModelForm
|
||||
manufacturerName={manufacturerName}
|
||||
manufacturerId={manufacturerId}
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
initialData={itemData as any}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
);
|
||||
|
||||
case 'photo':
|
||||
|
||||
Reference in New Issue
Block a user