mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 05:51:15 -05:00
Refactor: Execute remaining phases
This commit is contained in:
@@ -19,6 +19,7 @@ import { FlexibleDateInput, type DatePrecision } from '@/components/ui/flexible-
|
||||
import { submitDesignerCreation, submitDesignerUpdate } from '@/lib/entitySubmissionHelpers';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { toast } from 'sonner';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import type { UploadedImage } from '@/types/company';
|
||||
|
||||
@@ -113,9 +114,11 @@ export function DesignerForm({ onSubmit, onCancel, initialData }: DesignerFormPr
|
||||
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');
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: initialData?.id ? 'Update Designer' : 'Create Designer',
|
||||
metadata: { companyName: data.name }
|
||||
});
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
|
||||
@@ -122,10 +122,9 @@ export function LocationSearch({ onLocationSelect, initialLocationId, className
|
||||
setResults(data);
|
||||
setShowResults(true);
|
||||
setSearchError(null);
|
||||
} catch (error) {
|
||||
const errorMsg = error instanceof Error ? error.message : 'Failed to search locations. Please check your connection.';
|
||||
console.error('Error searching locations:', error);
|
||||
setSearchError(errorMsg);
|
||||
} catch (error: unknown) {
|
||||
logger.error('Location search failed', { query: searchQuery });
|
||||
setSearchError('Failed to search locations. Please check your connection.');
|
||||
setResults([]);
|
||||
setShowResults(false);
|
||||
} finally {
|
||||
|
||||
@@ -19,6 +19,7 @@ import { FlexibleDateInput, type DatePrecision } from '@/components/ui/flexible-
|
||||
import { submitManufacturerCreation, submitManufacturerUpdate } from '@/lib/entitySubmissionHelpers';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { toast } from 'sonner';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { toDateOnly } from '@/lib/dateUtils';
|
||||
import type { UploadedImage } from '@/types/company';
|
||||
@@ -116,9 +117,11 @@ export function ManufacturerForm({ onSubmit, onCancel, initialData }: Manufactur
|
||||
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');
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: initialData?.id ? 'Update Manufacturer' : 'Create Manufacturer',
|
||||
metadata: { companyName: data.name }
|
||||
});
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import { FlexibleDateInput, type DatePrecision } from '@/components/ui/flexible-
|
||||
import { submitOperatorCreation, submitOperatorUpdate } from '@/lib/entitySubmissionHelpers';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { toast } from 'sonner';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import type { UploadedImage } from '@/types/company';
|
||||
|
||||
@@ -113,9 +114,11 @@ export function OperatorForm({ onSubmit, onCancel, initialData }: OperatorFormPr
|
||||
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');
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: initialData?.id ? 'Update Operator' : 'Create Operator',
|
||||
metadata: { companyName: data.name }
|
||||
});
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import { DatePicker } from '@/components/ui/date-picker';
|
||||
import { FlexibleDateInput, type DatePrecision } from '@/components/ui/flexible-date-input';
|
||||
import { SlugField } from '@/components/ui/slug-field';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
import { MapPin, Save, X, Plus } from 'lucide-react';
|
||||
import { toDateOnly } from '@/lib/dateUtils';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
@@ -193,12 +193,16 @@ export function ParkForm({ onSubmit, onCancel, initialData, isEditing = false }:
|
||||
? "The park information has been updated successfully."
|
||||
: "The new park has been created successfully."
|
||||
});
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
toast({
|
||||
title: "Error",
|
||||
description: errorMsg,
|
||||
variant: "destructive"
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: isEditing ? 'Update Park' : 'Create Park',
|
||||
userId: user?.id,
|
||||
metadata: {
|
||||
parkName: data.name,
|
||||
hasLocation: !!data.location_id,
|
||||
hasNewOperator: !!tempNewOperator,
|
||||
hasNewOwner: !!tempNewPropertyOwner
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
|
||||
@@ -19,6 +19,7 @@ import { FlexibleDateInput, type DatePrecision } from '@/components/ui/flexible-
|
||||
import { submitPropertyOwnerCreation, submitPropertyOwnerUpdate } from '@/lib/entitySubmissionHelpers';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { toast } from 'sonner';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import type { UploadedImage } from '@/types/company';
|
||||
|
||||
@@ -113,9 +114,11 @@ export function PropertyOwnerForm({ onSubmit, onCancel, initialData }: PropertyO
|
||||
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');
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: initialData?.id ? 'Update Property Owner' : 'Create Property Owner',
|
||||
metadata: { companyName: data.name }
|
||||
});
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } f
|
||||
import { Combobox } from '@/components/ui/combobox';
|
||||
import { SlugField } from '@/components/ui/slug-field';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { getErrorMessage } from '@/lib/errorHandler';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
import { Plus, Zap, Save, X } from 'lucide-react';
|
||||
import { toDateOnly } from '@/lib/dateUtils';
|
||||
import { useUnitPreferences } from '@/hooks/useUnitPreferences';
|
||||
@@ -264,12 +264,14 @@ export function RideForm({ onSubmit, onCancel, initialData, isEditing = false }:
|
||||
? "Ride, manufacturer, and model submitted for review"
|
||||
: "Ride submitted for review"
|
||||
});
|
||||
} catch (error) {
|
||||
const errorMsg = getErrorMessage(error);
|
||||
toast({
|
||||
title: "Error",
|
||||
description: errorMsg,
|
||||
variant: "destructive"
|
||||
} catch (error: unknown) {
|
||||
handleError(error, {
|
||||
action: isEditing ? 'Update Ride' : 'Create Ride',
|
||||
metadata: {
|
||||
rideName: data.name,
|
||||
hasNewManufacturer: !!tempNewManufacturer,
|
||||
hasNewModel: !!tempNewRideModel
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
|
||||
Reference in New Issue
Block a user