Add edit button for rental bookings in Bookings page rental tab
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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<BookingStatus | 'all'>('all')
|
||||
const [selected, setSelected] = useState<Booking | null>(null)
|
||||
@@ -281,9 +281,9 @@ export function BookingsPage() {
|
||||
<thead>
|
||||
<tr className="border-b border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-700/40">
|
||||
{[
|
||||
'Гость', 'Объект', 'Дата', 'Время', 'Сумма', 'Статус',
|
||||
].map(h => (
|
||||
<th key={h} className="text-left px-4 py-3 text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wide">
|
||||
'Гость', 'Объект', 'Дата', 'Время', 'Сумма', 'Статус', '',
|
||||
].map((h, i) => (
|
||||
<th key={i} className="text-left px-4 py-3 text-xs font-semibold text-slate-500 dark:text-slate-400 uppercase tracking-wide">
|
||||
{h}
|
||||
</th>
|
||||
))}
|
||||
@@ -326,6 +326,17 @@ export function BookingsPage() {
|
||||
{b.status === 'confirmed' ? 'Подтверждено' : 'Отменено'}
|
||||
</Badge>
|
||||
</td>
|
||||
<td className="px-4 py-3">
|
||||
{obj && (
|
||||
<button
|
||||
onClick={() => setShowRentalModal({ obj, date: b.date, editBooking: b })}
|
||||
className="p-1.5 rounded-lg hover:bg-slate-100 dark:hover:bg-slate-700 text-slate-400 hover:text-slate-700 dark:hover:text-slate-300 transition-colors"
|
||||
title="Редактировать"
|
||||
>
|
||||
<Pencil size={13} />
|
||||
</button>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
})}
|
||||
@@ -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)
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user