Custom Appointment Booking Scenario from Booking Forms

Question:
Is there something i’ve missed in my code?

Product:
Wix Bookings

What are you trying to achieve:
Choirs For Good run choirs that we’d like to be booked for events etc. I’m trying to use Wix appointments to help me with this. But I need to custom code it as timings and addresses for each event will differ (rather than picking pre-defined slots). I have started with the below code from a form input, but dont seem to be getting any results. Am I missing something?

What have you already tried:
[Share resources, forum topics, articles, or tutorials you’ve already used to try and answer your question.]

Additional information:

// import wixData from “@wix/data”;
// import { bookings,services } from ‘wix-bookings.v2’;
import { bookings, services, availabilityCalendar } from “@wix/bookings”;

const createBooking = async (choirSlug, contactDetails, date, startTime, endTime) => {
const availableServices = await services.queryServices({ “type”: “APPOINTMENT” }).eq(‘mainSlug.name’, choirSlug).find()
const service = availableServices.items[0]
const startDate = new Date(date.toString().replace(‘00:00:00’, startTime))
const endDate = new Date(date.toString().replace(‘00:00:00’, endTime))

console.log({ date, startTime, endTime, startDate, endDate })

const query = {
    filter: {
        serviceId: service._id,
        startDate,
        endDate,

    },
}

const availableSlots = await availabilityCalendar.queryAvailability(query)

console.log({ availableServices })
console.log({ availableSlots })

const firstSlot = availableSlots.availabilityEntries && availableSlots.availabilityEntries.length ? availableSlots.availabilityEntries[0].slot : null

if (!firstSlot) {
    return
}

const booking = await bookings.createBooking({
    contactDetails,
    startDate,
    endDate,
    bookedEntity: {
        slot: firstSlot,
    },
    totalParticipants: 1,
    


    
});

console.log({ booking });

}

$w.onReady(function () {
// Set up event handler for form submission

$w('#bookachoir').onWixFormSubmit(async () => {
    try {
        const startDate = $w('#eventdateinput').value
        const choirSlug = $w('#dropdown1').value
        const startTime = $w('#timefrominput').value
        const endTime = $w('#timetillinput').value

        const contactDetails = {
            firstName: $w('#firstnameinput').value,
            lastName: $w('#lastnameinput').value,
            emails: [$w('#emailinput').value],
            phones: [$w('#phoneinput').value],
        }

        await createBooking(choirSlug, contactDetails, startDate, startTime, endTime)
    } catch (e) {
        console.log(e)
    }

    return true
});

});