diff --git a/apps/web/modules/bookings/components/AvailableTimes.tsx b/apps/web/modules/bookings/components/AvailableTimes.tsx index 5f495ad47ebfb5..4d7e04c1afa2a1 100644 --- a/apps/web/modules/bookings/components/AvailableTimes.tsx +++ b/apps/web/modules/bookings/components/AvailableTimes.tsx @@ -76,6 +76,7 @@ type SlotItemProps = { unavailableTimeSlots?: string[]; confirmButtonDisabled?: boolean; handleSlotClick?: (slot: Slot, isOverlapping: boolean) => void; + bottomBarWidthCh?: number; }; const SlotItem = ({ @@ -97,6 +98,7 @@ const SlotItem = ({ unavailableTimeSlots = [], confirmButtonDisabled, confirmStepClassNames, + bottomBarWidthCh, }: SlotItemProps) => { const { t } = useLocale(); @@ -112,10 +114,12 @@ const SlotItem = ({ getQueryParam("overlayCalendar") === "true" || localStorage.getItem("overlayCalendarSwitchDefault"); const { timeFormat, timezone } = useBookerTime(); + const bookingData = useBookerStoreContext((state) => state.bookingData); const layout = useBookerStoreContext((state) => state.layout); const hasTimeSlots = !!seatsPerTimeSlot; const computedDateWithUsersTimezone = dayjs.utc(slot.time).tz(timezone); + const formattedTime = computedDateWithUsersTimezone.format(timeFormat); const bookingFull = !!(hasTimeSlots && slot.attendees && slot.attendees >= seatsPerTimeSlot); const isHalfFull = slot.attendees && seatsPerTimeSlot && slot.attendees / seatsPerTimeSlot >= 0.5; @@ -135,6 +139,18 @@ const SlotItem = ({ offset, }); + const slotHour = computedDateWithUsersTimezone.hour(); + let bottomBarColor = "bg-sky-500"; + + if (slotHour >= 6 && slotHour < 12) { + // Morning: 6 AM to 11:59 AM + bottomBarColor = "bg-yellow-400"; + + } else if (slotHour >= 12 && slotHour < 18) { + // Afternoon: 12 PM to 5:59 PM + bottomBarColor = "bg-orange-400"; + } + const onButtonClick = () => { if (handleSlotClick) { handleSlotClick(slot, isOverlapping); @@ -146,12 +162,14 @@ const SlotItem = ({ seatsPerTimeSlot, }); } + }; const isTimeslotUnavailable = unavailableTimeSlots.includes(slot.time); return (
+
+ {bookingFull &&

{t("booking_full")}

} {hasTimeSlots && !bookingFull && ( @@ -199,7 +226,11 @@ const SlotItem = ({ />

)} + + + + {!!slot.showConfirmButton && ( @@ -267,6 +298,15 @@ export const AvailableTimes = ({ ...props }: AvailableTimesProps) => { const { t } = useLocale(); + const { timeFormat, timezone } = useBookerTime(); + + const bottomBarWidthCh = useMemo(() => { + return slots.reduce((maxWidth, slot) => { + if (slot.away) return maxWidth; + const width = dayjs.utc(slot.time).tz(timezone).format(timeFormat).length; + return Math.max(maxWidth, width); + }, 0); + }, [slots, timeFormat, timezone]); const oooAllDay = slots.every((slot) => slot.away); if (oooAllDay) { @@ -293,7 +333,7 @@ export const AvailableTimes = ({ {oooBeforeSlots && !oooAfterSlots && } {slots.map((slot) => { if (slot.away) return null; - return ; + return ; })} {oooAfterSlots && !oooBeforeSlots && }