here is the code from the tutorial which i copied. i removed the age input, also removed the age in the database.
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
import wixBookings from ‘wix-bookings’ ;
import wixData from ‘wix-data’ ;
const serviceid = ‘1e418840-247f-4265-851d-deea0d63efc0’
let slotsmap = {};
$w.onReady( function () {
//TODO: write your page related code here…
const today = new Date();
const daysoftheweek = [ “Sun” , “Mon” , “Tue” , “Wed” , “Thu” , “Fri” , “Sat” ];
$w( ‘#datepick’ ).options = getweekdays(today).map(day => {
return {
label: {daysoftheweek[day.date.getDay()]} {day.date.toLocaldateString( "en-GB" )
,
value: day.date.toISOString()
}
});
$w( ‘#datepick’ ).onChange((event, $w) => {
const selecteddate = new Date(event.target.value);
findavailableslots(selecteddate);
});
$w( “#submit” ).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( “#slotpick” ).options = ;
$w( “#slotpick” ).placeholder = “No Sessions For This Day” ;
$w( "# slotpick " ).selectedIndex = undefined;
$w( "# slotpick " ).disable();
}
else {
$w( "# slotpick " ).options = availableslots.map(slot => {
slotsmap[slot.id] = slot;
let starttime = slot.startdatetime;
let timestring = gettimeofday(starttime);
return {
label: timestring,
value: slot._id
}
});
$w( "# slotpick " ).placeholder = “Pick a Time” ;
$w( "# slotpick " ).selectedIndex = undefined;
$w( "# slotpick " ).enabled;
}
}
async function validateandsubmitform() {
$w( “#errormsg” ).hide;
$w( “#submit” ).disable();
const formfields = [ “iname” , “iemail” , “datepick” , “slotpick” , “checkbox1” ];
if (formfields.every(input => $w(#${input}
).valid)) {
const slot = slotsmap[$w( “#slotpick” ).value];
const newrequest = {
name: $w( “#iname” ).value,
email: $w( “#iemail” ).value,
requestedslot: slot,
status: “PENDING”
};
await wixData.insert( “bookingappointments” , newrequest);
$w( “#group1” ).hide;
$w( “#thanksmsg” ).show;
}
else {
$w( “#errormsg” ).show;
$w( “#submit” ).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(slots => !pending.includes(slots._id));
}
async function getpendingappointments() {
return ( await wixData.query( “bookingappointments” ).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” + 1 ,
date: current
});
current = getnextmidnight(current)
}
return weekdays;
}
function gettimeofday(date) {
return date.toLocalTimeString(, {hour: “2-digit” , minute: “2-digit” }).toLowerCase();
}
here is the first problem.
and here is the second
everything seemed okay, doubled and triple checked the code, checked the input field element id’s, cant seem to determine the cause of those.
i cant get passed the form so i cant tell if there is any more problem besides those.
my wix site is not yet premium, im trying to learn corvid this is why im doing tutorials.