Files
2026-07-08 16:15:37 +02:00

68 lines
2.4 KiB
TypeScript

// AK-P16b · pure client-safe route-path builders for the booking module. Loaders
// build these and pass them into the VMs so the VMs stay routing-agnostic (mirrors
// calendarRoutePaths). The module is feature-gated by its OWN `booking` key
// (tenantHasModule) — unlike calendar which reuses `integrations`.
/** Tenant-connector module key for the Booking feature (M06 / DoD 7). */
export const BOOKING_MODULE_KEY = "booking";
/** Reserved slugs that may not be used for a public booking page. */
export const RESERVED_BOOKING_SLUGS: ReadonlySet<string> = new Set([
"new",
"pages",
"embed",
"admin",
"api",
"settings",
]);
/** Appointments list (M06 Block C). */
export function bookingsListPath(tenantSlug: string): string {
return `/${tenantSlug}/bookings`;
}
/** A single appointment's detail (M06 Block D). */
export function bookingDetailPath(tenantSlug: string, appointmentId: string): string {
return `/${tenantSlug}/bookings/${appointmentId}`;
}
/** Booking-pages list (M06 Block E.1). */
export function bookingPagesListPath(tenantSlug: string): string {
return `/${tenantSlug}/bookings/pages`;
}
/** New booking-page editor (M06 Block E.2). */
export function bookingPageNewPath(tenantSlug: string): string {
return `/${tenantSlug}/bookings/pages/new`;
}
/** Edit an existing booking-page (M06 Block E.2). */
export function bookingPageEditPath(tenantSlug: string, bookingPageId: string): string {
return `/${tenantSlug}/bookings/pages/${bookingPageId}`;
}
/** Per-user availability editor (M06 Block F). */
export function availabilityPath(tenantSlug: string): string {
return `/${tenantSlug}/availability`;
}
/** Public booking page (M06 Block G). NOT tenant-login-scoped. */
export function publicBookingPath(tenantSlug: string, slug: string): string {
return `/b/${tenantSlug}/${slug}`;
}
/** Iframe embed variant of the public booking page (M06 Block H). */
export function publicBookingEmbedPath(tenantSlug: string, slug: string): string {
return `/b/${tenantSlug}/${slug}/embed`;
}
/** Absolute public URL (for the editor's copy-to-clipboard + iframe snippet). */
export function publicBookingUrl(origin: string, tenantSlug: string, slug: string): string {
return `${origin}${publicBookingPath(tenantSlug, slug)}`;
}
/** 404 helper (Bauprinzip A.5.3 — permission/owner miss renders 404, not 403). */
export function notFoundResponse(): Response {
return new Response("Not Found", { status: 404 });
}