"use client" import * as React from "react" import { format } from "date-fns" import { cs } from "date-fns/locale" import { CalendarIcon } from "lucide-react" import { cn } from "@/lib/utils" import { Button } from "@/components/ui/button" import { Calendar } from "@/components/ui/calendar" import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover" interface DatePickerProps { value?: Date onChange?: (date: Date | undefined) => void placeholder?: string } export function DatePicker({ value, onChange, placeholder = "Pick a date" }: DatePickerProps) { const [date, setDate] = React.useState(value) const [open, setOpen] = React.useState(false) React.useEffect(() => { setDate(value) }, [value]) const handleSelect = (selectedDate: Date | undefined) => { setDate(selectedDate) onChange?.(selectedDate) setOpen(false) } return ( ) }