From 7d9c21cf9a540ae1ebf48972e3ff8746e8c68925 Mon Sep 17 00:00:00 2001 From: Shafkathullah Ihsan Date: Tue, 21 Mar 2023 23:26:16 +0530 Subject: [PATCH] adds fix-availability-slot-addition (#7420) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Omar López --- packages/features/schedules/components/Schedule.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/features/schedules/components/Schedule.tsx b/packages/features/schedules/components/Schedule.tsx index 049c15670d..af6be32a30 100644 --- a/packages/features/schedules/components/Schedule.tsx +++ b/packages/features/schedules/components/Schedule.tsx @@ -346,10 +346,16 @@ const useOptions = () => { }; const getNextRange = (field?: FieldArrayWithId) => { - const nextRangeStart = dayjs((field as unknown as TimeRange).end); - const nextRangeEnd = dayjs(nextRangeStart).add(1, "hour"); + const nextRangeStart = dayjs((field as unknown as TimeRange).end).utc(); + const nextRangeEnd = + nextRangeStart.hour() === 23 + ? dayjs(nextRangeStart).add(59, "minutes").add(59, "seconds").add(999, "milliseconds") + : dayjs(nextRangeStart).add(1, "hour"); - if (nextRangeEnd.isBefore(nextRangeStart.endOf("day"))) { + if ( + nextRangeEnd.isBefore(nextRangeStart.endOf("day")) || + nextRangeEnd.isSame(nextRangeStart.endOf("day")) + ) { return { start: nextRangeStart.toDate(), end: nextRangeEnd.toDate(),