import React, { useEffect, useState } from 'react'; interface Evento { id: string; data: string; tipo: string; descricao: string; } export const CalendarioAtendimentos: React.FC = () => { const [eventos, setEventos] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { async function fetchEventos() { try { setLoading(true); setError(null); const res = await fetch('/api/eventos'); if (!res.ok) throw new Error('Erro ao buscar eventos'); const data = await res.json(); setEventos(data); } catch (err: any) { setError(err.message); } finally { setLoading(false); } } fetchEventos(); }, []); // Simulação de calendário mensal const diasMes = Array.from({ length: 30 }, (_, i) => i + 1); const mes = '06'; const ano = '2024'; if (loading) return
Carregando calendário...
; if (error) return
{error}
; return (
{diasMes.map((dia) => { const dataStr = `${ano}-${mes}-${dia.toString().padStart(2, '0')}`; const eventosDia = eventos.filter(e => e.data === dataStr); return (
{dia} {eventosDia.map((ev) => ( {ev.tipo} ))}
); })}

Próximos eventos

    {eventos.map((ev) => (
  • {ev.data}: {ev.tipo} - {ev.descricao}
  • ))}
); };