feat: implement Project Management with Gantt Chart, Milestones, and CRM enhancements

This commit is contained in:
2026-03-01 00:26:59 +01:00
parent 4b5609a75e
commit 6444cf1e81
47 changed files with 15312 additions and 7373 deletions

View File

@@ -1,4 +1,5 @@
import type { CollectionConfig } from "payload";
import { aiEndpointHandler } from "../endpoints/aiEndpoint";
export const CrmAccounts: CollectionConfig = {
slug: "crm-accounts",
@@ -10,7 +11,16 @@ export const CrmAccounts: CollectionConfig = {
useAsTitle: "name",
defaultColumns: ["name", "status", "leadTemperature", "updatedAt"],
group: "CRM",
description:
"Accounts represent companies or organizations. They are the central hub linking Contacts and Interactions together. Use this to track the overall relationship status.",
},
endpoints: [
{
path: "/:id/analyze",
method: "post",
handler: aiEndpointHandler,
},
],
access: {
read: ({ req: { user } }) => Boolean(user), // Admin only
create: ({ req: { user } }) => Boolean(user),
@@ -23,7 +33,7 @@ export const CrmAccounts: CollectionConfig = {
type: "ui",
admin: {
components: {
Field: "/src/payload/components/AiAnalyzeButton#AiAnalyzeButton",
Field: "@/src/payload/components/AiAnalyzeButton#AiAnalyzeButton",
},
},
},
@@ -31,14 +41,20 @@ export const CrmAccounts: CollectionConfig = {
name: "name",
type: "text",
required: true,
label: "Company / Account Name",
label: "Company / Project Name",
admin: {
description:
"Enter the official name of the business or the research project name.",
},
},
{
name: "website",
type: "text",
label: "Website URL",
admin: {
description: "The website of the account, useful for AI analysis.",
description:
"The main website of the account. Required for triggering the AI Website Analysis.",
placeholder: "https://example.com",
},
},
{
@@ -48,29 +64,31 @@ export const CrmAccounts: CollectionConfig = {
name: "status",
type: "select",
options: [
{ label: "Lead", value: "lead" },
{ label: "Client", value: "client" },
{ label: "Lost", value: "lost" },
{ label: "Lead (Prospect)", value: "lead" },
{ label: "Active Client", value: "client" },
{ label: "Business Partner", value: "partner" },
{ label: "Lost / Archive", value: "lost" },
],
defaultValue: "lead",
admin: {
width: "50%",
description: "Change from Lead to Client upon conversion.",
description: "Current lifecycle stage of this business relation.",
},
},
{
name: "leadTemperature",
type: "select",
options: [
{ label: "Cold", value: "cold" },
{ label: "Warm", value: "warm" },
{ label: "Hot", value: "hot" },
{ label: "❄️ Cold (New Research)", value: "cold" },
{ label: "🔥 Warm (In Contact)", value: "warm" },
{ label: "Hot (Negotiation / Quote)", value: "hot" },
],
admin: {
condition: (data) => {
return data?.status === "lead";
},
width: "50%",
description: "Indicates how likely this lead is to convert soon.",
},
},
],
@@ -79,7 +97,10 @@ export const CrmAccounts: CollectionConfig = {
name: "assignedTo",
type: "relationship",
relationTo: "users",
label: "Assigned To (User)",
label: "Account Manager (User)",
admin: {
description: "The internal team member responsible for this account.",
},
},
{
name: "reports",
@@ -89,7 +110,45 @@ export const CrmAccounts: CollectionConfig = {
label: "AI Reports & Documents",
admin: {
description:
"PDFs and strategy documents generated by AI or attached manually.",
"All generated PDF estimates and strategy documents appear here.",
},
},
{
name: "topics",
type: "join",
collection: "crm-topics",
on: "account",
admin: {
description:
"Projects, deals, or specific topics active for this client.",
},
},
{
name: "contacts",
type: "join",
collection: "crm-contacts",
on: "account",
admin: {
description: "All contacts associated with this account.",
},
},
{
name: "interactions",
type: "join",
collection: "crm-interactions",
on: "account",
admin: {
description:
"Timeline of all communication logged against this account.",
},
},
{
name: "projects",
type: "join",
collection: "projects",
on: "account",
admin: {
description: "All high-level projects associated with this account.",
},
},
],