1
0
Fork 0
polaris-task-force/src/collections/game/LaborClassifications.ts
2026-09-20 02:43:23 -04:00

78 lines
2 KiB
TypeScript

import { CollectionConfig } from "payload";
import hasRoles from "@/utils/access-control/hasRoles";
export const LaborClassifications: CollectionConfig = {
slug: "labor-classifications",
admin: {
group: "Game",
useAsTitle: "name",
defaultColumns: ["name", "key", "defaultUnitSalary", "availableHeadcount"],
listSearchableFields: ["name", "key"],
},
access: {
read: ({ req }) => Boolean(req.user),
create: ({ req }) => hasRoles(["admin", "developer"], req.user),
update: ({ req }) => hasRoles(["admin", "developer"], req.user),
delete: ({ req }) => hasRoles(["admin", "developer"], req.user),
},
fields: [
{
name: "name",
type: "text",
required: true,
unique: true,
index: true,
label: "Name",
admin: {
description: "Display label for this labor trade (e.g. Mechanic).",
},
},
{
name: "key",
type: "text",
required: true,
unique: true,
index: true,
label: "Key",
admin: {
description: "Stable slug used to identify this classification (e.g. mechanic).",
},
},
{
name: "defaultUnitSalary",
type: "number",
min: 0,
label: "Default unit salary",
admin: {
description: "Prefills the wage-per-worker input in the hire dialog.",
},
},
{
name: "description",
type: "textarea",
label: "Description",
},
{
name: "buildEfficiency",
type: "number",
min: 0,
defaultValue: 1,
label: "Build efficiency",
admin: {
description:
"Construction speed this trade contributes per worker while building structures (1 = a full worker).",
},
},
{
name: "availableHeadcount",
type: "number",
min: 0,
defaultValue: 0,
label: "Available headcount",
admin: {
description:
"How many workers of this classification are currently available to hire across the unit. Hiring consumes from this pool; releasing staff returns them.",
},
},
],
};