From d8708e5ee52be10d09e32e5bbd19c5ee1fc37933 Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Thu, 14 Mar 2024 23:45:26 +0530 Subject: [PATCH] Update availabilityHelper.js --- app/javascript/widget/helpers/availabilityHelper.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/javascript/widget/helpers/availabilityHelper.js b/app/javascript/widget/helpers/availabilityHelper.js index 03293b5d8..53c3aab1b 100644 --- a/app/javascript/widget/helpers/availabilityHelper.js +++ b/app/javascript/widget/helpers/availabilityHelper.js @@ -29,13 +29,13 @@ const findNextAvailableTime = ( // Find the next available time for today const nextAvailableTimeToday = workingHours.find( workingHour => - currentDayOfWeek === workingHour.day_of_week && - !workingHour.closed_all_day && - (currentHour < workingHour.close_hour || - (currentHour === workingHour.close_hour && + currentDayOfWeek === workingHour.day_of_week && // Match current day + !workingHour.closed_all_day && // Check if not closed for the whole day + (currentHour < workingHour.close_hour || // Check if current hour is before closing hour + (currentHour === workingHour.close_hour && // or if hours are equal but minutes are before closing minutes currentMinutes < workingHour.close_minutes)) ); - + // If next available time for today is found if (nextAvailableTimeToday) { nextAvailableTime = { hour: nextAvailableTimeToday.open_hour, @@ -74,7 +74,7 @@ const findNextAvailableTime = ( * @returns {string} - Next availability message */ export const getNextAvailabilityMessage = (workingHours, currentTime) => { - const currentDayOfWeek = currentTime.getDay(); // 0 for Sunday, 1 for Monday, ... + const currentDayOfWeek = currentTime.getDay(); const currentHour = currentTime.getHours(); const currentMinutes = currentTime.getMinutes(); const nextAvailableTime = findNextAvailableTime(