- 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
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import type { CollectionConfig } from "payload";
|
|
|
|
const isSelfOrAdmin = ({ req }: { req: { user?: { collection?: string; id?: unknown } | null } }) => {
|
|
const user = req.user;
|
|
if (!user) return false;
|
|
if (user.collection === "users") return true;
|
|
if (user.collection === "customers") return { id: { equals: user.id } };
|
|
return false;
|
|
};
|
|
|
|
export const Customers: CollectionConfig = {
|
|
slug: "customers",
|
|
labels: {
|
|
singular: "Kundin/Kunde",
|
|
plural: "Kund:innen",
|
|
},
|
|
admin: {
|
|
useAsTitle: "name",
|
|
defaultColumns: ["name", "email", "phone"],
|
|
group: "Buchungen",
|
|
description: "Konten der Website-Besucher:innen (nicht die Admin-Zugänge unter „Benutzer:innen“).",
|
|
},
|
|
auth: {
|
|
maxLoginAttempts: 8,
|
|
lockTime: 10 * 60 * 1000,
|
|
},
|
|
access: {
|
|
// Anyone can create their own account (registration); reading/updating
|
|
// is restricted to the account owner or an admin.
|
|
create: () => true,
|
|
read: isSelfOrAdmin,
|
|
update: isSelfOrAdmin,
|
|
delete: ({ req }) => req.user?.collection === "users",
|
|
},
|
|
fields: [
|
|
{
|
|
name: "name",
|
|
type: "text",
|
|
label: "Name",
|
|
required: true,
|
|
},
|
|
{
|
|
name: "phone",
|
|
type: "text",
|
|
label: "Telefonnummer",
|
|
required: false,
|
|
admin: {
|
|
description: "Optional — für eine spätere Nutzung vorbereitet, aktuell nicht verpflichtend.",
|
|
},
|
|
},
|
|
// "email" and "password" are added automatically by the auth config.
|
|
],
|
|
};
|