diff --git a/susconecta/app/(main-routes)/calendar/page.tsx b/susconecta/app/(main-routes)/calendar/page.tsx index 4e427a2..a6d3b5c 100644 --- a/susconecta/app/(main-routes)/calendar/page.tsx +++ b/susconecta/app/(main-routes)/calendar/page.tsx @@ -76,18 +76,23 @@ export default function AgendamentoPage() { const patient = (patientsById[String(obj.patient_id)]?.full_name) || obj.patient_name || obj.patient_full_name || obj.patient || 'Paciente'; const title = `${patient}: ${obj.appointment_type ?? obj.type ?? ''}`.trim(); - - let color = "gray"; // Cor padrão - if (obj.status === 'confirmed') color = 'green'; - if (obj.status === 'pending') color = 'orange'; + + // Mapeamento de cores padronizado: + // azul = solicitado; verde = confirmado; laranja = pendente; vermelho = cancelado; azul como fallback + const status = String(obj.status || "").toLowerCase(); + let color: Event["color"] = "blue"; + if (status === "confirmed" || status === "confirmado") color = "green"; + else if (status === "pending" || status === "pendente") color = "orange"; + else if (status === "canceled" || status === "cancelado" || status === "cancelled") color = "red"; + else if (status === "requested" || status === "solicitado") color = "blue"; return { - id: obj.id || uuidv4(), // Usa ID da API ou gera um - title: title, - description: `Agendamento para ${patient}. Status: ${obj.status || 'N/A'}.`, + id: obj.id || uuidv4(), + title, + description: `Agendamento para ${patient}. Status: ${obj.status || 'N/A'}.`, startTime: start, endTime: end, - color: color, + color, }; }); setManagerEvents(newManagerEvents); @@ -144,17 +149,6 @@ export default function AgendamentoPage() { setThreeDEvents((prev) => prev.filter((e) => e.id !== id)); }; - // Tenta clicar no botão de filtro correspondente (procura por texto do botão) - const clickFilter = (label: string) => { - try { - const buttons = Array.from(document.querySelectorAll("button")); - const match = buttons.find((b) => b.textContent?.trim().toLowerCase().includes(label.toLowerCase())); - if (match) match.click(); - } catch { - // ignore - } - }; - return (
@@ -170,13 +164,6 @@ export default function AgendamentoPage() {

- {/* Botões rápidos de filtros (acionam os triggers se existirem no DOM) */} -
- - - -
-
-
+ + + {/* Legenda de status (estilo Google Calendar) */} +
+
+
+ + Solicitado +
+
+ + Confirmado +
+
+
{/* --- AQUI ESTÁ A SUBSTITUIÇÃO --- */} {activeTab === "calendar" ? ( @@ -226,8 +227,8 @@ export default function AgendamentoPage() { /> ) : null} - - - - ); - } \ No newline at end of file + + + + ); +} \ No newline at end of file diff --git a/susconecta/components/features/general/event-manager.tsx b/susconecta/components/features/general/event-manager.tsx index a009277..697b2e6 100644 --- a/susconecta/components/features/general/event-manager.tsx +++ b/susconecta/components/features/general/event-manager.tsx @@ -1,6 +1,6 @@ "use client" -import React, { useState, useCallback, useMemo } from "react" +import React, { useState, useCallback, useMemo, useEffect } from "react" import { Button } from "@/components/ui/button" import { Card } from "@/components/ui/card" import { Input } from "@/components/ui/input" @@ -52,6 +52,10 @@ const defaultColors = [ { name: "Red", value: "red", bg: "bg-red-500", text: "text-red-700" }, ] +// Locale/timezone padrão BR +const LOCALE = "pt-BR" +const TIMEZONE = "America/Sao_Paulo" + export function EventManager({ events: initialEvents = [], onEventCreate, @@ -215,6 +219,17 @@ export function EventManager({ [colors], ) + // Força lang/cookie pt-BR no documento (reforço local) + useEffect(() => { + try { + document.documentElement.lang = "pt-BR" + document.documentElement.setAttribute("xml:lang", "pt-BR") + document.documentElement.setAttribute("data-lang", "pt-BR") + const oneYear = 60 * 60 * 24 * 365 + document.cookie = `NEXT_LOCALE=pt-BR; Path=/; Max-Age=${oneYear}; SameSite=Lax` + } catch {} + }, []) + return (
{/* Header */} @@ -222,21 +237,24 @@ export function EventManager({

{view === "month" && - currentDate.toLocaleDateString("pt-BR", { + currentDate.toLocaleDateString(LOCALE, { month: "long", year: "numeric", + timeZone: TIMEZONE, })} {view === "week" && - `Semana de ${currentDate.toLocaleDateString("pt-BR", { + `Semana de ${currentDate.toLocaleDateString(LOCALE, { month: "short", day: "numeric", + timeZone: TIMEZONE, })}`} {view === "day" && - currentDate.toLocaleDateString("pt-BR", { + currentDate.toLocaleDateString(LOCALE, { weekday: "long", month: "long", day: "numeric", year: "numeric", + timeZone: TIMEZONE, })} {view === "list" && "Todos os eventos"}

@@ -430,9 +448,9 @@ export function EventManager({
{ev.title}
- {ev.startTime.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})} + {ev.startTime.toLocaleTimeString(LOCALE,{hour:"2-digit",minute:"2-digit",hour12:false,timeZone:TIMEZONE})} {" - "} - {ev.endTime.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})} + {ev.endTime.toLocaleTimeString(LOCALE,{hour:"2-digit",minute:"2-digit",hour12:false,timeZone:TIMEZONE})}
{ev.description && ( @@ -647,9 +665,11 @@ function EventCard({ const colorClasses = getColorClasses(event.color) const formatTime = (date: Date) => { - return date.toLocaleTimeString("en-US", { + return date.toLocaleTimeString(LOCALE, { hour: "2-digit", minute: "2-digit", + hour12: false, + timeZone: TIMEZONE, }) } @@ -984,10 +1004,10 @@ function WeekView({ key={day.toISOString()} className="border-r p-2 text-center text-xs font-medium last:border-r-0 sm:text-sm" > -
{day.toLocaleDateString("pt-BR", { weekday: "short" })}
-
{day.toLocaleDateString("pt-BR", { weekday: "narrow" })}
+
{day.toLocaleDateString(LOCALE, { weekday: "short", timeZone: TIMEZONE })}
+
{day.toLocaleDateString(LOCALE, { weekday: "narrow", timeZone: TIMEZONE })}
- {day.toLocaleDateString("pt-BR", { month: "short", day: "numeric" })} + {day.toLocaleDateString(LOCALE, { month: "short", day: "numeric", timeZone: TIMEZONE })}
))} @@ -1118,15 +1138,14 @@ function ListView({ const groupedEvents = sortedEvents.reduce( (acc, event) => { - const dateKey = event.startTime.toLocaleDateString("pt-BR", { + const dateKey = event.startTime.toLocaleDateString(LOCALE, { weekday: "long", year: "numeric", month: "long", day: "numeric", + timeZone: TIMEZONE, }) - if (!acc[dateKey]) { - acc[dateKey] = [] - } + if (!acc[dateKey]) acc[dateKey] = [] acc[dateKey].push(event) return acc }, @@ -1143,11 +1162,7 @@ function ListView({ {dateEvents.map((event) => { const colorClasses = getColorClasses(event.color) return ( -
onEventClick(event)} - className="group cursor-pointer rounded-lg border bg-card p-3 transition-all hover:shadow-md hover:scale-[1.01] animate-in fade-in slide-in-from-bottom-2 duration-300 sm:p-4" - > +
onEventClick(event)} className="group cursor-pointer rounded-lg border bg-card p-3 transition-all hover:shadow-md hover:scale-[1.01] animate-in fade-in slide-in-from-bottom-2 duration-300 sm:p-4">
@@ -1173,7 +1188,9 @@ function ListView({
- {event.startTime.toLocaleTimeString("pt-BR", { hour: "2-digit", minute: "2-digit" })} - {event.endTime.toLocaleTimeString("pt-BR", { hour: "2-digit", minute: "2-digit" })} + {event.startTime.toLocaleTimeString(LOCALE, { hour: "2-digit", minute: "2-digit", hour12: false, timeZone: TIMEZONE })} + {" - "} + {event.endTime.toLocaleTimeString(LOCALE, { hour: "2-digit", minute: "2-digit", hour12: false, timeZone: TIMEZONE })}
{event.tags && event.tags.length > 0 && (