import { Card, Col, Flex, Progress, Row, Skeleton, Space, Tag, Typography } from 'antd'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faArrowTrendUp, faCircleExclamation, faClipboardList, } from '@fortawesome/free-solid-svg-icons'; import { Link } from '@tanstack/react-router'; import type { PedidoSummary } from '@sar/api-interface'; import { SITUA_LABEL } from '@sar/api-interface'; import { useRepDashboard } from '../../lib/queries/dashboard'; const { Title, Text } = Typography; const SITUA_COLOR: Record = { 1: 'warning', 2: 'processing', 3: 'error', 4: 'success', }; function fmt(v: number): string { return v.toLocaleString('pt-BR', { style: 'currency', currency: 'BRL' }); } function greeting(): string { const h = new Date().getHours(); if (h < 12) return 'Bom dia'; if (h < 18) return 'Boa tarde'; return 'Boa noite'; } function today(): string { return new Date().toLocaleDateString('pt-BR', { day: 'numeric', month: 'long', }); } export function RafaelPainel() { const { data, isLoading } = useRepDashboard(); if (isLoading || !data) { return ( ); } const { meta, comissao, pedidosMes, pedidosRecentes, clientesInativos, syncedAt } = data; return ( {/* Saudação */} {greeting()}, Rafael {today()} {clientesInativos.length > 0 && ( <> {' '} ·{' '} {clientesInativos.length} clientes inativos )} {/* Linha 1 — Meta + KPIs */} META DO MÊS {fmt(meta.atingido)} de {fmt(meta.total)} = 100 ? 'success' : meta.pct >= 75 ? 'processing' : 'default'} > {meta.pct}% atingido {meta.falta > 0 ? ( Faltam {fmt(meta.falta)} pra fechar o mês. ) : ( Meta batida! Comissão FLEX ativa. )} PEDIDOS NO MÊS {pedidosMes} últimos 30 dias COMISSÃO ACUMULADA {fmt(comissao.total)} {comissao.flex > 0 && ( FLEX: {fmt(comissao.flex)} )} {/* Linha 2 — Clientes inativos + Pedidos recentes */} Clientes esfriando } extra={ clientesInativos.length > 0 ? ( {clientesInativos.length} clientes ) : null } > {clientesInativos.length === 0 ? ( Nenhum cliente inativo. Ótimo trabalho! ) : ( {clientesInativos.map((c) => ( 60 ? '#fff7e6' : 'var(--bg-surface-alt)', }} > {c.nome} {c.ultimaCompraValor && ( Última compra:{' '} {Number(c.ultimaCompraValor).toLocaleString('pt-BR', { style: 'currency', currency: 'BRL', })} )} 60 ? 'orange' : 'default'} className="tabular-nums" > {c.diasSemCompra >= 999 ? 'nunca comprou' : `${c.diasSemCompra}d`} ))} )} Pedidos recentes } extra={Ver todos} > {pedidosRecentes.length === 0 ? ( Nenhum pedido nos últimos 7 dias. ) : ( {pedidosRecentes.map((o: PedidoSummary) => ( {o.numPedSar} Cód. cliente {o.idCliente} {Number(o.total).toLocaleString('pt-BR', { style: 'currency', currency: 'BRL', })} {SITUA_LABEL[o.situa] ?? String(o.situa)} ))} )} SAR · Força de Vendas · Powered by JCS Sistemas Sync: {new Date(syncedAt).toLocaleTimeString('pt-BR')} ); }