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:
gpt-engineer-app[bot]
2025-11-11 23:44:48 +00:00
parent 92e93bfc9d
commit f4300de738
5 changed files with 60 additions and 26 deletions

View File

@@ -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 {