Form validation for event create/update (#218)
* refactor: migrate EventModal to use shared EventFormFields component * feat: add form validation for event create/update - Validate title is required - Validate end datetime must be after start datetime - Disable save button when form is invalid - Show error messages below invalid fields with red highlight (MUI) - Title validation in create mode only shows error after field is touched - Track touched state to avoid showing errors on initial load * feat: improve event modal UX with auto-focus and default times - Auto-focus title field when opening create/update event modal - Set default datetime when creating event without selecting range: * Start time = current time + 1 hour (rounded to :00) * End time = start time + 1 hour - Applied duplicate event to display datetime from original event - Fix logic to detect empty event object vs valid event with uid * fix: improve validation UX and add required field indicator - Only show validation errors when modal is open (isOpen check) - Add red asterisk (*) to Title label to indicate required field - Prevent validation error flash when closing modal - Fix TypeScript errors in EventUpdateModal - Keep validation behavior: only show error after user types and deletes * feat: auto-focus title field when toggling between normal and extended mode in event modal * update: only validation when click on save button * fix: prevent form data loss and validation errors in event modals Fixes: 1. Form fields no longer clear when changing start/end dates 2. Extended mode stays active when modifying dates 3. No validation errors shown after successful save
This commit is contained in:
@@ -16,7 +16,7 @@ import { getEvent } from "../../../features/Events/EventApi";
|
||||
import { refreshCalendars } from "../../Event/utils/eventUtils";
|
||||
import { updateTempCalendar } from "../utils/calendarUtils";
|
||||
import { User } from "../../Attendees/PeopleSearch";
|
||||
import { formatLocalDateTime } from "../../../features/Events/EventModal";
|
||||
import { formatLocalDateTime } from "../../Event/EventFormFields";
|
||||
|
||||
export interface EventHandlersProps {
|
||||
setSelectedRange: (range: DateSelectArg | null) => void;
|
||||
|
||||
Reference in New Issue
Block a user