import type { CollectionConfig } from "payload";

export const ContactSubmissions: CollectionConfig = {
  slug: "contactSubmissions",
  access: {
    read: ({ req: { user } }) => Boolean(user),
    update: ({ req: { user } }) => Boolean(user),
    delete: ({ req: { user } }) => Boolean(user),
    create: () => true,
  },
  admin: {
    useAsTitle: "name",
    defaultColumns: ["name", "email", "status", "submittedAt"],
  },
  fields: [
    { name: "name", type: "text", required: true },
    { name: "email", type: "email", required: true },
    { name: "brief", type: "textarea", required: true },
    { name: "source", type: "text" },
    { name: "submittedAt", type: "date", defaultValue: () => new Date() },
    { name: "ipHash", type: "text" },
    {
      name: "status",
      type: "select",
      defaultValue: "new",
      options: [
        { label: "New", value: "new" },
        { label: "Replied", value: "replied" },
        { label: "Spam", value: "spam" },
      ],
    },
  ],
};
