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

{description || "\u00A0"}

)} /> ); }