Initial commit: ANOUMA website with Payload CMS, WebRTC meetings, and booking system
- Next.js 16 App Router site with the ANOUMA design system - Payload CMS (PostgreSQL) for offers, events, posts and page content - WebRTC video-call system with custom signaling server - SMTP email reminders and booking-request notifications - Customer accounts, calendar-based availability, and booking workflow
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { cache } from "react";
|
||||
import { getCMS } from "@/lib/payload/getPayload";
|
||||
import type { BookingRequest } from "@/payload-types";
|
||||
|
||||
/**
|
||||
* These are called only after the caller has already verified who the
|
||||
* current customer is (see lib/auth/customer.ts) — the `where: { user }`
|
||||
* filter below is what actually scopes results to that one customer.
|
||||
*/
|
||||
export const getCustomerBookings = cache(async (customerId: number): Promise<BookingRequest[]> => {
|
||||
const payload = await getCMS();
|
||||
const result = await payload.find({
|
||||
collection: "booking-requests",
|
||||
where: { user: { equals: customerId } },
|
||||
sort: "-date",
|
||||
depth: 2,
|
||||
limit: 200,
|
||||
});
|
||||
return result.docs;
|
||||
});
|
||||
|
||||
export async function getCustomerBookingById(customerId: number, id: number): Promise<BookingRequest | null> {
|
||||
const payload = await getCMS();
|
||||
const result = await payload.find({
|
||||
collection: "booking-requests",
|
||||
where: { and: [{ id: { equals: id } }, { user: { equals: customerId } }] },
|
||||
depth: 2,
|
||||
limit: 1,
|
||||
});
|
||||
return result.docs[0] ?? null;
|
||||
}
|
||||
Reference in New Issue
Block a user