import { EventCard } from "./EventCard"; import type { CalendarEvent } from "../../types"; interface CalendarViewProps { events: CalendarEvent[]; } export function CalendarView({ events }: CalendarViewProps) { const now = new Date(); const today = now.toISOString().split("T")[0]; const tomorrow = new Date(now.getTime() + 86400000).toISOString().split("T")[0]; const todayEvents = events.filter((e) => e.start.startsWith(today)); const tomorrowEvents = events.filter((e) => e.start.startsWith(tomorrow)); const laterEvents = events.filter( (e) => !e.start.startsWith(today) && !e.start.startsWith(tomorrow) ); const formatDate = (dateStr: string) => { return new Date(dateStr).toLocaleDateString("es-MX", { weekday: "long", month: "long", day: "numeric", }); }; const hasEvents = events.length > 0; return (
{events.length} eventos esta semana
{!hasEvents ? (
📅

Sin eventos programados

Los próximos eventos del calendario de Odoo aparecerán aquí

) : (

Hoy

{formatDate(today)}

{todayEvents.length === 0 ? (

Sin eventos

) : (
{todayEvents.map((e) => )}
)}

Mañana

{formatDate(tomorrow)}

{tomorrowEvents.length === 0 ? (

Sin eventos

) : (
{tomorrowEvents.map((e) => )}
)}

Esta semana

Próximos días

{laterEvents.length === 0 ? (

Sin eventos

) : (
{laterEvents.map((e) => (
{formatDate(e.start)} {e.name}
))}
)}
)}
); }