fix: harden booking and meeting flows
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import type { BookingRequest } from "@/payload-types";
|
||||
|
||||
/** Explicit allow-list at the server/client boundary, including relationships. */
|
||||
export function customerBookingView(booking: BookingRequest) {
|
||||
const offer = typeof booking.offer === "object" ? booking.offer : null;
|
||||
const event = typeof booking.linkedEvent === "object" ? booking.linkedEvent : null;
|
||||
const alternative = booking.proposedAlternative;
|
||||
return {
|
||||
id: booking.id,
|
||||
date: booking.date,
|
||||
startTime: booking.startTime,
|
||||
endTime: booking.endTime,
|
||||
status: booking.status,
|
||||
appointmentType: booking.appointmentType,
|
||||
offer: offer ? { title: offer.title } : null,
|
||||
linkedEvent: event ? { slug: event.slug, isOnline: event.isOnline } : null,
|
||||
proposedAlternative: alternative ? {
|
||||
date: alternative.date,
|
||||
startTime: alternative.startTime,
|
||||
endTime: alternative.endTime,
|
||||
} : null,
|
||||
};
|
||||
}
|
||||
|
||||
export type CustomerBooking = ReturnType<typeof customerBookingView>;
|
||||
Reference in New Issue
Block a user