Hopefully I can explain this clearly...
I have a page set up where people can schedule a time with one of our consultants. I use a repeater to list the available times from a dataset and they can select a time to reserve it. The trouble comes in if more than one person has the page open at the same time - they are both able to select the same time and whoever selects it second overwrites the first person. Because it's part of a repeater, I can't refresh/filter the dataset when they choose a time. How can I confirm that a time is still available when someone chooses it?
The page is https://www.dprepsafety.com/schedule
The code is:
$w("#daveButton").onClick((event, $w) => { $w("#emailD").updateValidityIndication(); if ($w("#emailD").valid) { let itemObj = $w("#daveSchedule").getCurrentItem(); let iDate = itemObj.time; console.log(itemObj); console.log(iDate); const options = { day: "numeric", month: "long", year: "numeric", hour: "2-digit", minute: "2-digit", timeZoneName: "short" }; $w("#daveSchedule").setFieldValues({ "email": $w('#emailD').value, "name": $w('#nameD').value, "department": $w('#departmentD').value }); $w('#daveSchedule').save() .then((response) => { console.log("Done saving the dataset"); $w('#daveRepeater').collapse(); console.log(iDate); $w('#dateOutD').text = iDate.toLocaleDateString("en-US", options); $w('#daveDateGroup').expand(); }) .catch((error) => { console.log(error); }) } }) Thank you!
Your issue....
How can I confirm that a time is still available when someone chooses it?
Your soution:
As soon as a person selects a time ---> you set the status of this time to "currently not available" (or similar) and save this state in your DATABASE (refreshing your DATASET --> which should refresh automatically your repeater with new data.
Inside of your database you simply generate a further DB-FIELD --> something like ----> "state" (available/in grogress/not available), or as a boolean DB-FIELD ---> "availability" ----> (TRUE / FALSE).
As an aside - I'm open to better ways of doing this. I know about the built in Wix booking system, but we don't want people to have to go through the process of becoming site members. We want to make it as easy as possible for folks signing up. It's a much lower priority, but I could also use advice on automating the reply when they sign up - currently I monitor the collection and manually send out emails to let people know we received the reservation.