import { CollectionConfig } from "payload"; import { requirePermission } from "@/utils/access-control/hasPermission"; export const NarrativeEvents: CollectionConfig = { slug: "narrative-events", admin: { group: "World", useAsTitle: "name", }, access: { create: requirePermission("narrative-events:create"), update: requirePermission("narrative-events:update"), delete: requirePermission("narrative-events:delete"), read: requirePermission("narrative-events:read"), }, fields: [ { name: "name", type: "text", required: true, admin: { description: "The title of this narrative event chain.", }, }, { name: "summary", type: "textarea", required: true, admin: { description: "A brief summary of what this event is about.", }, }, { type: "tabs", tabs: [ { label: "Flow Editor", description: "Build the narrative flowchart by adding beats, choices, and outcomes.", fields: [ { name: "flowData", type: "json", required: true, defaultValue: () => ({ nodes: [], edges: [], }), admin: { components: { Field: "@/components/admin/narrative-flow/NarrativeFlowEditor", }, }, }, ], }, { label: "Event Configuration", description: "Configure trigger conditions and other metadata.", fields: [ { name: "triggers", type: "group", fields: [ { name: "type", type: "select", options: [ { label: "Manual", value: "manual" }, { label: "On Mission Complete", value: "mission_complete" }, { label: "On Timer", value: "timer" }, { label: "On Condition", value: "condition" }, ], defaultValue: "manual", }, { name: "condition", type: "json", admin: { description: "Optional JSON conditions for when this event can fire.", }, }, ], }, ], }, ], }, ], };