'use client'; import { useState } from 'react'; import { motion } from 'framer-motion'; import { Calendar as CalendarIcon, ChevronLeft, ChevronRight } from 'lucide-react'; export default function BookingCalendar({ property }) { const [currentMonth, setCurrentMonth] = useState(new Date()); const [selectedRange, setSelectedRange] = useState({ start: null, end: null }); const daysInMonth = new Date( currentMonth.getFullYear(), currentMonth.getMonth() + 1, 0 ).getDate(); const firstDayOfMonth = new Date( currentMonth.getFullYear(), currentMonth.getMonth(), 1 ).getDay(); const monthNames = [ 'يناير', 'فبراير', 'مارس', 'إبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر' ]; const isDateBooked = (date) => { if (!property.bookings) return false; const dateStr = date.toISOString().split('T')[0]; return property.bookings.some(booking => { const start = new Date(booking.startDate); const end = new Date(booking.endDate); const current = new Date(date); return current >= start && current <= end; }); }; const handleDateClick = (date) => { if (isDateBooked(date)) return; }; const renderDays = () => { const days = []; const totalDays = daysInMonth + firstDayOfMonth; for (let i = 0; i < totalDays; i++) { if (i < firstDayOfMonth) { days.push(
); } else { const dayNumber = i - firstDayOfMonth + 1; const date = new Date( currentMonth.getFullYear(), currentMonth.getMonth(), dayNumber ); const isBooked = isDateBooked(date); days.push( ); } } return days; }; return (

{monthNames[currentMonth.getMonth()]} {currentMonth.getFullYear()}

أحد
إثنين
ثلاثاء
أربعاء
خميس
جمعة
سبت
{renderDays()}
محجوز
متاح
); }