Booking tools

This commit is contained in:
Jose Selesan
2026-05-06 15:31:02 -03:00
parent b97eb9c8a4
commit 01688cf042
5 changed files with 341 additions and 15 deletions

View File

@@ -210,7 +210,7 @@ interface BookingSlotBlockProps {
}
function BookingSlotBlock({ segment, schedule, rangeStart, totalMinutes }: BookingSlotBlockProps) {
const { openCreateBooking, updateBookingStatus } = useBooking();
const { openCreateBooking, updateBookingStatus, openBookingTools } = useBooking();
const left = ((segment.startMinutes - rangeStart) / totalMinutes) * 100;
const width = ((segment.endMinutes - segment.startMinutes) / totalMinutes) * 100;
const isFree = segment.status === 'free';
@@ -225,13 +225,16 @@ function BookingSlotBlock({ segment, schedule, rangeStart, totalMinutes }: Booki
segment.status === 'reserved' &&
'border-reserved/70 bg-reserved/80 text-reserved-foreground',
segment.status === 'maintenance' &&
'border-maintenance/80 bg-maintenance/75 text-maintenance-foreground'
'border-maintenance/80 bg-maintenance/75 text-maintenance-foreground',
segment.booking?.status === 'COMPLETED' &&
'border-reserved/70 bg-reserved/25 dark:text-reserved-foreground text-gray-600 line-through',
)}
style={{
left: `calc(${left}% + 4px)`,
width: `calc(${width}% - 8px)`,
}}
onClick={() => {
onClick={(event) => {
if (isFree) {
openCreateBooking({
courtId: schedule.court.id,
@@ -239,13 +242,11 @@ function BookingSlotBlock({ segment, schedule, rangeStart, totalMinutes }: Booki
sportId: schedule.court.sportId,
});
} else {
//console.log(JSON.stringify(segment, null, 2));
setPopoverOpen(true);
}
}}
onDoubleClick={() => {
if (segment.booking?.status === 'CONFIRMED') {
updateBookingStatus(segment.booking.id, 'COMPLETED');
if(event.shiftKey && segment.booking?.status === 'CONFIRMED') {
updateBookingStatus(segment.booking.id, 'COMPLETED');
} else {
openBookingTools(segment);
}
}
}}
title={