import type { CollectionConfig } from "payload";

export const Users: CollectionConfig = {
  slug: "users",
  admin: {
    useAsTitle: "email",
    defaultColumns: ["email", "role"],
    group: "System",
  },
  auth: true,
  fields: [
    {
      name: "role",
      type: "select",
      defaultValue: "admin",
      options: [{ label: "Admin", value: "admin" }],
      access: {
        update: ({ req: { user } }) => user?.role === "admin",
      },
    },
  ],
};
