diff --git a/src/components/calendar/BookingCalendar.tsx b/src/components/calendar/BookingCalendar.tsx index a90fb29..ab0763d 100644 --- a/src/components/calendar/BookingCalendar.tsx +++ b/src/components/calendar/BookingCalendar.tsx @@ -1,7 +1,8 @@ import { useState, useRef, useCallback, useEffect } from 'react' +import type { ReactNode } from 'react' import { addDays, format, startOfDay, differenceInDays, parseISO, isToday } from 'date-fns' import { ru } from 'date-fns/locale' -import { ChevronLeft, ChevronRight, Plus, CalendarDays, ChevronDown } from 'lucide-react' +import { ChevronLeft, ChevronRight, Plus, CalendarDays, ChevronDown, AlignJustify } from 'lucide-react' import { cn, BOOKING_STATUS_COLORS, BOOKING_STATUS_LABELS, SOURCE_LABELS } from '../../lib/utils' import type { Room, Booking, DraftBooking } from '../../types' import type { RentalObject, RentalBooking } from '../../data/rentalData' @@ -11,6 +12,7 @@ import { RentalBookingModal } from '../rental/RentalBookingModal' const CELL_WIDTH = 52 const ROW_HEIGHT = 56 +const ROW_HEIGHT_COMPACT = 34 const LABEL_WIDTH = 160 const DAYS_VISIBLE = 30 @@ -25,6 +27,15 @@ interface BookingCalendarProps { onRentalBookingCreate?: (b: RentalBooking) => void } +const CATEGORY_ORDER: Record = { + 'Стандарт': 0, + 'Делюкс': 1, + 'Полулюкс': 2, + 'Люкс': 3, + 'Пентхаус': 4, + 'Апартаменты': 5, +} + function getRoomTypeColor(type: string): string { const map: Record = { 'Стандарт': 'bg-slate-100 dark:bg-slate-700 text-slate-600 dark:text-slate-300', @@ -62,6 +73,10 @@ export function BookingCalendar({ rooms, bookings, onBookingCreate, onBookingUpd const [dragStart, setDragStart] = useState<{ roomId: string; dayIdx: number } | null>(null) const [dragEnd, setDragEnd] = useState(null) + // Compact mode + const [compact, setCompact] = useState(false) + const rowHeight = compact ? ROW_HEIGHT_COMPACT : ROW_HEIGHT + // Modals const [bookingModalDraft, setBookingModalDraft] = useState(null) const [selectedBooking, setSelectedBooking] = useState(null) @@ -71,6 +86,14 @@ export function BookingCalendar({ rooms, bookings, onBookingCreate, onBookingUpd const dates = Array.from({ length: visibleDays }, (_, i) => addDays(startDate, i)) + // Sorted+grouped rooms + const sortedRooms = [...rooms].sort((a, b) => { + const ao = CATEGORY_ORDER[a.type] ?? 99 + const bo = CATEGORY_ORDER[b.type] ?? 99 + if (ao !== bo) return ao - bo + return a.number.localeCompare(b.number, 'ru', { numeric: true }) + }) + const shiftDays = (n: number) => setStartDate(d => addDays(d, n)) const getBlockStyle = (booking: Booking) => { @@ -219,6 +242,14 @@ export function BookingCalendar({ rooms, bookings, onBookingCreate, onBookingUpd ))} + +