// * Other import { fr, enUS } from "date-fns/locale"; import InputError from "@/back/Components/InputError"; import { usePage } from "@inertiajs/react"; import { Calendar } from "@/components/ui/calendar"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { CalendarIcon, RefreshCcw } from "lucide-react"; import { cn } from "@/lib/utils"; import { useFormatedDate } from "@/hooks/use-formated-value"; import useLocale from "@/store/use-locale-store"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { Label } from "@/components/ui/label"; import { Separator } from "@/components/ui/separator"; import str from "@/hooks/use-string"; import useTrans from "@/hooks/use-translations"; export default function SimpleDatePicker({ name, placeholder = "Sélectionner une date", date, required = false, disabled = false, setData, className, label, hasTime = false }: { name: string; placeholder?: string; date?: Date | null; required?: boolean; disabled?: boolean; setData: Function; className?: string; label: string; hasTime?: boolean; }) { let calendarLocale = fr; switch (usePage().props.locale) { case "en": calendarLocale = enUS; break; default: calendarLocale = fr; break; } const parsedDate = date ? new Date(date) : undefined; const errors = usePage().props.errors; const hours = Array.from({ length: 24 }, (_, i) => i); const minutes = Array.from({ length: 12 }, (_, i) => i * 5); const handleDateSelect = (selectedDate: Date | undefined) => { if (selectedDate) { setData(name, selectedDate); } }; const resetDate = () => { setData(name, null); } function handleTimeChange(type: "hour" | "minute", value: string) { const currentDate = parsedDate || new Date(); let newDate = new Date(currentDate); if (type === "hour") { const hour = parseInt(value, 10); newDate.setHours(hour); } else if (type === "minute") { newDate.setMinutes(parseInt(value, 10)); } setData(name, newDate); } return (