From a787affa72c4086c3928e36c80a574e94c0ab3c9 Mon Sep 17 00:00:00 2001 From: HotelSync Date: Mon, 16 Mar 2026 15:18:23 +0300 Subject: [PATCH] Add edit button for rental bookings in Bookings page rental tab Co-Authored-By: Claude Sonnet 4.6 --- src/pages/BookingsPage.tsx | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/pages/BookingsPage.tsx b/src/pages/BookingsPage.tsx index 40e1e44..4d35419 100644 --- a/src/pages/BookingsPage.tsx +++ b/src/pages/BookingsPage.tsx @@ -1,5 +1,5 @@ import { useState, useMemo } from 'react' -import { Search, Plus, ArrowUp, ArrowDown, ArrowUpDown, Clock } from 'lucide-react' +import { Search, Plus, ArrowUp, ArrowDown, ArrowUpDown, Clock, Pencil } from 'lucide-react' import { MOCK_BOOKINGS, MOCK_ROOMS } from '../data/mockData' import { RENTAL_OBJECTS, MOCK_RENTAL_BOOKINGS } from '../data/rentalData' import { useModules } from '../contexts/ModulesContext' @@ -46,7 +46,7 @@ export function BookingsPage() { const [newRentalStep, setNewRentalStep] = useState<'idle' | 'pick'>('idle') const [rentalPickObj, setRentalPickObj] = useState(RENTAL_OBJECTS[0]?.id ?? '') const [rentalPickDate, setRentalPickDate] = useState(format(new Date(), 'yyyy-MM-dd')) - const [showRentalModal, setShowRentalModal] = useState<{ obj: typeof RENTAL_OBJECTS[0]; date: string } | null>(null) + const [showRentalModal, setShowRentalModal] = useState<{ obj: typeof RENTAL_OBJECTS[0]; date: string; editBooking?: RentalBooking } | null>(null) const [search, setSearch] = useState('') const [statusFilter, setStatusFilter] = useState('all') const [selected, setSelected] = useState(null) @@ -281,9 +281,9 @@ export function BookingsPage() { {[ - 'Гость', 'Объект', 'Дата', 'Время', 'Сумма', 'Статус', - ].map(h => ( - + 'Гость', 'Объект', 'Дата', 'Время', 'Сумма', 'Статус', '', + ].map((h, i) => ( + {h} ))} @@ -326,6 +326,17 @@ export function BookingsPage() { {b.status === 'confirmed' ? 'Подтверждено' : 'Отменено'} + + {obj && ( + + )} + ) })} @@ -424,9 +435,13 @@ export function BookingsPage() { obj={showRentalModal.obj} date={showRentalModal.date} existingBookings={rentalBookings.filter(b => b.objectId === showRentalModal.obj.id && b.date === showRentalModal.date)} + editBooking={showRentalModal.editBooking} onClose={() => setShowRentalModal(null)} onSave={(b) => { - setRentalBookings(prev => [...prev, b]) + setRentalBookings(prev => { + const exists = prev.find(x => x.id === b.id) + return exists ? prev.map(x => x.id === b.id ? b : x) : [...prev, b] + }) setShowRentalModal(null) }} />