Hi. I had a Quick Booking adapted code on my site, which was working fine. Now, suddenly it’s not working. I’m getting this error message:
Wix code SDK error: The value parameter of item at index 0 that is passed to the options method cannot be set to the value “4XH3LWgKG5txVlW2EDckWeLceXMrFoQG3X11PHA2gmcjF6lQbnuqUF9Akd9HmKmKZVMiEUMrML2yCudVrGAI7na8ctEtmjHwOPblD4p5mHeyGZ0Lcwn1PYjznzVut67CFjf2PjMglR61NwApLoijpaZsLNGGTwX5VS0JtQcAtACwV7jKy4WnNC3wuBQwFDItZfKhHWzRskvBKiUj9K65pLV0fzcR6apm1j1mAoIIhFGbHpX6B0KsEddHxkLJ8O6qvUaIfW15pf8pFclLZBOS8VkETZPYeldtTa9kdZTEq3layS8wOdfeOPv04U01kW1rKdeejG8d7kTq6iOFDygsQ0FrWrzTyCKFRIjBtpbIAJRLTSg6OrgCJGmss58o7iOtIPyihypbFNSY2uz1AQxg82ycsEtvXhgEUjwvF” because its length exceeds 400.
I pulled up a backup of my site I had made a while back when the code was working and now it’s not working either. Even the Wix Quick Booking example which I had opened in my editor is not working either. All are giving the same error. I have no idea how to solve it. I checked the code everything seems perfectly fine!
Any ideas? How can I solve this?
Here’s the code which refers to the dropdowns:
const serviceID = '62728e97-66ee-4643-acd3-cf00ecfbf8db';
let SlotsMap = {};
$w.onReady(function () {
const today = new Date();
today.setDate(today.getDate() + 1);
const daysOfTheWeek = ["Domingo","Segunda","Terça","Quarta","Quinta","Sexta", "Sábado"]
$w('#pickDay').options = GetWeekDays(today).map(day => {
return{
label: `${daysOfTheWeek[day.date.getDay()]}`,
value: day.date.toISOString()
}
});
$w('#pickDay').onChange((event, $w) => {
const selectedDate = new Date(event.target.value);
FindAvailableSlots(selectedDate);
});
$w('#buttonSubmit1').onClick(() => ValidadeAndSubmitForm());
});
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("#pickTime").options = []
$w("#pickTime").placeholder = "Indisponível"
$w("#pickTime").selectedIndex = undefined;
$w("#pickTime").disable();
}
else {
$w("#pickTime").options = availableSlots.map(slot => {
SlotsMap[slot._id] = slot;
let startTime = slot.startDateTime;
let timeString = GetTimeOfDay(startTime);
return {
label: timeString,
value: slot._id
}
});
$w("#pickTime").placeholder = "Horários disponíveis";
$w("#pickTime").selectedIndex = undefined;
$w("#pickTime").enable();
}
}
async function ValidadeAndSubmitForm() {
$w("#error").hide();
$w("#buttonSubmit1").disable();
const formFields = ["inputNome", "inputSobrenome", "inputDN", "inputEmail", "inputWhatsApp", "pickDay", "pickTime"];
if (formFields.every(input => $w(`#${input}`).valid)) {
const slot = SlotsMap[$w("#pickTime").value];
const newRequest = {
nome: $w("#inputNome").value,
sobrenome: $w('#inputSobrenome').value,
dataNascimento: $w('#inputDN').value,
email: $w('#inputEmail').value,
whatsapp: $w('#inputWhatsApp').value,
requestedSlot: slot,
status: "PENDING"
};
await wixData.insert("pendingClasses", newRequest);
$w('#AnchorTop').scrollTo();
showAulaIntro()
}
else {
$w('#error').show();
$w('#buttonSubmit1').enable();
}
}
async function GetNonPendingAvailableSlots (requestedServiceId, options = {}) {
const pending = (await GetPendingAppointments()).map(appointment => appointment.requestedSlot._id);
let availableSlots = (await wixBookings.getServiceAvailability(requestedServiceId, options)).slots;
availableSlots = availableSlots.filter(slot => !pending.includes(slot._id));
return availableSlots;
}
async function GetPendingAppointments (){
return (await wixData.query("pendingClasses").find()).items.filter(item => item.status === "PENDING");
}
function GetMidnight (date) {
let midnight = new Date(date);
midnight.setHours(0, 0, 0, 0);
return midnight;
}
function GetNextMidnight (date) {
let midnight = new Date(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("pt-BR",{ hour: "2-digit", minute: "2-digit"}).toLowerCase();
}
Here’s the backup site if anyone needs to take a closer look: