This episode is for members only

Sign up to access "Build an Appointment Booking System With Inertia" right now.

Get started
Already a member? Sign in to continue
Playing
31. Fixing up core availability in the past

Episodes

0%
Your progress
  • Total: 5h 0m
  • Played: 0m
  • Remaining: 5h 0m
Join or sign in to track your progress

Transcript

00:00
Okay let's take a look at a fundamental issue with the core functionality which means that we still see availability for dates in the past even though the schedule doesn't allow for it.
00:10
So as an example if we just land on this checkout and we have a look here everything looks good now that's fine because we kind of expect that if we go back or forward to March and then back again remember what we're doing is we are looking at the start of the month so we're now looking from the 1st of February and it's currently the 19th so what's happening is these slots
00:33
are showing as available we can't select them which is fine but these are showing as available because we've set that minimum date within our picker but we could still technically book these now the reason that this is happening if we come over to our availability or schedule availability class under add availability from schedule let's think about what's happening
00:55
so if we look in the database my schedule starts on the 10th of February and ends within a year now that's fine because if our schedule isn't in between there we're not going to add availability but what's happening here is I'm technically available from the 10th even though it's currently the 19th so our schedule is from the 10th which is always going to be the case because
01:18
we always need to start an end day but I can technically look at say the 15th the 14th the 13th all the way down to the 10th so what we want to do is add another check in here just to make sure that we're returning if we are not past the current day so let's go ahead and say if the date is less than or equal to the current date and then sub a day so let's just remove a day from that
01:45
then we want to return so basically if say today is or if my schedule is on the 10th and today is the 19th I want to only show availability from the 19th onwards and we could say start of day here but let's just say sub a day it doesn't really matter too much so let's go ahead and try this out again let's go over give this a refresh go to the next month
02:08
back again which is technically from the first but now we've added that condition in it's only showing availability from today rather than the start of the schedule that I have in the database so something we missed and something that we just needed to very quickly add in to prevent that from happening for previous dates we never need availability for any day other than today onwards

Episode summary

In this episode, we tackle a pretty important bug with our core availability feature: the app is showing available slots for past dates, even though users shouldn't be able to book them! We walk through a real example where, after navigating the calendar, dates prior to today are still appearing as available—even though they can't be selected.

We dig into the logic inside our schedule availability class and see exactly why this is happening: our system is adding availabilities for dates starting from the schedule's start date, regardless of whether that date is in the past. So, if the schedule starts on the 10th and today is the 19th, it's still technically showing slots for the 10th and onward.

To fix this, we add a simple check to ensure that availability is only shown for today or later, not for any day before. After updating the code, we test again and confirm that only current and future slots are visible to users. It's a nice, quick fix to stop users from seeing irrelevant past availability in the booking calendar!

Episode discussion

No comments, yet. Be the first!