import { useState } from 'react'; import { X } from 'lucide-react'; import { DEPARTMENT_LABELS } from '@/lib/enum-labels'; interface DriverFormProps { driver?: Driver | null; onSubmit: (data: DriverFormData) => void; onCancel: () => void; isSubmitting: boolean; } interface Driver { id: string; name: string; phone: string; department: string | null; userId: string | null; } export interface DriverFormData { name: string; phone: string; department?: string; userId?: string; } export function DriverForm({ driver, onSubmit, onCancel, isSubmitting }: DriverFormProps) { const [formData, setFormData] = useState({ name: driver?.name || '', phone: driver?.phone || '', department: driver?.department || 'OFFICE_OF_DEVELOPMENT', userId: driver?.userId || '', }); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); // Clean up the data - remove empty strings for optional fields const cleanedData = { ...formData, department: formData.department || undefined, userId: formData.userId || undefined, }; onSubmit(cleanedData); }; const handleChange = ( e: React.ChangeEvent ) => { const { name, value } = e.target; setFormData((prev) => ({ ...prev, [name]: value, })); }; return (

{driver ? 'Edit Driver' : 'Add New Driver'}

{/* Name */}
{/* Phone */}
{/* Department */}
{/* User ID (optional, for linking driver to user account) */}

Link this driver to a user account for login access

{/* Actions */}
); }