import type { CollectionConfig } from "payload";

export const users: CollectionConfig = {
  slug: "users",
  auth: true,
  admin: {
    useAsTitle: "email",
  },
  custom: {
    retention: {
      purgeSchedule: "daily",
      postDeletion: {
        duration: "P30D",
        trigger: "after-deletion",
        action: "hard-delete",
      },
    },
    subject: { kind: "self", field: "id" },
  },
  fields: [
    {
      name: "displayName",
      type: "text",
      custom: {
        pii: {
          category: "identification-username",
          purpose: ["service-delivery"],
          exportable: true,
          restrictable: true,
        },
      },
    },
    {
      name: "role",
      type: "select",
      options: [
        { label: "Admin", value: "admin" },
        { label: "Editor", value: "editor" },
        { label: "Author", value: "author" },
      ],
      defaultValue: "author",
      required: true,
    },
    {
      name: "consentState",
      type: "json",
    },
  ],
};
