// Formatação para exibição (pt-BR, fuso de Belo Horizonte). const TZ = "America/Sao_Paulo"; const dateTime = new Intl.DateTimeFormat("pt-BR", { timeZone: TZ, day: "2-digit", month: "2-digit", year: "numeric", hour: "2-digit", minute: "2-digit", }); const clock = new Intl.DateTimeFormat("pt-BR", { timeZone: TZ, hour: "2-digit", minute: "2-digit" }); export function fmtDateTime(value: string | null | undefined): string { return value ? dateTime.format(new Date(value)) : "—"; } export function fmtClock(value: string | null | undefined, timeZone = TZ): string { if (!value) return "—"; return timeZone === TZ ? clock.format(new Date(value)) : new Intl.DateTimeFormat("pt-BR", { timeZone, hour: "2-digit", minute: "2-digit" }).format(new Date(value)); } export function fmtDay(day: string): string { const [y, m, d] = day.split("-"); return `${d}/${m}/${y}`; } export function fmtMinutes(minutes: number): string { return `${Math.floor(minutes / 60)}h${String(minutes % 60).padStart(2, "0")}`; } export const userStatusLabel: Record = { pending: "aguardando aprovação", active: "ativo", disabled: "desativado", }; export const notificationStatusLabel: Record = { scheduled: "agendado", sending: "enviando", sent: "enviado", failed: "falhou", cancelled: "cancelado", expired: "expirado", }; export const dayStatusLabel: Record = { awaiting: "aguardando primeira consulta", no_points: "sem pontos (reverificando)", working: "acompanhando", not_working: "sem pontos (encerrado)", finished: "jornada encerrada", }; export const pauseReasonLabel: Record = { manual: "pausado pelo usuário", api_failures: "pausado após falhas na PontoMais", admin: "pausado pelo painel", user_disabled: "usuário desativado", }; export function badgeClass(status: string): string { switch (status) { case "active": case "sent": case "finished": case "working": return "badge ok"; case "failed": case "disabled": case "expired": case "not_working": return "badge error"; case "pending": case "scheduled": case "sending": case "no_points": return "badge warn"; default: return "badge"; } }