Merge branch 'feature/ajustCalendar' into fix/patient-page
This commit is contained in:
commit
1af15a16b7
@ -2,39 +2,36 @@
|
|||||||
|
|
||||||
// Imports mantidos
|
// Imports mantidos
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import dynamic from "next/dynamic";
|
|
||||||
import Link from "next/link";
|
|
||||||
|
|
||||||
// --- Imports do EventManager (NOVO) - MANTIDOS ---
|
// --- Imports do EventManager (NOVO) - MANTIDOS ---
|
||||||
import { EventManager, type Event } from "@/components/features/general/event-manager";
|
import { EventManager, type Event } from "@/components/features/general/event-manager";
|
||||||
import { v4 as uuidv4 } from 'uuid'; // Usado para IDs de fallback
|
import { v4 as uuidv4 } from 'uuid'; // Usado para IDs de fallback
|
||||||
|
|
||||||
// Imports mantidos
|
// Imports mantidos
|
||||||
import { Sidebar } from "@/components/layout/sidebar";
|
|
||||||
import { PagesHeader } from "@/components/features/dashboard/header";
|
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { mockWaitingList } from "@/lib/mocks/appointment-mocks";
|
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import {
|
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from "@/components/ui/dropdown-menu";
|
|
||||||
import { ThreeDWallCalendar, CalendarEvent } from "@/components/ui/three-dwall-calendar"; // Calendário 3D mantido
|
import { ThreeDWallCalendar, CalendarEvent } from "@/components/ui/three-dwall-calendar"; // Calendário 3D mantido
|
||||||
|
|
||||||
const ListaEspera = dynamic(
|
|
||||||
() => import("@/components/features/agendamento/ListaEspera"),
|
|
||||||
{ ssr: false }
|
|
||||||
);
|
|
||||||
|
|
||||||
export default function AgendamentoPage() {
|
export default function AgendamentoPage() {
|
||||||
const [appointments, setAppointments] = useState<any[]>([]);
|
const [appointments, setAppointments] = useState<any[]>([]);
|
||||||
const [waitingList, setWaitingList] = useState(mockWaitingList);
|
const [activeTab, setActiveTab] = useState<"calendar" | "3d">("calendar");
|
||||||
const [activeTab, setActiveTab] = useState<"calendar" | "espera" | "3d">("calendar");
|
|
||||||
|
|
||||||
const [threeDEvents, setThreeDEvents] = useState<CalendarEvent[]>([]);
|
const [threeDEvents, setThreeDEvents] = useState<CalendarEvent[]>([]);
|
||||||
|
|
||||||
|
// Padroniza idioma da página para pt-BR (afeta componentes que usam o lang do documento)
|
||||||
|
useEffect(() => {
|
||||||
|
try {
|
||||||
|
// Atributos no <html>
|
||||||
|
document.documentElement.lang = "pt-BR";
|
||||||
|
document.documentElement.setAttribute("xml:lang", "pt-BR");
|
||||||
|
document.documentElement.setAttribute("data-lang", "pt-BR");
|
||||||
|
// Cookie de locale (usado por apps com i18n)
|
||||||
|
const oneYear = 60 * 60 * 24 * 365;
|
||||||
|
document.cookie = `NEXT_LOCALE=pt-BR; Path=/; Max-Age=${oneYear}; SameSite=Lax`;
|
||||||
|
} catch {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
// --- NOVO ESTADO ---
|
// --- NOVO ESTADO ---
|
||||||
// Estado para alimentar o NOVO EventManager com dados da API
|
// Estado para alimentar o NOVO EventManager com dados da API
|
||||||
const [managerEvents, setManagerEvents] = useState<Event[]>([]);
|
const [managerEvents, setManagerEvents] = useState<Event[]>([]);
|
||||||
@ -42,15 +39,8 @@ export default function AgendamentoPage() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.addEventListener("keydown", (event) => {
|
document.addEventListener("keydown", (event) => {
|
||||||
if (event.key === "c") {
|
if (event.key === "c") setActiveTab("calendar");
|
||||||
setActiveTab("calendar");
|
if (event.key === "3") setActiveTab("3d");
|
||||||
}
|
|
||||||
if (event.key === "f") {
|
|
||||||
setActiveTab("espera");
|
|
||||||
}
|
|
||||||
if (event.key === "3") {
|
|
||||||
setActiveTab("3d");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@ -86,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 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();
|
const title = `${patient}: ${obj.appointment_type ?? obj.type ?? ''}`.trim();
|
||||||
|
|
||||||
let color = "gray"; // Cor padrão
|
// Mapeamento de cores padronizado:
|
||||||
if (obj.status === 'confirmed') color = 'green';
|
// azul = solicitado; verde = confirmado; laranja = pendente; vermelho = cancelado; azul como fallback
|
||||||
if (obj.status === 'pending') color = 'orange';
|
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 {
|
return {
|
||||||
id: obj.id || uuidv4(), // Usa ID da API ou gera um
|
id: obj.id || uuidv4(),
|
||||||
title: title,
|
title,
|
||||||
description: `Agendamento para ${patient}. Status: ${obj.status || 'N/A'}.`,
|
description: `Agendamento para ${patient}. Status: ${obj.status || 'N/A'}.`,
|
||||||
startTime: start,
|
startTime: start,
|
||||||
endTime: end,
|
endTime: end,
|
||||||
color: color,
|
color,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
setManagerEvents(newManagerEvents);
|
setManagerEvents(newManagerEvents);
|
||||||
@ -146,10 +141,6 @@ export default function AgendamentoPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleNotifyPatient = (patientId: string) => {
|
|
||||||
console.log(`Notificando paciente ${patientId}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleAddEvent = (event: CalendarEvent) => {
|
const handleAddEvent = (event: CalendarEvent) => {
|
||||||
setThreeDEvents((prev) => [...prev, event]);
|
setThreeDEvents((prev) => [...prev, event]);
|
||||||
};
|
};
|
||||||
@ -172,26 +163,10 @@ export default function AgendamentoPage() {
|
|||||||
Navegue através dos atalhos: Calendário (C), Fila de espera (F) ou 3D (3).
|
Navegue através dos atalhos: Calendário (C), Fila de espera (F) ou 3D (3).
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex space-x-2">
|
<div className="flex space-x-2 items-center">
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger className="bg-primary hover:bg-primary/90 px-5 py-1 text-primary-foreground rounded-sm">
|
|
||||||
Opções »
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent>
|
|
||||||
<Link href={"/agenda"}>
|
|
||||||
<DropdownMenuItem>Agendamento</DropdownMenuItem>
|
|
||||||
</Link>
|
|
||||||
<Link href={"/procedimento"}>
|
|
||||||
<DropdownMenuItem>Procedimento</DropdownMenuItem>
|
|
||||||
</Link>
|
|
||||||
<Link href={"/financeiro"}>
|
|
||||||
<DropdownMenuItem>Financeiro</DropdownMenuItem>
|
|
||||||
</Link>
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
|
|
||||||
<div className="flex flex-row">
|
<div className="flex flex-row">
|
||||||
<Button
|
<Button
|
||||||
|
type="button"
|
||||||
variant={"outline"}
|
variant={"outline"}
|
||||||
className="bg-muted hover:bg-primary! hover:text-white! transition-colors rounded-l-[100px] rounded-r-none"
|
className="bg-muted hover:bg-primary! hover:text-white! transition-colors rounded-l-[100px] rounded-r-none"
|
||||||
onClick={() => setActiveTab("calendar")}
|
onClick={() => setActiveTab("calendar")}
|
||||||
@ -200,20 +175,27 @@ export default function AgendamentoPage() {
|
|||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
type="button"
|
||||||
variant={"outline"}
|
variant={"outline"}
|
||||||
className="bg-muted hover:bg-primary! hover:text-white! transition-colors rounded-none"
|
className="bg-muted hover:bg-primary! hover:text-white! transition-colors rounded-r-[100px] rounded-l-none"
|
||||||
onClick={() => setActiveTab("3d")}
|
onClick={() => setActiveTab("3d")}
|
||||||
>
|
>
|
||||||
3D
|
3D
|
||||||
</Button>
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Button
|
{/* Legenda de status (estilo Google Calendar) */}
|
||||||
variant={"outline"}
|
<div className="rounded-md border bg-card/60 p-2 sm:p-3 -mt-4">
|
||||||
className="bg-muted hover:bg-primary! hover:text-white! transition-colors rounded-r-[100px] rounded-l-none"
|
<div className="flex flex-wrap items-center gap-6 text-sm">
|
||||||
onClick={() => setActiveTab("espera")}
|
<div className="flex items-center gap-2">
|
||||||
>
|
<span aria-hidden className="h-3 w-3 rounded-full bg-blue-500 ring-2 ring-blue-500/30" />
|
||||||
Lista de espera
|
<span className="text-foreground">Solicitado</span>
|
||||||
</Button>
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<span aria-hidden className="h-3 w-3 rounded-full bg-green-500 ring-2 ring-green-500/30" />
|
||||||
|
<span className="text-foreground">Confirmado</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -244,14 +226,7 @@ export default function AgendamentoPage() {
|
|||||||
onRemoveEvent={handleRemoveEvent}
|
onRemoveEvent={handleRemoveEvent}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : null}
|
||||||
// A Lista de Espera foi MANTIDA
|
|
||||||
<ListaEspera
|
|
||||||
patients={waitingList}
|
|
||||||
onNotify={handleNotifyPatient}
|
|
||||||
onAddToWaitlist={() => {}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
1485
susconecta/components/event-manager.tsx
Normal file
1485
susconecta/components/event-manager.tsx
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import React, { useState, useCallback, useMemo } from "react"
|
import React, { useState, useCallback, useMemo, useEffect } from "react"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
import { Card } from "@/components/ui/card"
|
import { Card } from "@/components/ui/card"
|
||||||
import { Input } from "@/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
@ -16,16 +16,8 @@ import {
|
|||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@/components/ui/dialog"
|
} from "@/components/ui/dialog"
|
||||||
import { Badge } from "@/components/ui/badge"
|
import { Badge } from "@/components/ui/badge"
|
||||||
import { ChevronLeft, ChevronRight, Plus, Calendar, Clock, Grid3x3, List, Search, Filter, X } from "lucide-react"
|
import { ChevronLeft, ChevronRight, Plus, Calendar, Clock, Grid3x3, List, Search, X } from "lucide-react"
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
import {
|
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuCheckboxItem,
|
|
||||||
DropdownMenuLabel,
|
|
||||||
DropdownMenuSeparator,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from "@/components/ui/dropdown-menu"
|
|
||||||
|
|
||||||
export interface Event {
|
export interface Event {
|
||||||
id: string
|
id: string
|
||||||
@ -60,6 +52,10 @@ const defaultColors = [
|
|||||||
{ name: "Red", value: "red", bg: "bg-red-500", text: "text-red-700" },
|
{ 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({
|
export function EventManager({
|
||||||
events: initialEvents = [],
|
events: initialEvents = [],
|
||||||
onEventCreate,
|
onEventCreate,
|
||||||
@ -87,13 +83,19 @@ export function EventManager({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const [searchQuery, setSearchQuery] = useState("")
|
const [searchQuery, setSearchQuery] = useState("")
|
||||||
const [selectedColors, setSelectedColors] = useState<string[]>([])
|
|
||||||
const [selectedTags, setSelectedTags] = useState<string[]>([])
|
// Dialog: lista completa de pacientes do dia
|
||||||
const [selectedCategories, setSelectedCategories] = useState<string[]>([])
|
const [dayDialogEvents, setDayDialogEvents] = useState<Event[] | null>(null)
|
||||||
|
const [isDayDialogOpen, setIsDayDialogOpen] = useState(false)
|
||||||
|
const openDayDialog = useCallback((eventsForDay: Event[]) => {
|
||||||
|
// ordena por horário antes de abrir
|
||||||
|
const ordered = [...eventsForDay].sort((a, b) => a.startTime.getTime() - b.startTime.getTime())
|
||||||
|
setDayDialogEvents(ordered)
|
||||||
|
setIsDayDialogOpen(true)
|
||||||
|
}, [])
|
||||||
|
|
||||||
const filteredEvents = useMemo(() => {
|
const filteredEvents = useMemo(() => {
|
||||||
return events.filter((event) => {
|
return events.filter((event) => {
|
||||||
// Search filter
|
|
||||||
if (searchQuery) {
|
if (searchQuery) {
|
||||||
const query = searchQuery.toLowerCase()
|
const query = searchQuery.toLowerCase()
|
||||||
const matchesSearch =
|
const matchesSearch =
|
||||||
@ -101,36 +103,15 @@ export function EventManager({
|
|||||||
event.description?.toLowerCase().includes(query) ||
|
event.description?.toLowerCase().includes(query) ||
|
||||||
event.category?.toLowerCase().includes(query) ||
|
event.category?.toLowerCase().includes(query) ||
|
||||||
event.tags?.some((tag) => tag.toLowerCase().includes(query))
|
event.tags?.some((tag) => tag.toLowerCase().includes(query))
|
||||||
|
|
||||||
if (!matchesSearch) return false
|
if (!matchesSearch) return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Color filter
|
|
||||||
if (selectedColors.length > 0 && !selectedColors.includes(event.color)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tag filter
|
|
||||||
if (selectedTags.length > 0) {
|
|
||||||
const hasMatchingTag = event.tags?.some((tag) => selectedTags.includes(tag))
|
|
||||||
if (!hasMatchingTag) return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Category filter
|
|
||||||
if (selectedCategories.length > 0 && event.category && !selectedCategories.includes(event.category)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
}, [events, searchQuery, selectedColors, selectedTags, selectedCategories])
|
}, [events, searchQuery])
|
||||||
|
|
||||||
const hasActiveFilters = selectedColors.length > 0 || selectedTags.length > 0 || selectedCategories.length > 0
|
const hasActiveFilters = false
|
||||||
|
|
||||||
const clearFilters = () => {
|
const clearFilters = () => {
|
||||||
setSelectedColors([])
|
|
||||||
setSelectedTags([])
|
|
||||||
setSelectedCategories([])
|
|
||||||
setSearchQuery("")
|
setSearchQuery("")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,23 +219,16 @@ export function EventManager({
|
|||||||
[colors],
|
[colors],
|
||||||
)
|
)
|
||||||
|
|
||||||
const toggleTag = (tag: string, isCreating: boolean) => {
|
// Força lang/cookie pt-BR no documento (reforço local)
|
||||||
if (isCreating) {
|
useEffect(() => {
|
||||||
setNewEvent((prev) => ({
|
try {
|
||||||
...prev,
|
document.documentElement.lang = "pt-BR"
|
||||||
tags: prev.tags?.includes(tag) ? prev.tags.filter((t) => t !== tag) : [...(prev.tags || []), tag],
|
document.documentElement.setAttribute("xml:lang", "pt-BR")
|
||||||
}))
|
document.documentElement.setAttribute("data-lang", "pt-BR")
|
||||||
} else {
|
const oneYear = 60 * 60 * 24 * 365
|
||||||
setSelectedEvent((prev) =>
|
document.cookie = `NEXT_LOCALE=pt-BR; Path=/; Max-Age=${oneYear}; SameSite=Lax`
|
||||||
prev
|
} catch {}
|
||||||
? {
|
}, [])
|
||||||
...prev,
|
|
||||||
tags: prev.tags?.includes(tag) ? prev.tags.filter((t) => t !== tag) : [...(prev.tags || []), tag],
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn("flex flex-col gap-4", className)}>
|
<div className={cn("flex flex-col gap-4", className)}>
|
||||||
@ -263,21 +237,24 @@ export function EventManager({
|
|||||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4">
|
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-4">
|
||||||
<h2 className="text-xl font-semibold sm:text-2xl">
|
<h2 className="text-xl font-semibold sm:text-2xl">
|
||||||
{view === "month" &&
|
{view === "month" &&
|
||||||
currentDate.toLocaleDateString("pt-BR", {
|
currentDate.toLocaleDateString(LOCALE, {
|
||||||
month: "long",
|
month: "long",
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
|
timeZone: TIMEZONE,
|
||||||
})}
|
})}
|
||||||
{view === "week" &&
|
{view === "week" &&
|
||||||
`Semana de ${currentDate.toLocaleDateString("pt-BR", {
|
`Semana de ${currentDate.toLocaleDateString(LOCALE, {
|
||||||
month: "short",
|
month: "short",
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
|
timeZone: TIMEZONE,
|
||||||
})}`}
|
})}`}
|
||||||
{view === "day" &&
|
{view === "day" &&
|
||||||
currentDate.toLocaleDateString("pt-BR", {
|
currentDate.toLocaleDateString(LOCALE, {
|
||||||
weekday: "long",
|
weekday: "long",
|
||||||
month: "long",
|
month: "long",
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
|
timeZone: TIMEZONE,
|
||||||
})}
|
})}
|
||||||
{view === "list" && "Todos os eventos"}
|
{view === "list" && "Todos os eventos"}
|
||||||
</h2>
|
</h2>
|
||||||
@ -285,9 +262,6 @@ export function EventManager({
|
|||||||
<Button variant="outline" size="icon" onClick={() => navigateDate("prev")} className="h-8 w-8">
|
<Button variant="outline" size="icon" onClick={() => navigateDate("prev")} className="h-8 w-8">
|
||||||
<ChevronLeft className="h-4 w-4" />
|
<ChevronLeft className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="outline" size="sm" onClick={() => setCurrentDate(new Date())}>
|
|
||||||
Hoje
|
|
||||||
</Button>
|
|
||||||
<Button variant="outline" size="icon" onClick={() => navigateDate("next")} className="h-8 w-8">
|
<Button variant="outline" size="icon" onClick={() => navigateDate("next")} className="h-8 w-8">
|
||||||
<ChevronRight className="h-4 w-4" />
|
<ChevronRight className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
@ -385,290 +359,46 @@ export function EventManager({
|
|||||||
|
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<div className="relative flex-1">
|
<div className="relative flex-1">
|
||||||
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
<div className="flex items-center">
|
||||||
<Input
|
{/* Lupa minimalista à esquerda (somente ícone) */}
|
||||||
placeholder="Buscar eventos..."
|
<button
|
||||||
value={searchQuery}
|
type="button"
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
aria-label="Buscar"
|
||||||
className="pl-9"
|
className="flex items-center justify-center h-10 w-10 p-0 text-muted-foreground bg-transparent border-0"
|
||||||
/>
|
onClick={() => {
|
||||||
{searchQuery && (
|
const el = document.querySelector<HTMLInputElement>('input[placeholder="Buscar eventos..."]')
|
||||||
<Button
|
el?.focus()
|
||||||
variant="ghost"
|
}}
|
||||||
size="icon"
|
|
||||||
className="absolute right-1 top-1/2 h-7 w-7 -translate-y-1/2"
|
|
||||||
onClick={() => setSearchQuery("")}
|
|
||||||
>
|
>
|
||||||
<X className="h-4 w-4" />
|
<Search className="h-5 w-5" />
|
||||||
</Button>
|
</button>
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Mobile: Horizontal scroll with full-length buttons */}
|
{/* Input central com altura consistente e foco visível */}
|
||||||
<div className="sm:hidden -mx-4 px-4">
|
<Input
|
||||||
<div className="flex gap-2 overflow-x-auto pb-2 scrollbar-hide">
|
placeholder="Buscar eventos..."
|
||||||
{/* Color Filter */}
|
value={searchQuery}
|
||||||
<DropdownMenu>
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
<DropdownMenuTrigger asChild>
|
className={cn(
|
||||||
<Button variant="outline" size="sm" className="gap-2 whitespace-nowrap flex-shrink-0 bg-transparent">
|
"flex-1 h-10 px-3 border border-border focus:ring-2 focus:ring-primary/20 outline-none",
|
||||||
<Filter className="h-4 w-4" />
|
searchQuery ? "rounded-l-md rounded-r-none" : "rounded-md"
|
||||||
Cores
|
)}
|
||||||
{selectedColors.length > 0 && (
|
/>
|
||||||
<Badge variant="secondary" className="ml-1 h-5 px-1.5">
|
|
||||||
{selectedColors.length}
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="start" className="w-48">
|
|
||||||
<DropdownMenuLabel>Filtrar por Cor</DropdownMenuLabel>
|
|
||||||
<DropdownMenuSeparator />
|
|
||||||
{colors.map((color) => (
|
|
||||||
<DropdownMenuCheckboxItem
|
|
||||||
key={color.value}
|
|
||||||
checked={selectedColors.includes(color.value)}
|
|
||||||
onCheckedChange={(checked) => {
|
|
||||||
setSelectedColors((prev) =>
|
|
||||||
checked ? [...prev, color.value] : prev.filter((c) => c !== color.value),
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<div className={cn("h-3 w-3 rounded", color.bg)} />
|
|
||||||
{color.name}
|
|
||||||
</div>
|
|
||||||
</DropdownMenuCheckboxItem>
|
|
||||||
))}
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
|
|
||||||
{/* Tag Filter */}
|
{/* Botão limpar discreto à direita (aparece somente com query) */}
|
||||||
<DropdownMenu>
|
{searchQuery ? (
|
||||||
<DropdownMenuTrigger asChild>
|
<button
|
||||||
<Button variant="outline" size="sm" className="gap-2 whitespace-nowrap flex-shrink-0 bg-transparent">
|
type="button"
|
||||||
<Filter className="h-4 w-4" />
|
aria-label="Limpar busca"
|
||||||
Tags
|
className="flex items-center justify-center h-10 w-10 p-0 text-muted-foreground bg-transparent border-0"
|
||||||
{selectedTags.length > 0 && (
|
onClick={() => setSearchQuery("")}
|
||||||
<Badge variant="secondary" className="ml-1 h-5 px-1.5">
|
|
||||||
{selectedTags.length}
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="start" className="w-48">
|
|
||||||
<DropdownMenuLabel>Filtrar por Tag</DropdownMenuLabel>
|
|
||||||
<DropdownMenuSeparator />
|
|
||||||
{availableTags.map((tag) => (
|
|
||||||
<DropdownMenuCheckboxItem
|
|
||||||
key={tag}
|
|
||||||
checked={selectedTags.includes(tag)}
|
|
||||||
onCheckedChange={(checked) => {
|
|
||||||
setSelectedTags((prev) => (checked ? [...prev, tag] : prev.filter((t) => t !== tag)))
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{tag}
|
|
||||||
</DropdownMenuCheckboxItem>
|
|
||||||
))}
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
|
|
||||||
{/* Category Filter */}
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger asChild>
|
|
||||||
<Button variant="outline" size="sm" className="gap-2 whitespace-nowrap flex-shrink-0 bg-transparent">
|
|
||||||
<Filter className="h-4 w-4" />
|
|
||||||
Categorias
|
|
||||||
{selectedCategories.length > 0 && (
|
|
||||||
<Badge variant="secondary" className="ml-1 h-5 px-1.5">
|
|
||||||
{selectedCategories.length}
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="start" className="w-48">
|
|
||||||
<DropdownMenuLabel>Filtrar por Categoria</DropdownMenuLabel>
|
|
||||||
<DropdownMenuSeparator />
|
|
||||||
{categories.map((category) => (
|
|
||||||
<DropdownMenuCheckboxItem
|
|
||||||
key={category}
|
|
||||||
checked={selectedCategories.includes(category)}
|
|
||||||
onCheckedChange={(checked) => {
|
|
||||||
setSelectedCategories((prev) =>
|
|
||||||
checked ? [...prev, category] : prev.filter((c) => c !== category),
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{category}
|
|
||||||
</DropdownMenuCheckboxItem>
|
|
||||||
))}
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
|
|
||||||
{hasActiveFilters && (
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
onClick={clearFilters}
|
|
||||||
className="gap-2 whitespace-nowrap flex-shrink-0"
|
|
||||||
>
|
>
|
||||||
<X className="h-4 w-4" />
|
<X className="h-5 w-5" />
|
||||||
Limpar Filtros
|
</button>
|
||||||
</Button>
|
) : null}
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Desktop: Original layout */}
|
|
||||||
<div className="hidden sm:flex items-center gap-2">
|
|
||||||
{/* Color Filter */}
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger asChild>
|
|
||||||
<Button variant="outline" size="sm" className="gap-2 bg-transparent">
|
|
||||||
<Filter className="h-4 w-4" />
|
|
||||||
Cores
|
|
||||||
{selectedColors.length > 0 && (
|
|
||||||
<Badge variant="secondary" className="ml-1 h-5 px-1">
|
|
||||||
{selectedColors.length}
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="end" className="w-48">
|
|
||||||
<DropdownMenuLabel>Filtrar por Cor</DropdownMenuLabel>
|
|
||||||
<DropdownMenuSeparator />
|
|
||||||
{colors.map((color) => (
|
|
||||||
<DropdownMenuCheckboxItem
|
|
||||||
key={color.value}
|
|
||||||
checked={selectedColors.includes(color.value)}
|
|
||||||
onCheckedChange={(checked) => {
|
|
||||||
setSelectedColors((prev) =>
|
|
||||||
checked ? [...prev, color.value] : prev.filter((c) => c !== color.value),
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<div className={cn("h-3 w-3 rounded", color.bg)} />
|
|
||||||
{color.name}
|
|
||||||
</div>
|
|
||||||
</DropdownMenuCheckboxItem>
|
|
||||||
))}
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
|
|
||||||
{/* Tag Filter */}
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger asChild>
|
|
||||||
<Button variant="outline" size="sm" className="gap-2 bg-transparent">
|
|
||||||
<Filter className="h-4 w-4" />
|
|
||||||
Tags
|
|
||||||
{selectedTags.length > 0 && (
|
|
||||||
<Badge variant="secondary" className="ml-1 h-5 px-1">
|
|
||||||
{selectedTags.length}
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="end" className="w-48">
|
|
||||||
<DropdownMenuLabel>Filtrar por Tag</DropdownMenuLabel>
|
|
||||||
<DropdownMenuSeparator />
|
|
||||||
{availableTags.map((tag) => (
|
|
||||||
<DropdownMenuCheckboxItem
|
|
||||||
key={tag}
|
|
||||||
checked={selectedTags.includes(tag)}
|
|
||||||
onCheckedChange={(checked) => {
|
|
||||||
setSelectedTags((prev) => (checked ? [...prev, tag] : prev.filter((t) => t !== tag)))
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{tag}
|
|
||||||
</DropdownMenuCheckboxItem>
|
|
||||||
))}
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
|
|
||||||
{/* Category Filter */}
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger asChild>
|
|
||||||
<Button variant="outline" size="sm" className="gap-2 bg-transparent">
|
|
||||||
<Filter className="h-4 w-4" />
|
|
||||||
Categorias
|
|
||||||
{selectedCategories.length > 0 && (
|
|
||||||
<Badge variant="secondary" className="ml-1 h-5 px-1">
|
|
||||||
{selectedCategories.length}
|
|
||||||
</Badge>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="end" className="w-48">
|
|
||||||
<DropdownMenuLabel>Filtrar por Categoria</DropdownMenuLabel>
|
|
||||||
<DropdownMenuSeparator />
|
|
||||||
{categories.map((category) => (
|
|
||||||
<DropdownMenuCheckboxItem
|
|
||||||
key={category}
|
|
||||||
checked={selectedCategories.includes(category)}
|
|
||||||
onCheckedChange={(checked) => {
|
|
||||||
setSelectedCategories((prev) =>
|
|
||||||
checked ? [...prev, category] : prev.filter((c) => c !== category),
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{category}
|
|
||||||
</DropdownMenuCheckboxItem>
|
|
||||||
))}
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
|
|
||||||
{hasActiveFilters && (
|
|
||||||
<Button variant="ghost" size="sm" onClick={clearFilters} className="gap-2">
|
|
||||||
<X className="h-4 w-4" />
|
|
||||||
Limpar
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{hasActiveFilters && (
|
|
||||||
<div className="flex flex-wrap items-center gap-2">
|
|
||||||
<span className="text-sm text-muted-foreground">Filtros ativos:</span>
|
|
||||||
{selectedColors.map((colorValue) => {
|
|
||||||
const color = getColorClasses(colorValue)
|
|
||||||
return (
|
|
||||||
<Badge key={colorValue} variant="secondary" className="gap-1">
|
|
||||||
<div className={cn("h-2 w-2 rounded-full", color.bg)} />
|
|
||||||
{color.name}
|
|
||||||
<button
|
|
||||||
onClick={() => setSelectedColors((prev) => prev.filter((c) => c !== colorValue))}
|
|
||||||
className="ml-1 hover:text-foreground"
|
|
||||||
>
|
|
||||||
<X className="h-3 w-3" />
|
|
||||||
</button>
|
|
||||||
</Badge>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
{selectedTags.map((tag) => (
|
|
||||||
<Badge key={tag} variant="secondary" className="gap-1">
|
|
||||||
{tag}
|
|
||||||
<button
|
|
||||||
onClick={() => setSelectedTags((prev) => prev.filter((t) => t !== tag))}
|
|
||||||
className="ml-1 hover:text-foreground"
|
|
||||||
>
|
|
||||||
<X className="h-3 w-3" />
|
|
||||||
</button>
|
|
||||||
</Badge>
|
|
||||||
))}
|
|
||||||
{selectedCategories.map((category) => (
|
|
||||||
<Badge key={category} variant="secondary" className="gap-1">
|
|
||||||
{category}
|
|
||||||
<button
|
|
||||||
onClick={() => setSelectedCategories((prev) => prev.filter((c) => c !== category))}
|
|
||||||
className="ml-1 hover:text-foreground"
|
|
||||||
>
|
|
||||||
<X className="h-3 w-3" />
|
|
||||||
</button>
|
|
||||||
</Badge>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Calendar Views - Pass filteredEvents instead of events */}
|
{/* Calendar Views - Pass filteredEvents instead of events */}
|
||||||
{view === "month" && (
|
{view === "month" && (
|
||||||
<MonthView
|
<MonthView
|
||||||
@ -682,9 +412,66 @@ export function EventManager({
|
|||||||
onDragEnd={() => handleDragEnd()}
|
onDragEnd={() => handleDragEnd()}
|
||||||
onDrop={handleDrop}
|
onDrop={handleDrop}
|
||||||
getColorClasses={getColorClasses}
|
getColorClasses={getColorClasses}
|
||||||
|
openDayDialog={openDayDialog}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Dialog com todos os pacientes do dia */}
|
||||||
|
<Dialog open={isDayDialogOpen} onOpenChange={setIsDayDialogOpen}>
|
||||||
|
<DialogContent className="max-w-lg max-h-[80vh] overflow-y-auto">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>Pacientes do dia</DialogTitle>
|
||||||
|
<DialogDescription>Todos os agendamentos do dia selecionado.</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<div className="space-y-3 py-2">
|
||||||
|
{dayDialogEvents?.map((ev) => (
|
||||||
|
<div
|
||||||
|
key={ev.id}
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedEvent(ev)
|
||||||
|
setIsDialogOpen(true)
|
||||||
|
setIsDayDialogOpen(false)
|
||||||
|
}}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter" || e.key === " ") {
|
||||||
|
setSelectedEvent(ev)
|
||||||
|
setIsDialogOpen(true)
|
||||||
|
setIsDayDialogOpen(false)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="flex items-start gap-3 p-2 border-b last:border-b-0 rounded-md cursor-pointer hover:bg-accent/40 focus:outline-none focus:ring-2 focus:ring-primary/30"
|
||||||
|
>
|
||||||
|
<div className={cn("mt-1 h-3 w-3 rounded-full", getColorClasses(ev.color).bg)} />
|
||||||
|
<div className="flex-1 min-w-0">
|
||||||
|
<div className="flex items-center justify-between gap-2">
|
||||||
|
<div className="font-semibold truncate">{ev.title}</div>
|
||||||
|
<div className="text-xs text-muted-foreground">
|
||||||
|
{ev.startTime.toLocaleTimeString(LOCALE,{hour:"2-digit",minute:"2-digit",hour12:false,timeZone:TIMEZONE})}
|
||||||
|
{" - "}
|
||||||
|
{ev.endTime.toLocaleTimeString(LOCALE,{hour:"2-digit",minute:"2-digit",hour12:false,timeZone:TIMEZONE})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{ev.description && (
|
||||||
|
<div className="text-xs text-muted-foreground line-clamp-2">{ev.description}</div>
|
||||||
|
)}
|
||||||
|
<div className="mt-1 flex flex-wrap gap-1">
|
||||||
|
{ev.category && <Badge variant="secondary" className="text-[11px] h-5">{ev.category}</Badge>}
|
||||||
|
{ev.tags?.map((t) => (
|
||||||
|
<Badge key={t} variant="outline" className="text-[11px] h-5">{t}</Badge>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
{!dayDialogEvents?.length && (
|
||||||
|
<div className="py-6 text-center text-sm text-muted-foreground">Nenhum evento</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
{view === "week" && (
|
{view === "week" && (
|
||||||
<WeekView
|
<WeekView
|
||||||
currentDate={currentDate}
|
currentDate={currentDate}
|
||||||
@ -728,7 +515,7 @@ export function EventManager({
|
|||||||
|
|
||||||
{/* Event Dialog */}
|
{/* Event Dialog */}
|
||||||
<Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
|
<Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
|
||||||
<DialogContent className="max-w-md max-h-[90vh] overflow-y-auto">
|
<DialogContent className="max-w-md max-h[90vh] overflow-y-auto">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>{isCreating ? "Criar Evento" : "Detalhes do Evento"}</DialogTitle>
|
<DialogTitle>{isCreating ? "Criar Evento" : "Detalhes do Evento"}</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
@ -827,75 +614,9 @@ export function EventManager({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-2 gap-4">
|
{/* Campos de Categoria/Cor removidos */}
|
||||||
<div className="space-y-2">
|
|
||||||
<Label htmlFor="category">Categoria</Label>
|
|
||||||
<Select
|
|
||||||
value={isCreating ? newEvent.category : selectedEvent?.category}
|
|
||||||
onValueChange={(value) =>
|
|
||||||
isCreating
|
|
||||||
? setNewEvent((prev) => ({ ...prev, category: value }))
|
|
||||||
: setSelectedEvent((prev) => (prev ? { ...prev, category: value } : null))
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<SelectTrigger id="category">
|
|
||||||
<SelectValue placeholder="Selecione a categoria" />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
{categories.map((cat) => (
|
|
||||||
<SelectItem key={cat} value={cat}>
|
|
||||||
{cat}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="space-y-2">
|
{/* Campo de Tags removido */}
|
||||||
<Label htmlFor="color">Cor</Label>
|
|
||||||
<Select
|
|
||||||
value={isCreating ? newEvent.color : selectedEvent?.color}
|
|
||||||
onValueChange={(value) =>
|
|
||||||
isCreating
|
|
||||||
? setNewEvent((prev) => ({ ...prev, color: value }))
|
|
||||||
: setSelectedEvent((prev) => (prev ? { ...prev, color: value } : null))
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<SelectTrigger id="color">
|
|
||||||
<SelectValue placeholder="Selecione a cor" />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
{colors.map((color) => (
|
|
||||||
<SelectItem key={color.value} value={color.value}>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<div className={cn("h-4 w-4 rounded", color.bg)} />
|
|
||||||
{color.name}
|
|
||||||
</div>
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Label>Tags</Label>
|
|
||||||
<div className="flex flex-wrap gap-2">
|
|
||||||
{availableTags.map((tag) => {
|
|
||||||
const isSelected = isCreating ? newEvent.tags?.includes(tag) : selectedEvent?.tags?.includes(tag)
|
|
||||||
return (
|
|
||||||
<Badge
|
|
||||||
key={tag}
|
|
||||||
variant={isSelected ? "default" : "outline"}
|
|
||||||
className="cursor-pointer transition-all hover:scale-105"
|
|
||||||
onClick={() => toggleTag(tag, isCreating)}
|
|
||||||
>
|
|
||||||
{tag}
|
|
||||||
</Badge>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
@ -944,9 +665,11 @@ function EventCard({
|
|||||||
const colorClasses = getColorClasses(event.color)
|
const colorClasses = getColorClasses(event.color)
|
||||||
|
|
||||||
const formatTime = (date: Date) => {
|
const formatTime = (date: Date) => {
|
||||||
return date.toLocaleTimeString("en-US", {
|
return date.toLocaleTimeString(LOCALE, {
|
||||||
hour: "2-digit",
|
hour: "2-digit",
|
||||||
minute: "2-digit",
|
minute: "2-digit",
|
||||||
|
hour12: false,
|
||||||
|
timeZone: TIMEZONE,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1124,6 +847,7 @@ function MonthView({
|
|||||||
onDragEnd,
|
onDragEnd,
|
||||||
onDrop,
|
onDrop,
|
||||||
getColorClasses,
|
getColorClasses,
|
||||||
|
openDayDialog,
|
||||||
}: {
|
}: {
|
||||||
currentDate: Date
|
currentDate: Date
|
||||||
events: Event[]
|
events: Event[]
|
||||||
@ -1132,6 +856,7 @@ function MonthView({
|
|||||||
onDragEnd: () => void
|
onDragEnd: () => void
|
||||||
onDrop: (date: Date) => void
|
onDrop: (date: Date) => void
|
||||||
getColorClasses: (color: string) => { bg: string; text: string }
|
getColorClasses: (color: string) => { bg: string; text: string }
|
||||||
|
openDayDialog: (eventsForDay: Event[]) => void
|
||||||
}) {
|
}) {
|
||||||
const firstDayOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1)
|
const firstDayOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1)
|
||||||
const lastDayOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0)
|
const lastDayOfMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0)
|
||||||
@ -1170,6 +895,15 @@ function MonthView({
|
|||||||
<div className="grid grid-cols-7">
|
<div className="grid grid-cols-7">
|
||||||
{days.map((day, index) => {
|
{days.map((day, index) => {
|
||||||
const dayEvents = getEventsForDay(day)
|
const dayEvents = getEventsForDay(day)
|
||||||
|
// dedup por título para evitar repetidos
|
||||||
|
const uniqueMap = new Map<string, Event>()
|
||||||
|
dayEvents.forEach((ev) => {
|
||||||
|
const k = (ev.title || "").trim().toLowerCase()
|
||||||
|
if (!uniqueMap.has(k)) uniqueMap.set(k, ev)
|
||||||
|
})
|
||||||
|
const uniqueEvents = Array.from(uniqueMap.values())
|
||||||
|
const eventsToShow = uniqueEvents.slice(0, 3)
|
||||||
|
const moreCount = Math.max(0, uniqueEvents.length - 3)
|
||||||
const isCurrentMonth = day.getMonth() === currentDate.getMonth()
|
const isCurrentMonth = day.getMonth() === currentDate.getMonth()
|
||||||
const isToday = day.toDateString() === new Date().toDateString()
|
const isToday = day.toDateString() === new Date().toDateString()
|
||||||
|
|
||||||
@ -1184,16 +918,11 @@ function MonthView({
|
|||||||
onDragOver={(e) => e.preventDefault()}
|
onDragOver={(e) => e.preventDefault()}
|
||||||
onDrop={() => onDrop(day)}
|
onDrop={() => onDrop(day)}
|
||||||
>
|
>
|
||||||
<div
|
{/* Número do dia padronizado (sem destaque azul no 'hoje') */}
|
||||||
className={cn(
|
<div className="mb-1 text-xs sm:text-sm">{day.getDate()}</div>
|
||||||
"mb-1 flex h-5 w-5 items-center justify-center rounded-full text-xs sm:h-6 sm:w-6 sm:text-sm",
|
|
||||||
isToday && "bg-primary text-primary-foreground font-semibold",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
{day.getDate()}
|
|
||||||
</div>
|
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
{dayEvents.slice(0, 3).map((event) => (
|
{eventsToShow.map((event) => (
|
||||||
<EventCard
|
<EventCard
|
||||||
key={event.id}
|
key={event.id}
|
||||||
event={event}
|
event={event}
|
||||||
@ -1204,8 +933,16 @@ function MonthView({
|
|||||||
variant="compact"
|
variant="compact"
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
{dayEvents.length > 3 && (
|
{moreCount > 0 && (
|
||||||
<div className="text-[10px] text-muted-foreground sm:text-xs">+{dayEvents.length - 3} mais</div>
|
<div className="text-[10px] sm:text-xs">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => openDayDialog(uniqueEvents)}
|
||||||
|
className="text-primary underline"
|
||||||
|
>
|
||||||
|
+{moreCount} mais
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -1267,17 +1004,17 @@ function WeekView({
|
|||||||
key={day.toISOString()}
|
key={day.toISOString()}
|
||||||
className="border-r p-2 text-center text-xs font-medium last:border-r-0 sm:text-sm"
|
className="border-r p-2 text-center text-xs font-medium last:border-r-0 sm:text-sm"
|
||||||
>
|
>
|
||||||
<div className="hidden sm:block">{day.toLocaleDateString("pt-BR", { weekday: "short" })}</div>
|
<div className="hidden sm:block">{day.toLocaleDateString(LOCALE, { weekday: "short", timeZone: TIMEZONE })}</div>
|
||||||
<div className="sm:hidden">{day.toLocaleDateString("pt-BR", { weekday: "narrow" })}</div>
|
<div className="sm:hidden">{day.toLocaleDateString(LOCALE, { weekday: "narrow", timeZone: TIMEZONE })}</div>
|
||||||
<div className="text-[10px] text-muted-foreground sm:text-xs">
|
<div className="text-[10px] text-muted-foreground sm:text-xs">
|
||||||
{day.toLocaleDateString("pt-BR", { month: "short", day: "numeric" })}
|
{day.toLocaleDateString(LOCALE, { month: "short", day: "numeric", timeZone: TIMEZONE })}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-8">
|
<div className="grid grid-cols-8">
|
||||||
{hours.map((hour) => (
|
{hours.map((hour) => (
|
||||||
<>
|
<React.Fragment key={`hour-${hour}`}>
|
||||||
<div
|
<div
|
||||||
key={`time-${hour}`}
|
key={`time-${hour}`}
|
||||||
className="border-b border-r p-1 text-[10px] text-muted-foreground sm:p-2 sm:text-xs"
|
className="border-b border-r p-1 text-[10px] text-muted-foreground sm:p-2 sm:text-xs"
|
||||||
@ -1309,7 +1046,7 @@ function WeekView({
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</>
|
</React.Fragment>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
@ -1401,15 +1138,14 @@ function ListView({
|
|||||||
|
|
||||||
const groupedEvents = sortedEvents.reduce(
|
const groupedEvents = sortedEvents.reduce(
|
||||||
(acc, event) => {
|
(acc, event) => {
|
||||||
const dateKey = event.startTime.toLocaleDateString("pt-BR", {
|
const dateKey = event.startTime.toLocaleDateString(LOCALE, {
|
||||||
weekday: "long",
|
weekday: "long",
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
month: "long",
|
month: "long",
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
|
timeZone: TIMEZONE,
|
||||||
})
|
})
|
||||||
if (!acc[dateKey]) {
|
if (!acc[dateKey]) acc[dateKey] = []
|
||||||
acc[dateKey] = []
|
|
||||||
}
|
|
||||||
acc[dateKey].push(event)
|
acc[dateKey].push(event)
|
||||||
return acc
|
return acc
|
||||||
},
|
},
|
||||||
@ -1426,11 +1162,7 @@ function ListView({
|
|||||||
{dateEvents.map((event) => {
|
{dateEvents.map((event) => {
|
||||||
const colorClasses = getColorClasses(event.color)
|
const colorClasses = getColorClasses(event.color)
|
||||||
return (
|
return (
|
||||||
<div
|
<div key={event.id} onClick={() => 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">
|
||||||
key={event.id}
|
|
||||||
onClick={() => 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"
|
|
||||||
>
|
|
||||||
<div className="flex items-start gap-2 sm:gap-3">
|
<div className="flex items-start gap-2 sm:gap-3">
|
||||||
<div className={cn("mt-1 h-2.5 w-2.5 rounded-full sm:h-3 sm:w-3", colorClasses.bg)} />
|
<div className={cn("mt-1 h-2.5 w-2.5 rounded-full sm:h-3 sm:w-3", colorClasses.bg)} />
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
@ -1456,7 +1188,9 @@ function ListView({
|
|||||||
<div className="mt-2 flex flex-wrap items-center gap-2 text-[10px] text-muted-foreground sm:gap-4 sm:text-xs">
|
<div className="mt-2 flex flex-wrap items-center gap-2 text-[10px] text-muted-foreground sm:gap-4 sm:text-xs">
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<Clock className="h-3 w-3" />
|
<Clock className="h-3 w-3" />
|
||||||
{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 })}
|
||||||
</div>
|
</div>
|
||||||
{event.tags && event.tags.length > 0 && (
|
{event.tags && event.tags.length > 0 && (
|
||||||
<div className="flex flex-wrap gap-1">
|
<div className="flex flex-wrap gap-1">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user