import React, { useEffect, useState } from 'react'; import { Users, Calendar, DollarSign, Activity, ArrowUpRight, ArrowDownRight, Zap, TrendingUp, AlertCircle, ArrowRight } from 'lucide-react'; import { MedicoBackend } from './services/medicoBackend.ts'; import { MedicoNotif } from './services/medicoNotif.ts'; import { MedPaciente, MedAgendamento, MedNotificacao } from './types.ts'; export const MedDashboard: React.FC = () => { const [pacientes, setPacientes] = useState([]); const [agendamentos, setAgendamentos] = useState([]); const [notificacoes, setNotificacoes] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { const loadData = async () => { await MedicoNotif.generateIntelligentAlerts(); const [p, a, n] = await Promise.all([ MedicoBackend.getPacientes(), MedicoBackend.getAgendamentos(), MedicoBackend.getNotificacoes() ]); setPacientes(p); setAgendamentos(a); setNotificacoes(n.filter(notif => !notif.lida)); setLoading(false); }; loadData(); }, []); const stats = [ { label: 'Pacientes Ativos', value: pacientes.length.toString(), change: '+12%', positive: true, icon: Users, color: 'cyan' }, { label: 'Consultas Hoje', value: agendamentos.filter(a => a.start.includes(new Date().toISOString().split('T')[0])).length.toString(), change: '+4', positive: true, icon: Calendar, color: 'blue' }, { label: 'Receita Est. (MRR)', value: 'R$ 84.200', change: '+8%', positive: true, icon: DollarSign, color: 'emerald' }, { label: 'Alertas Ativos', value: notificacoes.length.toString(), change: '', positive: true, icon: Activity, color: 'purple' }, ]; if (loading) { return
Iniciando Motor Médico...
; } return (
{/* Header */}

Painel Estratégico

Visão geral do ecossistema médico e fidelidade

{/* Stats Grid */}
{stats.map((stat, i) => { const Icon = stat.icon; return (
{stat.change && (stat.positive ? : )} {stat.change}
{stat.label}
{stat.value}
); })}
{/* Main Content Grid */}
{/* Upcoming Appointments */}

Próximos Atendimentos

{agendamentos.length > 0 ? agendamentos.slice(0, 5).map((item, i) => (
HRS {new Date(item.start).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}
{item.pacienteNome}
{item.tipo}
{item.status}
)) : (
Nenhum agendamento para hoje
)}
{/* Intelligent Insights */}

Inteligência
Médica

{notificacoes.length > 0 ? notificacoes.slice(0, 2).map((notif, i) => (
{notif.titulo}

{notif.mensagem}

)) : (

Sem alertas pendentes

)}
); };