Wix Bookings Timetable Future Dates Problem

Hi Wix Gurus,

I’m hoping someone can help me figure out what’s going on here.

I have built out the Bookings Timetable from the tutorial and examples, and have it working. I’m able to book people for the correct dates (mostly). I just noticed a problem and I can’t figure out why this is happening. Let’s say today is 4/12, and the timetable shows the next six days in the daysToolbar repeater. When I click on Thu 4/15, and I look at the console.log, I get the following.

This is exactly what I expect. I see the date range from midnight to midnight of 4/15 midnight to 4/16 midnight. Nothing strange here.

Now, when I click ahead two weeks, and I land on the week showing 4/26 to 5/2, and I click on Fri 4/30, the console is printing the Set Active Day twice… once for the Fri previous (4/23), and once for the current Fri (4/30), like so…

Why is it setting the Active Day twice?

This becomes a major issue anytime I’m in a future or previous week because sometimes (not always), it logs the dates out of chronological order… like so (I’ve switched over to show the logs in Chrome)…

As you can see in the logs above, the log prints out the date I’ve clicked on (4/24) first, and then it prints out the previous Thu date (4/17). This is a problem because it has now set the slotRepeater to 4/17, even though the user believes they have clicked on 4/24.

When I go through and book this slot, it books the wrong day. It books 4/17, instead of 4/24 (which the user believes they are booking).

So, my main question is, and I can’t figure this out… why is it setting the Active Day twice (or three times if I’m three weeks in the future, or 4 times if I’m four weeks in the future)? The future and previous week buttons become unusable if it’s sometimes going to set the Active Day to the wrong date.

I’ve made some slight modifications to the original tutorial, but nothing that should be affecting how the Active Day is being set. Again, if we are in the current week, this is not a problem. Set Active Day gets set once to the correct date. This only becomes a problem when I click on the next week or previous week buttons and the code has to calculate the future or past date. For some reason, it’s printing out multiple Set Active Dates and I need it to only print out one date… the correct one.

Any help you can provide would be appreciated. Thanks.

I would check where the ‘setActiveDay’ is being called from? It looks like it is being called twice, but using different dates each time.

It’s only being called once if we’re in the current week. It’s being called twice if, and only if, we’ve clicked on the arrow to move to the next week. It’s being called three times if, and only if, we’ve clicked the arrow to move to two weeks ahead. So, it’s not being called twice in the code. I suspect it’s in a helper date function, but I’m at a loss.

Here’s where setActiveDay is being called, exactly as the published tutorial (except I’m not getting Staff members).

And here is setupDaysToolbar. I’m not sure why its using firstDay and activeDay interchangeably, but this is also exactly as written in the tutorial…

Yeah, this looks a strange example, there are a couple of lines of code that don’t actually seem to be doing anything. Can you show the full function thats on lines 198/199?