26 lines
975 B
TypeScript
26 lines
975 B
TypeScript
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>;
|