Extract shared form field components and enum utilities #17

Closed
opened 2026-02-08 06:44:20 -08:00 by kyle · 1 comment
Owner

Context: Form components duplicate several patterns:

  • toDatetimeLocal() function copied identically in VIPForm and EventForm
  • Department, ArrivalMode, EventType label/option mappings hardcoded in 5+ locations
  • Form field markup (label + input + error) repeated extensively

Files affected:

  • frontend/src/components/VIPForm.tsx (lines 47-57, 134-390, 197-199)
  • frontend/src/components/DriverForm.tsx (lines 74-137, 114-118)
  • frontend/src/components/EventForm.tsx (lines 44-54, 319-494, 455-477)
  • frontend/src/pages/VipList.tsx (lines 190-202)
  • frontend/src/pages/DriverList.tsx (lines 195-202)

Suggested fix:

  • Move toDatetimeLocal() to frontend/src/lib/utils.ts
  • Create frontend/src/lib/enum-labels.ts with all enum display mappings
  • Optionally create <FormField> wrapper component for label+input+error pattern

Effort: Small

**Context:** Form components duplicate several patterns: - `toDatetimeLocal()` function copied identically in VIPForm and EventForm - Department, ArrivalMode, EventType label/option mappings hardcoded in 5+ locations - Form field markup (label + input + error) repeated extensively **Files affected:** - `frontend/src/components/VIPForm.tsx` (lines 47-57, 134-390, 197-199) - `frontend/src/components/DriverForm.tsx` (lines 74-137, 114-118) - `frontend/src/components/EventForm.tsx` (lines 44-54, 319-494, 455-477) - `frontend/src/pages/VipList.tsx` (lines 190-202) - `frontend/src/pages/DriverList.tsx` (lines 195-202) **Suggested fix:** - Move `toDatetimeLocal()` to `frontend/src/lib/utils.ts` - Create `frontend/src/lib/enum-labels.ts` with all enum display mappings - Optionally create `<FormField>` wrapper component for label+input+error pattern **Effort:** Small
Author
Owner

Moved to shared utils. Created with DEPARTMENT_LABELS, ARRIVAL_MODE_LABELS, EVENT_TYPE_LABELS, EVENT_STATUS_LABELS. Updated all form and list files.

Moved to shared utils. Created with DEPARTMENT_LABELS, ARRIVAL_MODE_LABELS, EVENT_TYPE_LABELS, EVENT_STATUS_LABELS. Updated all form and list files.
kyle closed this issue 2026-02-08 07:09:58 -08:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kyle/vip-coordinator#17