import { useId, useMemo, useState } from 'react' import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Button } from "@/components/ui/button" import { Label } from './ui/label' type StyledHourOptionProps = { value: string label24h: string label12h: string } export function StyledHourOption({ value, label24h, label12h }: StyledHourOptionProps) { return (
{label24h}
{label12h}
) } type TimeInputDialogProps = { title: string; isOpen: boolean; onClose: () => void; onSubmit: (time: string) => void; } export function TimeInputDialog({ title, isOpen, onClose, onSubmit }: TimeInputDialogProps) { const [hour, setHour] = useState('00'); const [minute, setMinute] = useState('00'); const hourSelectId = `timeinput-${useId()}`; const minuteSelectId = `timeinput-${useId()}`; const handleSubmit = () => { onSubmit(`${hour}:${minute}`); setHour('00'); setMinute('00'); onClose() } const hoursArray = useMemo(() => Array.from({ length: 24 }, (_, i) => { const h = i.toString().padStart(2, '0') const ampm = i < 12 ? 'AM' : 'PM' const h12 = i % 12 || 12 return { value: h, label24h: h, label12h: `${h12} ${ampm}`, } satisfies StyledHourOptionProps }), []); return ( {title}
) }