I need to display a component only during business hours.
Right now, my plan is to create an object called Hours that has weekday:[openTime, closeTime] as key/value pairs for each day of the week.
Then, I am planning on using JavaScript to get the current time, then using that to get the weekday. I will see if the current time is between the times I will fetch from the previously created object (Hours.weekday), and render the component if true.
This seems very overly complicated, but it is the only way I could think of. I am still pretty new to JavaScript and React, so if you have any tips or more concise ways to do this, please let me know!
const hours = new Object();
hours.monday = [9, 5]
hours.tuesday = [9, 5]
hours.wednesday = [9, 5]
hours.thursday = [9, 5]
hours.friday = [9, 5]
hours.saturday = [10, 4]
hours.sunday=[null, null]