// sidebar.jsx — Left sidebar for Sao Mai Hotel // Logo, +New, nav, mini calendar, room filters, quick stats const NAV_ITEMS = [ { key: 'calendar', label: 'Lịch đặt phòng', icon: 'calendar', badge: null }, { key: 'bookings', label: 'Danh sách đặt phòng', icon: 'list', badge: 13 }, { key: 'invoices', label: 'Hóa đơn', icon: 'invoice', badge: 8 }, { key: 'services', label: 'Dịch vụ', icon: 'sparkle', badge: null }, { key: 'rooms', label: 'Phòng', icon: 'bed', badge: null }, { key: 'reports', label: 'Báo cáo', icon: 'chart', badge: null }, ]; function MiniCalendar({ value, onPick, bookings, today }) { const [view, setView] = React.useState(() => { const d = new Date(value || today); return new Date(d.getFullYear(), d.getMonth(), 1); }); const monthName = `${MONTH_VN[view.getMonth()]} ${view.getFullYear()}`; const firstDow = view.getDay(); const daysInMonth = new Date(view.getFullYear(), view.getMonth() + 1, 0).getDate(); const prevMonthDays = new Date(view.getFullYear(), view.getMonth(), 0).getDate(); // Build 6 weeks of 7 = 42 cells const cells = []; for (let i = 0; i < firstDow; i++) { cells.push({ d: new Date(view.getFullYear(), view.getMonth() - 1, prevMonthDays - firstDow + 1 + i), muted: true, }); } for (let i = 1; i <= daysInMonth; i++) { cells.push({ d: new Date(view.getFullYear(), view.getMonth(), i), muted: false }); } while (cells.length < 42) { const last = cells[cells.length - 1].d; cells.push({ d: new Date(last.getFullYear(), last.getMonth(), last.getDate() + 1), muted: true }); } // Booking presence per date const hasBooking = (d) => bookings.some(b => { const a = startOfDay(b.checkIn), c = startOfDay(b.checkOut); const x = startOfDay(d); return x >= a && x < c && b.status !== 'cancelled'; }); return (
{monthName}
{DOW_VN.map((d, i) =>
{d}
)} {cells.map((c, i) => { const isToday = sameDay(c.d, today); const isSelected = sameDay(c.d, value); return ( ); })}
); } function Sidebar({ collapsed, onToggle, active, onNav, onNewBooking, miniDate, setMiniDate, filters, setFilters, rooms, bookings, today, stats, }) { return ( ); } window.Sidebar = Sidebar;