// DatePickerField.tsx import { Button, Calendar, FormControl, FormField, FormItem, FormLabel, FormMessage, Popover, PopoverContent, PopoverTrigger, } from "@repo/shadcn-ui/components"; import { CalendarIcon, LockIcon } from "lucide-react"; import { cn } from "@repo/shadcn-ui/lib/utils"; import { format } from "date-fns"; import { Control, FieldPath, FieldValues } from "react-hook-form"; import { useTranslation } from "../../locales/i18n.ts"; type DatePickerFieldProps = { control: Control; name: FieldPath; label?: string; placeholder?: string; description?: string; disabled?: boolean; required?: boolean; readOnly?: boolean; className?: string; formatDateFn?: (iso: string) => string; }; export function DatePickerField({ control, name, label, placeholder, description, disabled = false, required = false, readOnly = false, className, formatDateFn = (iso) => format(new Date(iso), "dd/MM/yyyy"), }: DatePickerFieldProps) { const { t } = useTranslation(); const isDisabled = disabled || readOnly; return ( ( {label && (
{label} {required && {t("common.required")}}
)} { if (!readOnly) { field.onChange(date?.toISOString()); } }} initialFocus />

{description || "\u00A0"}

)} /> ); }