import { format, eachDayOfInterval, endOfMonth, startOfMonth, startOfYear, endOfYear, eachMonthOfInterval, getDay } from 'date-fns'; import { es } from 'date-fns/locale'; import type { Reservation } from '../types'; interface Props { reservations: Reservation[]; year: number; } export function YearlyCalendar({ reservations = [], year }: Props) { const months = eachMonthOfInterval({ start: startOfYear(new Date(year, 0, 1)), end: endOfYear(new Date(year, 0, 1)) }); const isDayOccupied = (date: Date) => { if (!reservations || !Array.isArray(reservations)) return false; return reservations.some(res => { if (!res.start_date || !res.end_date) return false; const start = new Date(res.start_date); const end = new Date(res.end_date); if (isNaN(start.getTime()) || isNaN(end.getTime())) return false; // Ajuste de zona horaria simple const checkDate = new Date(date); checkDate.setHours(12, 0, 0, 0); start.setHours(0, 0, 0, 0); end.setHours(23, 59, 59, 999); return checkDate >= start && checkDate <= end; }); }; return (
Panorama global de ocupación.