Dropdowns not working - Quick-Booking Form with the Wix Bookings API

I started by watching and doing exactly as this video instructed. https://www.youtube.com/watch?v=lEEIaJyKzM8

The video is by wix.com and it explains how to create a quick booking form with the Wix Bookings API. I copied every step and checked my code a 100 times, the problem is always the same, when I preview the page and click on the dropdown box there is nothing to choose from.

Then I went here https://www.wix.com/corvid/example/Quick-Book-and-Pending-Appointments

The code here was slightly different, I saved my other code elsewhere, and pasted in the code from the example. No errors came up, I hit the preview, clicked the downloads and still nothing.

I was determined to see it working as it should, so finally I went to the example editor. https://editor.wix.com/html/editor/web/renderer/new?siteId=a0d6a334-35b5-436a-a29e-e2ae855d9117&metaSiteId=7f4b3a3b-f10e-4f03-a95b-d2a33959486b

I hit preview, clicked on drop downs and it does the exact same thing!

So whats going on here, either all three of these different examples are broken in the same way, or… there was an update to how this code works and I can’t find anyone talking about it. You would think something like a problem with dropdowns and corvid would have been noticed sooner.

Which brings me here looking for an answer, anyone know whats going on?

Here is the original code from the youtube video transcribed. I’m assuming its all correct.


import wixBookings from ‘wix-bookings’;
import wixData from ‘wix-data’;

const serviceId = ‘c8eed83a-ccff-4022-bef7-0dc6985b0e38’;
let slotMap = {};

$w.onReady(function () {
const today = new Date();
const daysOfTheWeek = [“Sun”, “Mon”, “Tue”, “Wed”, “Thu”, “Fri”, “Sat”];
$w(‘#dayPicker’).options = getWeekDays(today).map(day => {
return {
label: ${daysOfTheWeek[day.date.getDay()]} ${day.date.tolocaleDateString("en-GB")},
value: day.date.toISOString()
}
});
$w(‘#dayPicker’).onChange((event, $w) => {
const selectedDate = new Date(event.target.value);
findAvailableSlots(selectedDate);
});
sw(“#submitButton”).onClick(() => validateAndSubmitForm());
});

async function findAvailableSlots(dateString) {
slotsMap = {};
const startDateTime = getMidnight(dateString);
const endDateTime = getNextMidnight(dateString);
const options = {
startDateTime,
endDateTime
};
const availableSlots = await getNonPendingAvailableSlots(serviceId, options);

if (availableSlots.length === 0) { 
	$w("#slotPicker").options = []; 
	$w("#slotPicker").placeholder = "No sessions for this day"; 
	$w("#slotPicker").selectedIndex = undefeined; 
	$w("#slotPicker").disable(); 
} 
else { 
	$w("#slotPicker").options = availableSlots.map(slot => { 
		slotsMap[slot._id] = slot; 
		let startTime = slot.startDateTime; 
		let timeString = getTimeOfDay(startTime); 
		return { 
			label: timeString, 
			value: slot._id 
		} 
	}); 
	$w("#slotPicker").placeholder = "Pick a time"; 
	$w("#slotPicker").selectedIndex = undefined; 
	$w("#slotPicker").enable(); 
} 

}

async function validateAndSubmitForm() {
$w(“#errorMessage”).hide();
$w(“#submitButton”).disable();

const formFields = ["nameInput", "emailInput", "ageInput", "dayPicker", "slotPicker", "agreementCheckbox"]; 

if (formFields.every(input => $w('#${input}').valid)) { 
const slot = slotsMap[$w("#slotPicker").value]; 
const newRequest = { 
	name: $w("#nameInput").value, 
	email: $w('#emailInput').value, 
	age: $w('#ageInput').value, 
	requestedSlot: slot, 
	status: "PENDING" 
}; 
await wixData.insert("Tour_Booking", newRequest); 
$w("#formGroup").hide(); 
$w("#thankYouText").show(); 
} 
else { 
	$w("#errorMessage").show(); 
	$w("#submitButton").enable(); 
} 

}
async function getNonPendingAvailableSlots(requestedServiceId, options = {}) {
const pending = {await getPendingAppiontments()).map(appointment => appointment.requestedSlot._id);
let availableSlots = (await wixBookings.getServiceAvailability(requestServiceId, options)).slots;
availableSlots = availableSlots.filter(slot => !pending.includes(slot._id));}
return availableSlots;
}

async function getTour_Booking() {
return (await wixData.query(“Tour_Booking”).find()).items.filter(item => item.status === “PENDING”);
}

function getMidnight(date) {
let midnight = new Data(date);
midnight.setHours(0, 0, 0, 0);
return midnight;
}

function getNextMidnight(date) {
let midnight = new Data(date);
midnight.sethours(24, 0, 0, 0);
return midnight;
}

function getWeekDays(startDate) {
let weekDays = ;
let current = getMidnight(startDate);

for (let i = 0; i < 7; i++) { 
	weekDays.push({ 
		_id: "day" + i, 
		date: current 
}); 
current = getNextMidnight(current) 
} 

return weekDays;
}

function getTimeOfDay(date) {
return date.toLocaleTimeString(, { hour: “2-digit”, minute: “2-digit”}).toLowerCase();
}


when I preview the page and click on the dropdown box there is nothing to choose from.

I hit the preview, clicked the downloads and still nothing.

I hit preview, clicked on drop downs and it does the exact same thing!

Have you simply tried just doing what it says in the tutorial, especially step 2?

Next Steps​

  1. Open this example in the Editor to work with the template.

  2. Publish the site and refresh your browser so the Bookings collections appear in the Database.

  3. Learn how to work with examples in Corvid .

Hello,

Thanks for the quick reply. I don’t suppose you could be a little more specific? I referred 3 different examples and none of them contain a “Step 2”. Are you referring to part 2 of the video, or some part of the blog post or Wix created example?

Lets suppose I missed some step how does that explain why the Wix made editor is doing the same thing, I didn’t make that example, Wix did.

I went to the Youtube link up top and read the description of the video.
To learn more about creating a quick-booking form with the Wix Bookings API visit: https://www.wix.com/corvid/example/Qu…

Which then took me to the quick book and pending etc page which you also linked to up above.
https://www.wix.com/corvid/example/Quick-Book-and-Pending-Appointments

Scroll down the page and it is there above the code example box.

Publish the site and refresh your browser so the Bookings collections appear in the Database.

Did you do this before you started making the page, so that you had all the Bookings Collections in your Site Structure?

You did put the code from the Youtube tutorial into your Lightbox page code?

Also, you have actually added the Wix Bookings app to your website too before you started making up this tutorial, as when they create the pendingAppointments dataset in the Youtube video, you will see that Bookings is already there.

Finally, the code on the Wix Tutorial page that is shown on page 2 of the code example box, that is all the code for the admin page which is shown in the second youtube video.
https://www.youtube.com/watch?v=_hKsMICCfAM

So, you can simply copy and paste that lot of code and change it to suit your own website, instead of having to pause and type it off from the video itself - which should have been the option for page 1 of the code example too for the first video!

I think there is a disconnect between what I’m saying and what you are saying.

“You did put the code from the Youtube tutorial into your Lightbox page code?”
Yes, I tested the code from the Youtube video and the code from the blog post.

“Also, you have actually added the Wix Bookings app to your website too?”
Yes, the Wix booking is added.

"Finally, the code on the Wix Tutorial page that is shown on page 2 of the code example box, that is all the code for the admin page which is shown in the second youtube video.
https://www.youtube.com/watch?v=_hKsMICCfAM
So, you can simply copy and paste that lot of code and change it to suit your own website, instead of having to pause and type it off from the video itself - which should have been the option for page 1 of the code example too for the first video!"

Yes not having to to transcribe the code would have been helpful. However, none of this is answering my question. I have proposed a problem that I need someone that is more skilled in corvid to confirm.

Can you explain this one thing to me, why doesn’t the drop down boxes on the Wix made example work? https://editor.wix.com/html/editor/web/renderer/new?siteId=a0d6a334-35b5-436a-a29e-e2ae855d9117&metaSiteId=7f4b3a3b-f10e-4f03-a95b-d2a33959486b

so you can see how everything works

This question is related to the YouTube video, so I posted a comment on that video and was told to come here. Surely there is someone that would know why 3 different examples of the same feature are having the same problem. Either A my browser is messed up and this is only effecting me, or B there was some kind of change that is effecting this feature from working. Because this video isn’t very old, perhaps there isn’t that many people that use this feature, or those that know corvid enough know to just make some sort of work around.

It would be helpful if you could start by acknowledging that you understand what the problem is and we go from there.

Thanks,

I am having the same problem… my drop downs are returning the label code instead of data… I get this
${daysOfTheWeek[day.date.getDay()]} ${day.date.toLocaleDateString(“en-GB”)} over and over again…