diff --git a/susconecta/app/(main-routes)/doutores/page.tsx b/susconecta/app/(main-routes)/doutores/page.tsx index 2a52829..1b6098d 100644 --- a/susconecta/app/(main-routes)/doutores/page.tsx +++ b/susconecta/app/(main-routes)/doutores/page.tsx @@ -964,7 +964,14 @@ export default function DoutoresPage() { {exceptions.map((ex) => (
-
{ex.date} {ex.start_time ? `• ${ex.start_time}` : ''} {ex.end_time ? `— ${ex.end_time}` : ''}
+
{(() => { + try { + const [y, m, d] = String(ex.date).split('-'); + return `${d}/${m}/${y}`; + } catch (e) { + return ex.date; + } + })()} {ex.start_time ? `• ${ex.start_time}` : ''} {ex.end_time ? `— ${ex.end_time}` : ''}
Tipo: {ex.kind} • Motivo: {ex.reason || '—'}
diff --git a/susconecta/components/features/forms/exception-form.tsx b/susconecta/components/features/forms/exception-form.tsx index b42ca0c..2b81e1d 100644 --- a/susconecta/components/features/forms/exception-form.tsx +++ b/susconecta/components/features/forms/exception-form.tsx @@ -6,6 +6,8 @@ import { Button } from '@/components/ui/button' import { Label } from '@/components/ui/label' import { Input } from '@/components/ui/input' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select' +import { Calendar as CalendarComponent } from '@/components/ui/calendar' +import { Calendar } from 'lucide-react' import { criarExcecao, DoctorExceptionCreate } from '@/lib/api' import { useToast } from '@/hooks/use-toast' @@ -23,6 +25,7 @@ export default function ExceptionForm({ open, onOpenChange, doctorId = null, onS const [kind, setKind] = useState<'bloqueio'|'liberacao'>('bloqueio') const [reason, setReason] = useState('') const [submitting, setSubmitting] = useState(false) + const [showDatePicker, setShowDatePicker] = useState(false) const { toast } = useToast() async function handleSubmit(e?: React.FormEvent) { @@ -67,9 +70,64 @@ export default function ExceptionForm({ open, onOpenChange, doctorId = null, onS
-
- - setDate(e.target.value)} /> +
+
+ + +
+
+ { + try { + const [y, m, d] = String(date).split('-'); + return `${d}/${m}/${y}`; + } catch (e) { + return ''; + } + })() : ''} + readOnly + /> + {showDatePicker && ( +
+ { + try { + const [y, m, d] = String(date).split('-').map(Number); + return new Date(y, m - 1, d); + } catch (e) { + return undefined; + } + })() : undefined} + onSelect={(selectedDate) => { + if (selectedDate) { + const y = selectedDate.getFullYear(); + const m = String(selectedDate.getMonth() + 1).padStart(2, '0'); + const d = String(selectedDate.getDate()).padStart(2, '0'); + const dateStr = `${y}-${m}-${d}`; + setDate(dateStr); + setShowDatePicker(false); + } + }} + disabled={(checkDate) => { + const today = new Date(); + today.setHours(0, 0, 0, 0); + return checkDate < today; + }} + /> +
+ )} +