const { slots } = await getAvailabilityForReschedule( confirmationNumber, contactInfo, { start: nextWeekStart, end: nextWeekEnd });// Show only available slots to customerconst selectedSlot = await showSlotPicker(slots);// Reschedule to verified slotawait rescheduleBooking(confirmationNumber, contactInfo, selectedSlot);
2. Handle Conflicts
The slot might be taken between selection and submission:
Copy
try { await rescheduleBooking(confirmationNumber, contactInfo, newTime);} catch (error) { if (error.status === 409) { // Refresh availability const { slots } = await getAvailabilityForReschedule(...); showError('That time was just booked. Please select another.'); showSlotPicker(slots); }}
3. Send Updated Confirmation
Always notify the customer of the change:
Copy
const { booking } = await rescheduleBooking(...);await sendEmail({ to: booking.contact.email, subject: 'Booking Rescheduled', body: ` Your appointment has been rescheduled. NEW DATE: ${formatDate(booking.start_at)} NEW TIME: ${formatTime(booking.start_at)} Confirmation #: ${booking.confirmation_number} Service: ${booking.service_name} Location: ${booking.location.value} `});
4. Keep Same Duration
Ensure the new time slot has the same duration:
Copy
// Calculate original durationconst original = await lookupBooking(confirmationNumber, contactInfo);const duration = new Date(original.booking.end_at) - new Date(original.booking.start_at);// Apply same duration to new startconst newStart = new Date(selectedSlot.startsAt);const newEnd = new Date(newStart.getTime() + duration);await rescheduleBooking(confirmationNumber, contactInfo, { startsAt: newStart.toISOString(), endsAt: newEnd.toISOString()});