Skip to content

Commit

Permalink
store status logic update
Browse files Browse the repository at this point in the history
  • Loading branch information
saaqi committed Sep 9, 2024
1 parent b2c7db6 commit 08ffd85
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/js/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,27 @@ function storeStatus() {
timeZone,
weekday: "long",
});
const isOpeningHours =
(dayOfWeek === "Sunday" && hours >= 9 && hours < 17) ||
(dayOfWeek !== "Sunday" && hours >= 8 && hours < 19);

const outputTime = isOpeningHours
? '<span class="open text-success fw-bold">Open</span> come on down'
: '<span class="closed text-danger fw-bold">Closed</span> see you tomorrow. 🙂';
let outputTime;
// Check if it's during opening hours
if (
(dayOfWeek === "Sunday" && hours >= 9 && hours < 17) ||
(dayOfWeek !== "Sunday" && hours >= 8 && hours < 19)
) outputTime = '<span class="open text-success fw-bold">Open</span> come on down'
// Check if it's after closing hours but before midnight
else if (
(dayOfWeek === "Sunday" && hours >= 17 && hours < 24) ||
(dayOfWeek !== "Sunday" && hours >= 19 && hours < 24)
) outputTime = '<span class="closed text-danger fw-bold">Closed</span> at the moment see you tomorrow. &#128578;';
// Check if it's before opening hours but after midnight
else if (hours >= 0 && (dayOfWeek === "Sunday" ? hours < 8 : hours < 9)) {
if (dayOfWeek === "Sunday" && hours < 8)
outputTime = '<span class="closed text-danger fw-bold">Closed</span> at the moment see you at 08:00 AM. &#128564;';
else if (dayOfWeek !== "Sunday" && hours < 9)
outputTime = '<span class="closed text-danger fw-bold">Closed</span> at the moment see you at 09:00 AM. &#128564;';
}

return `${outputDay}, We are ${outputTime}`;
return `It is ${outputDay}, We are ${outputTime}`;
}

function updateStatusRealtime() {
Expand Down

0 comments on commit 08ffd85

Please sign in to comment.