'use client'; import type { ComponentProps } from 'react'; import type { FieldErrors, UseFormRegister } from 'react-hook-form'; import { Loader2 } from 'lucide-react'; import { FormField } from '@/components/form'; import { Button } from '@/components/ui/button'; import { Dialog, DialogBody, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import type { ProjectFormValues } from '../hooks/useProjectForm'; interface ProjectDialogProps { open: boolean; onOpenChange: (open: boolean) => void; projectId?: string; register: UseFormRegister; errors: FieldErrors; isSubmitted: boolean; onSubmit: ComponentProps<'form'>['onSubmit']; canSubmit: boolean; isSaving: boolean; } export function ProjectDialog({ open, onOpenChange, projectId, register, errors, isSubmitted, onSubmit, canSubmit, isSaving, }: ProjectDialogProps) { const nameErrorMessage = isSubmitted ? errors.name?.message : undefined; const startLatErrorMessage = isSubmitted ? errors.start_lat?.message : undefined; const startLngErrorMessage = isSubmitted ? errors.start_lng?.message : undefined; const endLatErrorMessage = isSubmitted ? errors.end_lat?.message : undefined; const endLngErrorMessage = isSubmitted ? errors.end_lng?.message : undefined; return ( event.preventDefault()} > {projectId ? 'Edit Project' : 'Create Project'} Manage road project identity and optional coordinate boundaries.

Basic details

Project name and corridor information.

Coordinates

Optional start and end points for the project boundary.

); }