diff --git a/src/components/bookings/BookingModal.tsx b/src/components/bookings/BookingModal.tsx index 67dfa3d..63d4c73 100644 --- a/src/components/bookings/BookingModal.tsx +++ b/src/components/bookings/BookingModal.tsx @@ -1,6 +1,6 @@ import { useState } from 'react' import { format } from 'date-fns' -import { Star, Banknote, CreditCard, AlertCircle, Map, Plus, Trash2, IdCard, CalendarDays, Tag, ScanLine } from 'lucide-react' +import { Star, Banknote, CreditCard, AlertCircle, Map, Plus, Trash2, IdCard, CalendarDays, Tag, ScanLine, Minus, BedDouble } from 'lucide-react' import { MOCK_DISCOUNTS } from '../../pages/DiscountsPage' import type { Discount } from '../../pages/DiscountsPage' import { Modal } from '../ui/Modal' @@ -99,6 +99,10 @@ export function BookingModal({ open, draft, rooms, onClose, onSave, existing }: const [startHour, setStartHour] = useState(10) const [endHour, setEndHour] = useState(12) + // Extra beds + const [extraBeds, setExtraBeds] = useState(0) + const EXTRA_BED_PRICE = 1500 + const room = rooms.find(r => r.id === form.roomId) const nights = form.checkIn && form.checkOut ? Math.max(0, (new Date(form.checkOut).getTime() - new Date(form.checkIn).getTime()) / 86400000) @@ -115,7 +119,8 @@ export function BookingModal({ open, draft, rooms, onClose, onSave, existing }: : 0 const roomTotal = Math.max(0, roomBaseTotal - discountAmount) const servicesTotal = addedServices.reduce((s, sv) => s + sv.price * sv.qty, 0) - const total = roomTotal + servicesTotal + const extraBedsTotal = extraBeds * EXTRA_BED_PRICE * (isHourly ? 1 : Math.max(1, nights)) + const total = roomTotal + servicesTotal + extraBedsTotal const debt = Math.max(0, total - paidAmount) @@ -150,6 +155,7 @@ export function BookingModal({ open, draft, rooms, onClose, onSave, existing }: const hourlyPrefix = isHourly && room?.allowHourly ? `[Почасово: ${String(startHour).padStart(2, '0')}:00–${String(endHour).padStart(2, '0')}:00] ` : '' + const extraBedsPrefix = extraBeds > 0 ? `[Доп.места: ${extraBeds}] ` : '' const checkIn = isHourly && room?.allowHourly ? hourlyDate : form.checkIn const checkOut = isHourly && room?.allowHourly ? hourlyDate : form.checkOut @@ -159,7 +165,7 @@ export function BookingModal({ open, draft, rooms, onClose, onSave, existing }: source: 'direct', checkIn, checkOut, - notes: hourlyPrefix + form.notes, + notes: hourlyPrefix + extraBedsPrefix + form.notes, totalAmount: total, paidAmount, id: existing?.id ?? `b-${Date.now()}`, @@ -418,6 +424,37 @@ export function BookingModal({ open, draft, rooms, onClose, onSave, existing }: + {/* Extra beds */} +
+
+ +
+

Доп. места

+

{EXTRA_BED_PRICE.toLocaleString('ru-RU')} ₽/место{!isHourly && nights > 0 ? '/ночь' : ''}

+
+
+
+ {extraBeds > 0 && ( + + +{extraBedsTotal.toLocaleString('ru-RU')} ₽ + + )} + + {extraBeds} + +
+
+ {/* Guest tags */}
- {MEAL_PLANS.map(mp => ( + {mealPlans.map(mp => ( + + {showDicts && ( +
+ {/* Meal plans */} +
+
+

Типы питания

+ +
+
+ {mealPlans.map(mp => ( +
+ {editMeal?.id === mp.id ? ( + <> + setEditMeal(p => p ? {...p, label: e.target.value} : p)} /> + setEditMeal(p => p ? {...p, description: e.target.value} : p)} /> + + + + ) : ( + <> +
+

{mp.label}

+

{mp.description}

+
+
+ + {!DEFAULT_MEAL_IDS.includes(mp.id) && ( + + )} +
+ + )} +
+ ))} +
+ {addMealOpen && ( +
+ setNewMealLabel(e.target.value)} /> + setNewMealDesc(e.target.value)} /> +
+ + +
+
+ )} +
+ + {/* Inclusions */} +
+
+

Что включено в номер

+ +
+
+ {allInclusions.map(inc => ( +
+ {editInc?.id === inc.id ? ( + <> + setEditInc(p => p ? {...p, label: e.target.value} : p)} /> + + + + ) : ( + <> + + {inc.label} +
+ + {!DEFAULT_INC_IDS.includes(inc.id) && ( + + )} +
+ + )} +
+ ))} +
+ {addIncOpen && ( +
+ setNewIncLabel(e.target.value)} /> +
+ + +
+
+ )} +
+
+ )} +
+ {/* Tariff Modal */} {modal && ( setModal(null)} + mealPlans={mealPlans} + allInclusions={allInclusions} /> )}