Files
mintel.me/apps/web/src/payload/collections/Inquiries.ts
Marc Mintel 2097b571f3
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 1m9s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🏗️ Build (push) Failing after 30m21s
Build & Deploy / 🧪 QA (push) Has been skipped
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 4s
feat(web): streamline contact form and integrate identity fields
2026-04-07 23:08:04 +02:00

99 lines
2.0 KiB
TypeScript

import type { CollectionConfig } from "payload";
import { convertInquiryEndpoint } from "../endpoints/convertInquiryEndpoint";
export const Inquiries: CollectionConfig = {
slug: "inquiries",
labels: {
singular: "Inquiry",
plural: "Inquiries",
},
admin: {
useAsTitle: "name",
defaultColumns: ["name", "email", "companyName", "createdAt"],
description: "Contact form leads and inquiries.",
},
access: {
read: ({ req: { user } }) => Boolean(user), // Admin only
create: () => true, // Everyone can submit
update: ({ req: { user } }) => Boolean(user),
delete: ({ req: { user } }) => Boolean(user),
},
endpoints: [
{
path: "/:id/convert-to-lead",
method: "post",
handler: convertInquiryEndpoint,
},
],
fields: [
{
name: "convertButton",
type: "ui",
admin: {
components: {
Field:
"@/src/payload/components/ConvertInquiryButton#ConvertInquiryButton",
},
condition: (data) => {
return !data?.processed;
},
},
},
{
name: "processed",
type: "checkbox",
defaultValue: false,
admin: {
description: "Has this inquiry been converted into a CRM Lead?",
readOnly: true,
},
},
{
name: "name",
type: "text",
required: true,
},
{
name: "email",
type: "text", // Using text for email format, or 'email' type if strictly enforced
required: true,
},
{
name: "companyName",
type: "text",
},
{
name: "phone",
type: "text",
},
{
name: "role",
type: "text",
},
{
name: "projectType",
type: "text",
},
{
name: "deadline",
type: "text",
},
{
name: "message",
type: "textarea",
},
{
name: "isFreeText",
type: "checkbox",
defaultValue: false,
},
{
name: "config",
type: "json",
admin: {
description: "The JSON data from the configurator.",
},
},
],
};