import { useState } from 'react'; import { format } from 'date-fns'; interface Props { isOpen: boolean; onClose: () => void; onSave: (data: { date: string; time: string; description: string }) => Promise; } export function AddLogModal({ isOpen, onClose, onSave }: Props) { const [date, setDate] = useState(format(new Date(), 'yyyy-MM-dd')); const [time, setTime] = useState('8'); const [description, setDescription] = useState(''); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); if (!isOpen) return null; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); setIsLoading(true); try { await onSave({ date, time, description }); setTime('8'); setDescription(''); onClose(); } catch (err) { setError(err instanceof Error ? err.message : 'Ошибка'); } finally { setIsLoading(false); } }; const setQuickTime = (value: string) => { setTime(value); }; return (

Новая запись

setDate(e.target.value)} className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" required />
setTime(e.target.value)} placeholder="8, 8:30, 8,5" className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" required />

Форматы: 8, 8:30, 8,5, 8.5