mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 12:51: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 (
|
||||
<SubmissionErrorBoundary submissionId={editItem.id}>
|
||||
<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>
|
||||
);
|
||||
|
||||
case 'ride':
|
||||
return (
|
||||
<SubmissionErrorBoundary submissionId={editItem.id}>
|
||||
<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>
|
||||
);
|
||||
|
||||
case 'manufacturer':
|
||||
return (
|
||||
<SubmissionErrorBoundary submissionId={editItem.id}>
|
||||
<ManufacturerForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
);
|
||||
|
||||
case 'designer':
|
||||
return (
|
||||
<SubmissionErrorBoundary submissionId={editItem.id}>
|
||||
<DesignerForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
);
|
||||
|
||||
case 'operator':
|
||||
return (
|
||||
<SubmissionErrorBoundary submissionId={editItem.id}>
|
||||
<OperatorForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
initialData={jsonToFormData(editItem.item_data) as any}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
);
|
||||
|
||||
case 'property_owner':
|
||||
return (
|
||||
<SubmissionErrorBoundary submissionId={editItem.id}>
|
||||
<PropertyOwnerForm
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
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 (
|
||||
<SubmissionErrorBoundary submissionId={editItem.id}>
|
||||
<RideModelForm
|
||||
manufacturerName={manufacturerName}
|
||||
manufacturerId={manufacturerId}
|
||||
onSubmit={handleSubmit}
|
||||
onCancel={() => onOpenChange(false)}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
initialData={itemData as any}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
);
|
||||
|
||||
case 'photo':
|
||||
|
||||
@@ -18,6 +18,7 @@ import { useAuthModal } from '@/hooks/useAuthModal';
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle';
|
||||
import { useOpenGraph } from '@/hooks/useOpenGraph';
|
||||
import { handleNonCriticalError } from '@/lib/errorHandler';
|
||||
import { SubmissionErrorBoundary } from '@/components/error/SubmissionErrorBoundary';
|
||||
|
||||
export default function DesignerRides() {
|
||||
const { designerSlug } = useParams<{ designerSlug: string }>();
|
||||
@@ -329,10 +330,12 @@ export default function DesignerRides() {
|
||||
|
||||
<Dialog open={isCreateModalOpen} onOpenChange={setIsCreateModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<SubmissionErrorBoundary>
|
||||
<RideForm
|
||||
onSubmit={handleCreateSubmit}
|
||||
onCancel={() => setIsCreateModalOpen(false)}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
||||
@@ -26,6 +26,7 @@ import { useAuthModal } from '@/hooks/useAuthModal';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle';
|
||||
import { useOpenGraph } from '@/hooks/useOpenGraph';
|
||||
import { SubmissionErrorBoundary } from '@/components/error/SubmissionErrorBoundary';
|
||||
|
||||
export default function Designers() {
|
||||
useDocumentTitle('Designers');
|
||||
@@ -359,7 +360,9 @@ export default function Designers() {
|
||||
</main>
|
||||
<Dialog open={isCreateModalOpen} onOpenChange={setIsCreateModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<SubmissionErrorBoundary>
|
||||
<DesignerForm onSubmit={handleCreateSubmit} onCancel={() => setIsCreateModalOpen(false)} />
|
||||
</SubmissionErrorBoundary>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
||||
@@ -18,6 +18,7 @@ import { useAuthModal } from '@/hooks/useAuthModal';
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle';
|
||||
import { useOpenGraph } from '@/hooks/useOpenGraph';
|
||||
import { handleNonCriticalError } from '@/lib/errorHandler';
|
||||
import { SubmissionErrorBoundary } from '@/components/error/SubmissionErrorBoundary';
|
||||
|
||||
interface RideModelWithCount extends RideModel {
|
||||
ride_count: number;
|
||||
@@ -295,11 +296,13 @@ export default function ManufacturerModels() {
|
||||
|
||||
<Dialog open={isCreateModalOpen} onOpenChange={setIsCreateModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<SubmissionErrorBoundary>
|
||||
<RideModelForm
|
||||
manufacturerName={manufacturer.name}
|
||||
onSubmit={handleCreateSubmit}
|
||||
onCancel={() => setIsCreateModalOpen(false)}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
||||
@@ -18,6 +18,7 @@ import { useAuthModal } from '@/hooks/useAuthModal';
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle';
|
||||
import { useOpenGraph } from '@/hooks/useOpenGraph';
|
||||
import { handleNonCriticalError } from '@/lib/errorHandler';
|
||||
import { SubmissionErrorBoundary } from '@/components/error/SubmissionErrorBoundary';
|
||||
|
||||
export default function ManufacturerRides() {
|
||||
const { manufacturerSlug } = useParams<{ manufacturerSlug: string }>();
|
||||
@@ -329,10 +330,12 @@ export default function ManufacturerRides() {
|
||||
|
||||
<Dialog open={isCreateModalOpen} onOpenChange={setIsCreateModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<SubmissionErrorBoundary>
|
||||
<RideForm
|
||||
onSubmit={handleCreateSubmit}
|
||||
onCancel={() => setIsCreateModalOpen(false)}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
||||
@@ -26,6 +26,7 @@ import { useAuthModal } from '@/hooks/useAuthModal';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle';
|
||||
import { useOpenGraph } from '@/hooks/useOpenGraph';
|
||||
import { SubmissionErrorBoundary } from '@/components/error/SubmissionErrorBoundary';
|
||||
|
||||
export default function Manufacturers() {
|
||||
useDocumentTitle('Manufacturers');
|
||||
@@ -374,10 +375,12 @@ export default function Manufacturers() {
|
||||
{/* Create Modal */}
|
||||
<Dialog open={isCreateModalOpen} onOpenChange={setIsCreateModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<SubmissionErrorBoundary>
|
||||
<ManufacturerForm
|
||||
onSubmit={handleCreateSubmit}
|
||||
onCancel={() => setIsCreateModalOpen(false)}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
||||
@@ -26,6 +26,7 @@ import { useAuthModal } from '@/hooks/useAuthModal';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle';
|
||||
import { useOpenGraph } from '@/hooks/useOpenGraph';
|
||||
import { SubmissionErrorBoundary } from '@/components/error/SubmissionErrorBoundary';
|
||||
|
||||
const Operators = () => {
|
||||
useDocumentTitle('Operators');
|
||||
@@ -377,10 +378,12 @@ const Operators = () => {
|
||||
{/* Create Modal */}
|
||||
<Dialog open={isCreateModalOpen} onOpenChange={setIsCreateModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<SubmissionErrorBoundary>
|
||||
<OperatorForm
|
||||
onSubmit={handleCreateSubmit}
|
||||
onCancel={() => setIsCreateModalOpen(false)}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</main>
|
||||
|
||||
@@ -26,6 +26,7 @@ import { usePhotoCount } from '@/hooks/photos/usePhotoCount';
|
||||
const RideForm = lazy(() => import('@/components/admin/RideForm').then(m => ({ default: m.RideForm })));
|
||||
const ParkForm = lazy(() => import('@/components/admin/ParkForm').then(m => ({ default: m.ParkForm })));
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { SubmissionErrorBoundary } from '@/components/error/SubmissionErrorBoundary';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { Edit } from 'lucide-react';
|
||||
import { VersionIndicator } from '@/components/versioning/VersionIndicator';
|
||||
@@ -610,10 +611,13 @@ export default function ParkDetail() {
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<Suspense fallback={<AdminFormSkeleton />}>
|
||||
<SubmissionErrorBoundary>
|
||||
<RideForm
|
||||
onSubmit={handleRideSubmit}
|
||||
onCancel={() => setIsAddRideModalOpen(false)}
|
||||
initialData={{ park_id: park.id }}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
</Suspense>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
@@ -628,6 +632,7 @@ export default function ParkDetail() {
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<Suspense fallback={<AdminFormSkeleton />}>
|
||||
<SubmissionErrorBoundary>
|
||||
<ParkForm
|
||||
onSubmit={handleEditParkSubmit}
|
||||
onCancel={() => setIsEditParkModalOpen(false)}
|
||||
@@ -650,6 +655,7 @@ export default function ParkDetail() {
|
||||
}}
|
||||
isEditing={true}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
</Suspense>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
@@ -20,6 +20,7 @@ import { useAuthModal } from '@/hooks/useAuthModal';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle';
|
||||
import { useOpenGraph } from '@/hooks/useOpenGraph';
|
||||
import { SubmissionErrorBoundary } from '@/components/error/SubmissionErrorBoundary';
|
||||
|
||||
const ParkOwners = () => {
|
||||
useDocumentTitle('Property Owners');
|
||||
@@ -242,10 +243,12 @@ const ParkOwners = () => {
|
||||
{/* Create Modal */}
|
||||
<Dialog open={isCreateModalOpen} onOpenChange={setIsCreateModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<SubmissionErrorBoundary>
|
||||
<PropertyOwnerForm
|
||||
onSubmit={handleCreateSubmit}
|
||||
onCancel={() => setIsCreateModalOpen(false)}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</main>
|
||||
|
||||
@@ -18,6 +18,7 @@ import { getErrorMessage, handleNonCriticalError } from '@/lib/errorHandler';
|
||||
import { useAuthModal } from '@/hooks/useAuthModal';
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle';
|
||||
import { useOpenGraph } from '@/hooks/useOpenGraph';
|
||||
import { SubmissionErrorBoundary } from '@/components/error/SubmissionErrorBoundary';
|
||||
|
||||
export default function ParkRides() {
|
||||
const { parkSlug } = useParams<{ parkSlug: string }>();
|
||||
@@ -353,12 +354,14 @@ export default function ParkRides() {
|
||||
{/* Create Modal */}
|
||||
<Dialog open={isCreateModalOpen} onOpenChange={setIsCreateModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<SubmissionErrorBoundary>
|
||||
<RideForm
|
||||
onSubmit={handleCreateSubmit as any}
|
||||
onCancel={() => setIsCreateModalOpen(false)}
|
||||
isEditing={false}
|
||||
initialData={{ park_id: park.id }}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</main>
|
||||
|
||||
@@ -39,6 +39,7 @@ import { useAuthModal } from "@/hooks/useAuthModal";
|
||||
import { useOpenGraph } from "@/hooks/useOpenGraph";
|
||||
import { useParks } from "@/hooks/parks/useParks";
|
||||
import { Pagination } from "@/components/common/Pagination";
|
||||
import { SubmissionErrorBoundary } from "@/components/error/SubmissionErrorBoundary";
|
||||
|
||||
export interface FilterState {
|
||||
search: string;
|
||||
@@ -583,7 +584,9 @@ export default function Parks() {
|
||||
Add a new park to the database. Your submission will be reviewed before being published.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<SubmissionErrorBoundary>
|
||||
<ParkForm onSubmit={handleParkSubmit} onCancel={() => setIsAddParkModalOpen(false)} isEditing={false} />
|
||||
</SubmissionErrorBoundary>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</main>
|
||||
|
||||
@@ -17,6 +17,7 @@ import { toast } from '@/hooks/use-toast';
|
||||
import { getErrorMessage, handleNonCriticalError } from '@/lib/errorHandler';
|
||||
import type { Ride, Company, RideModel } from "@/types/database";
|
||||
import { useDocumentTitle } from '@/hooks/useDocumentTitle';
|
||||
import { SubmissionErrorBoundary } from '@/components/error/SubmissionErrorBoundary';
|
||||
|
||||
export default function RideModelRides() {
|
||||
const { manufacturerSlug, modelSlug } = useParams<{ manufacturerSlug: string; modelSlug: string }>();
|
||||
@@ -293,10 +294,12 @@ export default function RideModelRides() {
|
||||
{/* Create Modal */}
|
||||
<Dialog open={isCreateModalOpen} onOpenChange={setIsCreateModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<SubmissionErrorBoundary>
|
||||
<RideForm
|
||||
onSubmit={handleCreateSubmit}
|
||||
onCancel={() => setIsCreateModalOpen(false)}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
||||
@@ -26,6 +26,7 @@ import { useDocumentTitle } from '@/hooks/useDocumentTitle';
|
||||
import { useOpenGraph } from '@/hooks/useOpenGraph';
|
||||
import { useRides } from '@/hooks/rides/useRides';
|
||||
import { Pagination } from '@/components/common/Pagination';
|
||||
import { SubmissionErrorBoundary } from '@/components/error/SubmissionErrorBoundary';
|
||||
|
||||
export default function Rides() {
|
||||
useDocumentTitle('Rides & Attractions');
|
||||
@@ -529,11 +530,13 @@ export default function Rides() {
|
||||
{/* Create Modal */}
|
||||
<Dialog open={isCreateModalOpen} onOpenChange={setIsCreateModalOpen}>
|
||||
<DialogContent className="max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<SubmissionErrorBoundary>
|
||||
<RideForm
|
||||
onSubmit={handleCreateSubmit}
|
||||
onCancel={() => setIsCreateModalOpen(false)}
|
||||
isEditing={false}
|
||||
/>
|
||||
</SubmissionErrorBoundary>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user