mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 21:11:12 -05:00
Apply blur validation and toasts to remaining forms
Extend forms with blur-based validation via FormFieldWrapper.validationMode, and replace inline toasts with centralized formToasts. Update ManufacturerForm, DesignerForm, OperatorForm, PropertyOwnerForm, RideModelForm, and related components to use the new toast helper and ensure data-error scroll behavior where applicable.
This commit is contained in:
@@ -16,8 +16,9 @@ import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { HeadquartersLocationInput } from './HeadquartersLocationInput';
|
||||
import { EntityMultiImageUploader } from '@/components/upload/EntityMultiImageUploader';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { toast } from 'sonner';
|
||||
import { handleError } from '@/lib/errorHandler';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { handleError, getErrorMessage } from '@/lib/errorHandler';
|
||||
import { formToasts } from '@/lib/formToasts';
|
||||
import type { UploadedImage } from '@/types/company';
|
||||
|
||||
// Zod output type (after transformation)
|
||||
@@ -73,7 +74,7 @@ export function OperatorForm({ onSubmit, onCancel, initialData }: OperatorFormPr
|
||||
<CardContent>
|
||||
<form onSubmit={handleSubmit(async (data) => {
|
||||
if (!user) {
|
||||
toast.error('You must be logged in to submit');
|
||||
formToasts.error.generic('You must be logged in to submit');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,9 +94,11 @@ export function OperatorForm({ onSubmit, onCancel, initialData }: OperatorFormPr
|
||||
|
||||
await onSubmit(formData);
|
||||
|
||||
// Only show success toast and close if not editing through moderation queue
|
||||
if (!initialData?.id) {
|
||||
toast.success('Operator submitted for review');
|
||||
// Show success toast
|
||||
if (initialData?.id) {
|
||||
formToasts.success.update('Operator', data.name);
|
||||
} else {
|
||||
formToasts.success.create('Operator', data.name);
|
||||
onCancel();
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
@@ -104,6 +107,9 @@ export function OperatorForm({ onSubmit, onCancel, initialData }: OperatorFormPr
|
||||
metadata: { companyName: data.name }
|
||||
});
|
||||
|
||||
// Show error toast
|
||||
formToasts.error.generic(getErrorMessage(error));
|
||||
|
||||
// Re-throw so parent can handle modal closing
|
||||
throw error;
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user