Fix booking click broken: restore onClick, fix drag vs click detection
Removed onClick broke the detail panel. Now: - onClick restored on booking block (opens panel on simple click) - didDragRef flag prevents panel opening after a drag completes - handleMouseUp no longer calls setSelectedBooking (onClick handles it) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -87,6 +87,7 @@ export function BookingCalendar({ rooms, bookings, onBookingCreate, onBookingUpd
|
||||
const moveStartPos = useRef<{ x: number; y: number } | null>(null)
|
||||
const movingBookingRef = useRef<Booking | null>(null)
|
||||
const moveTargetRoomIdRef = useRef<string | null>(null)
|
||||
const didDragRef = useRef(false)
|
||||
movingBookingRef.current = movingBooking
|
||||
moveTargetRoomIdRef.current = moveTargetRoomId
|
||||
|
||||
@@ -179,6 +180,7 @@ export function BookingCalendar({ rooms, bookings, onBookingCreate, onBookingUpd
|
||||
if (mb) {
|
||||
// Was dragging a booking to another room
|
||||
if (targetRoom && targetRoom !== mb.roomId) {
|
||||
didDragRef.current = true
|
||||
onBookingUpdate(mb.id, { roomId: targetRoom })
|
||||
}
|
||||
setMovingBooking(null)
|
||||
@@ -188,12 +190,10 @@ export function BookingCalendar({ rooms, bookings, onBookingCreate, onBookingUpd
|
||||
return
|
||||
}
|
||||
|
||||
// No drag — clear pending refs; onClick on booking block will open the panel
|
||||
if (pendingMoveBooking.current) {
|
||||
// Mouse went up without moving — treat as click
|
||||
setSelectedBooking(pendingMoveBooking.current)
|
||||
pendingMoveBooking.current = null
|
||||
moveStartPos.current = null
|
||||
return
|
||||
}
|
||||
|
||||
if (!dragStart || dragEnd === null) return
|
||||
@@ -526,6 +526,11 @@ export function BookingCalendar({ rooms, bookings, onBookingCreate, onBookingUpd
|
||||
pendingMoveBooking.current = booking
|
||||
moveStartPos.current = { x: e.clientX, y: e.clientY }
|
||||
}}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
if (didDragRef.current) { didDragRef.current = false; return }
|
||||
setSelectedBooking(booking)
|
||||
}}
|
||||
title={`${booking.guestName} • ${booking.checkIn}${hourlyMatch ? ` ${hourlyMatch[1]}:00–${hourlyMatch[2]}:00` : ` – ${booking.checkOut}`}${isUnpaid ? ' • Не оплачено' : ''}`}
|
||||
>
|
||||
{isUnpaid && (
|
||||
|
||||
Reference in New Issue
Block a user