Enhance FormFieldWrapper with blur validation and toasts

Adds validation on blur mode to FormFieldWrapper, introduces animated validation states, and implements standardized form submission toasts via a new formToasts helper; updates ParkForm and RideForm to use the new toast system and to propagate error state with scroll-to-error support.
This commit is contained in:
gpt-engineer-app[bot]
2025-11-11 23:43:01 +00:00
parent 7d085a0702
commit 92e93bfc9d
5 changed files with 150 additions and 24 deletions

65
src/lib/formToasts.ts Normal file
View File

@@ -0,0 +1,65 @@
import { toast } from '@/hooks/use-toast';
/**
* Standardized toast notifications for form submissions
* Provides consistent success/error feedback across all forms
*/
export const formToasts = {
success: {
create: (entityType: string, entityName?: string) => {
toast({
title: '✓ Submission Created',
description: entityName
? `${entityName} has been submitted for review.`
: `${entityType} has been submitted for review.`,
variant: 'default',
});
},
update: (entityType: string, entityName?: string) => {
toast({
title: '✓ Update Submitted',
description: entityName
? `Changes to ${entityName} have been submitted for review.`
: `${entityType} update has been submitted for review.`,
variant: 'default',
});
},
moderatorApproval: (entityType: string, entityName?: string) => {
toast({
title: '✓ Published Successfully',
description: entityName
? `${entityName} is now live on the site.`
: `${entityType} is now live on the site.`,
variant: 'default',
});
},
},
error: {
validation: (fieldCount: number) => {
toast({
title: 'Validation Failed',
description: `Please fix ${fieldCount} error${fieldCount > 1 ? 's' : ''} before submitting.`,
variant: 'destructive',
});
},
network: () => {
toast({
title: 'Connection Error',
description: 'Unable to submit. Please check your connection and try again.',
variant: 'destructive',
});
},
generic: (error: string) => {
toast({
title: 'Submission Failed',
description: error,
variant: 'destructive',
});
},
},
};