Hello,
We are implementing the cancel booking page and would like to use the cancel-booking-form component (https://developer.nylas.com/docs/reference/ui/cancel-booking-form/).
We were able to render the element successfully; however, the cancel booking action does not trigger any request. We can see logs from the cancelBookingFormSubmitted event, but no API call is made.
When using the full flow from nylas-scheduling, we noticed that the request is triggered using the bookingRef.
Could you clarify how the cancel-booking-form is expected to trigger the cancellation request, and what we might be missing in our implementation?
Note: We are replacing the cancel link in the email confirmation with a link to our custom page.
Code Sample that we are using for testing.
<!DOCTYPE html>
<html>
<head>
<title>Cancel Booking</title>
</head>
<body>
<nylas-cancel-booking-form id="scheduler"></nylas-cancel-booking-form>
<script type="module">
import { defineCustomElement } from "https://cdn.jsdelivr.net/npm/@nylas/web-elements@2.5.4/dist/cdn/nylas-scheduling/nylas-scheduling.es.js";
defineCustomElement();
// Read booking reference from URL: /cancel?bookingRef=abc123
const params = new URLSearchParams(window.location.search);
const bookingRef = params.get("bookingRef");
const bookingId = params.get("bookingId");
const scheduler = document.getElementById("scheduler");
scheduler.configurationId = "YOUR_CONFIGURATION_ID";
scheduler.cancelBookingId = bookingId;
scheduler.schedulerApiUrl = "https://api.us.nylas.com";
// Listen for cancel events
scheduler.addEventListener("cancelBookingFormSubmitted", (event) => {
const { bookingId, action, reason } = event.detail;
console.log(`Booking ${bookingId} ${action}ed. Reason: ${reason}`);
});
scheduler.addEventListener("cancelBookedEventError", (event) => {
console.error("Cancellation error:", event.detail);
});
</script>
</body>
</html>