@fayz-ai/plugin-crm 0.2.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/CrmPage.d.ts.map +1 -1
- package/dist/data/supabase.d.ts.map +1 -1
- package/dist/data/tables.d.ts +10 -0
- package/dist/data/tables.d.ts.map +1 -0
- package/dist/index.cjs +176 -153
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +96 -73
- package/dist/index.js.map +1 -1
- package/dist/migrations/index.d.ts +10 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/registries.d.ts.map +1 -1
- package/dist/schema/index.d.ts +65 -65
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema.cjs +23 -23
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.js +24 -24
- package/dist/schema.js.map +1 -1
- package/package.json +8 -5
- package/src/CrmPage.tsx +0 -2
- package/src/data/supabase.ts +30 -27
- package/src/data/tables.ts +11 -0
- package/src/index.ts +15 -11
- package/src/migrations/000_plg_rename.sql +28 -0
- package/src/migrations/001_crm_base.sql +32 -32
- package/src/migrations/002_activities.sql +14 -14
- package/src/migrations/003_crm_views_rls.sql +8 -8
- package/src/migrations/004_seed_default_pipeline.sql +5 -5
- package/src/migrations/index.ts +247 -0
- package/src/registries.ts +45 -4
- package/src/schema/index.ts +25 -25
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React14 = require('react');
|
|
4
|
+
var saas = require('@fayz-ai/saas');
|
|
4
5
|
var core = require('@fayz-ai/core');
|
|
5
6
|
var ui = require('@fayz-ai/ui');
|
|
6
|
-
var saas = require('@fayz-ai/saas');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
8
|
var lucideReact = require('lucide-react');
|
|
9
9
|
var reactDom = require('react-dom');
|
|
@@ -11,7 +11,7 @@ var vanilla = require('zustand/vanilla');
|
|
|
11
11
|
|
|
12
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var React14__default = /*#__PURE__*/_interopDefault(React14);
|
|
15
15
|
|
|
16
16
|
// src/index.ts
|
|
17
17
|
var ctx = saas.createPluginContext("CrmPage");
|
|
@@ -60,37 +60,6 @@ function CrmGeneralSettings() {
|
|
|
60
60
|
] })
|
|
61
61
|
] });
|
|
62
62
|
}
|
|
63
|
-
function PipelineSettings() {
|
|
64
|
-
const t2 = core.useTranslation();
|
|
65
|
-
const stages = useCrmStore((s) => s.stages);
|
|
66
|
-
useCrmStore((s) => s.pipelines);
|
|
67
|
-
const fetchPipelines = useCrmStore((s) => s.fetchPipelines);
|
|
68
|
-
React15.useEffect(() => {
|
|
69
|
-
fetchPipelines();
|
|
70
|
-
}, []);
|
|
71
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
72
|
-
/* @__PURE__ */ jsxRuntime.jsx(saas.SettingsGroup, { title: t2("crm.pipelineSettings.title"), description: t2("crm.pipelineSettings.description"), children: stages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-6 text-center text-sm text-muted-foreground", children: t2("common.loading") }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-0", children: stages.map((stage, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 py-3", children: [
|
|
73
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground w-5 shrink-0", children: i + 1 }),
|
|
74
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-3 w-3 rounded-full shrink-0", style: { backgroundColor: stage.color } }),
|
|
75
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
76
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: stage.name }),
|
|
77
|
-
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-[10px] text-muted-foreground", children: [
|
|
78
|
-
t2("crm.pipelineSettings.probability"),
|
|
79
|
-
": ",
|
|
80
|
-
stage.probability,
|
|
81
|
-
"%",
|
|
82
|
-
stage.isWon && ` \u2014 ${t2("crm.pipelineSettings.winStage")}`,
|
|
83
|
-
stage.isLost && ` \u2014 ${t2("crm.pipelineSettings.lossStage")}`
|
|
84
|
-
] })
|
|
85
|
-
] }),
|
|
86
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground", children: [
|
|
87
|
-
stage.probability,
|
|
88
|
-
"%"
|
|
89
|
-
] })
|
|
90
|
-
] }, stage.id)) }) }),
|
|
91
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[10px] text-muted-foreground px-1", children: t2("crm.pipelineSettings.customizationNote") })
|
|
92
|
-
] });
|
|
93
|
-
}
|
|
94
63
|
var STEPS = [
|
|
95
64
|
{ id: "welcome", icon: lucideReact.Filter, titleKey: "crm.onboarding.welcome", descKey: "crm.onboarding.description" },
|
|
96
65
|
{ id: "sources", icon: lucideReact.Globe, titleKey: "crm.onboarding.sources.title", descKey: "crm.onboarding.sources.description" },
|
|
@@ -98,7 +67,7 @@ var STEPS = [
|
|
|
98
67
|
];
|
|
99
68
|
function CrmOnboarding({ onComplete }) {
|
|
100
69
|
const t2 = core.useTranslation();
|
|
101
|
-
const [step, setStep] =
|
|
70
|
+
const [step, setStep] = React14.useState(0);
|
|
102
71
|
const current = STEPS[step];
|
|
103
72
|
const isLast = step === STEPS.length - 1;
|
|
104
73
|
const Icon = current.icon;
|
|
@@ -144,7 +113,7 @@ var TRANSITIONS = {
|
|
|
144
113
|
expired: []
|
|
145
114
|
};
|
|
146
115
|
function RejectModal({ onConfirm, onCancel }) {
|
|
147
|
-
const [reason, setReason] =
|
|
116
|
+
const [reason, setReason] = React14.useState("");
|
|
148
117
|
return reactDom.createPortal(
|
|
149
118
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed inset-0 z-[60] flex items-center justify-center bg-black/50", onClick: onCancel, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
150
119
|
"div",
|
|
@@ -183,9 +152,9 @@ function QuoteStatusDropdown({ quote, onStatusChange, size = "default" }) {
|
|
|
183
152
|
const approveQuote = useCrmStore((s) => s.approveQuote);
|
|
184
153
|
const rejectQuote = useCrmStore((s) => s.rejectQuote);
|
|
185
154
|
const expireQuote = useCrmStore((s) => s.expireQuote);
|
|
186
|
-
const [loading, setLoading] =
|
|
187
|
-
const [showApprove, setShowApprove] =
|
|
188
|
-
const [showReject, setShowReject] =
|
|
155
|
+
const [loading, setLoading] = React14.useState(false);
|
|
156
|
+
const [showApprove, setShowApprove] = React14.useState(false);
|
|
157
|
+
const [showReject, setShowReject] = React14.useState(false);
|
|
189
158
|
const config = STATUS_CONFIG[quote.status] ?? STATUS_CONFIG.draft;
|
|
190
159
|
const StatusIcon = config.icon;
|
|
191
160
|
const transitions = TRANSITIONS[quote.status] ?? [];
|
|
@@ -488,15 +457,15 @@ function DealSidebar({ dealId, open, onClose, onViewLead, onViewQuote }) {
|
|
|
488
457
|
const t2 = core.useTranslation();
|
|
489
458
|
const provider = useCrmProvider();
|
|
490
459
|
const { currency } = useCrmConfig();
|
|
491
|
-
const [deal, setDeal] =
|
|
492
|
-
const [lead, setLead] =
|
|
493
|
-
const [activities, setActivities] =
|
|
494
|
-
const [quotes, setQuotes] =
|
|
495
|
-
const [loading, setLoading] =
|
|
496
|
-
const [activitiesLoading, setActivitiesLoading] =
|
|
497
|
-
const [quotesLoading, setQuotesLoading] =
|
|
498
|
-
const [activeTab, setActiveTab] =
|
|
499
|
-
|
|
460
|
+
const [deal, setDeal] = React14.useState(null);
|
|
461
|
+
const [lead, setLead] = React14.useState(null);
|
|
462
|
+
const [activities, setActivities] = React14.useState([]);
|
|
463
|
+
const [quotes, setQuotes] = React14.useState([]);
|
|
464
|
+
const [loading, setLoading] = React14.useState(true);
|
|
465
|
+
const [activitiesLoading, setActivitiesLoading] = React14.useState(true);
|
|
466
|
+
const [quotesLoading, setQuotesLoading] = React14.useState(true);
|
|
467
|
+
const [activeTab, setActiveTab] = React14.useState("overview");
|
|
468
|
+
React14.useEffect(() => {
|
|
500
469
|
if (!open) return;
|
|
501
470
|
setLoading(true);
|
|
502
471
|
setActivitiesLoading(true);
|
|
@@ -623,7 +592,7 @@ function DealCard({ deal, saving, currency, onClick, onDragStart, onDragEnd }) {
|
|
|
623
592
|
function StageColumn({ stageId, stageName, stageColor, deals, savingDealIds, currency, dragOverStageId, onDealClick, onAddLead, onDragStart, onDragEnd, onDragOver, onDragLeave, onDrop }) {
|
|
624
593
|
const t2 = core.useTranslation();
|
|
625
594
|
const isOver = dragOverStageId === stageId;
|
|
626
|
-
const [hovered, setHovered] =
|
|
595
|
+
const [hovered, setHovered] = React14.useState(false);
|
|
627
596
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
628
597
|
"div",
|
|
629
598
|
{
|
|
@@ -687,19 +656,19 @@ function PipelineView({ onDealClick, onViewLead, onViewQuote, onAddLead }) {
|
|
|
687
656
|
const fetchPipelines = useCrmStore((s) => s.fetchPipelines);
|
|
688
657
|
const fetchDealsByStage = useCrmStore((s) => s.fetchDealsByStage);
|
|
689
658
|
const moveDealToStage = useCrmStore((s) => s.moveDealToStage);
|
|
690
|
-
const [dragOverStageId, setDragOverStageId] =
|
|
691
|
-
const [savingDealIds, setSavingDealIds] =
|
|
692
|
-
const [optimisticBoard, setOptimisticBoard] =
|
|
659
|
+
const [dragOverStageId, setDragOverStageId] = React14.useState(null);
|
|
660
|
+
const [savingDealIds, setSavingDealIds] = React14.useState(/* @__PURE__ */ new Set());
|
|
661
|
+
const [optimisticBoard, setOptimisticBoard] = React14.useState(null);
|
|
693
662
|
const t2 = core.useTranslation();
|
|
694
|
-
const [selectedDealId, setSelectedDealId] =
|
|
695
|
-
const dragRef =
|
|
696
|
-
|
|
663
|
+
const [selectedDealId, setSelectedDealId] = React14.useState(null);
|
|
664
|
+
const dragRef = React14.useRef(null);
|
|
665
|
+
React14.useEffect(() => {
|
|
697
666
|
fetchPipelines();
|
|
698
667
|
}, []);
|
|
699
|
-
|
|
668
|
+
React14.useEffect(() => {
|
|
700
669
|
if (pipelines.length > 0) fetchDealsByStage(pipelines[0].id);
|
|
701
670
|
}, [pipelines]);
|
|
702
|
-
|
|
671
|
+
React14.useEffect(() => {
|
|
703
672
|
if (savingDealIds.size === 0) setOptimisticBoard(null);
|
|
704
673
|
}, [dealsByStage, savingDealIds]);
|
|
705
674
|
const visibleStages = stages.filter((s) => !s.isLost);
|
|
@@ -830,12 +799,12 @@ function LeadListView({ onNew, onEdit }) {
|
|
|
830
799
|
const leads = useCrmStore((s) => s.leads);
|
|
831
800
|
const leadsLoading = useCrmStore((s) => s.leadsLoading);
|
|
832
801
|
const fetchLeads = useCrmStore((s) => s.fetchLeads);
|
|
833
|
-
const [search, setSearch] =
|
|
834
|
-
const [statusFilter, setStatusFilter] =
|
|
835
|
-
|
|
802
|
+
const [search, setSearch] = React14.useState("");
|
|
803
|
+
const [statusFilter, setStatusFilter] = React14.useState([]);
|
|
804
|
+
React14.useEffect(() => {
|
|
836
805
|
fetchLeads({ status: statusFilter.length > 0 ? statusFilter : void 0, search: search || void 0 });
|
|
837
806
|
}, [statusFilter, search]);
|
|
838
|
-
const tags =
|
|
807
|
+
const tags = React14.useMemo(() => STATUS_OPTIONS.map((o) => ({ value: o.value, label: o.label })), []);
|
|
839
808
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
840
809
|
/* @__PURE__ */ jsxRuntime.jsx(ui.SubpageHeader, { title: t2("crm.leads.title"), subtitle: `${leads.length} leads` }),
|
|
841
810
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -867,15 +836,15 @@ function LeadFormView({ onSaved }) {
|
|
|
867
836
|
const createLead = useCrmStore((s) => s.createLead);
|
|
868
837
|
const fetchPipelines = useCrmStore((s) => s.fetchPipelines);
|
|
869
838
|
const pipelines = useCrmStore((s) => s.pipelines);
|
|
870
|
-
|
|
839
|
+
React14.useEffect(() => {
|
|
871
840
|
if (pipelines.length === 0) fetchPipelines();
|
|
872
841
|
}, []);
|
|
873
|
-
const [name, setName] =
|
|
874
|
-
const [email, setEmail] =
|
|
875
|
-
const [phone, setPhone] =
|
|
876
|
-
const [company, setCompany] =
|
|
877
|
-
const [notes, setNotes] =
|
|
878
|
-
const [saving, setSaving] =
|
|
842
|
+
const [name, setName] = React14.useState("");
|
|
843
|
+
const [email, setEmail] = React14.useState("");
|
|
844
|
+
const [phone, setPhone] = React14.useState("");
|
|
845
|
+
const [company, setCompany] = React14.useState("");
|
|
846
|
+
const [notes, setNotes] = React14.useState("");
|
|
847
|
+
const [saving, setSaving] = React14.useState(false);
|
|
879
848
|
async function handleSave() {
|
|
880
849
|
if (!name.trim()) {
|
|
881
850
|
ui.toast.error(t2("common.formIncomplete"));
|
|
@@ -987,7 +956,7 @@ function QuoteListView({ onNew, onEdit, onEditQuote }) {
|
|
|
987
956
|
const quotes = useCrmStore((s) => s.quotes);
|
|
988
957
|
const quotesLoading = useCrmStore((s) => s.quotesLoading);
|
|
989
958
|
const fetchQuotes = useCrmStore((s) => s.fetchQuotes);
|
|
990
|
-
|
|
959
|
+
React14.useEffect(() => {
|
|
991
960
|
fetchQuotes({});
|
|
992
961
|
}, []);
|
|
993
962
|
const columns2 = useQuoteColumns(currency, onEditQuote);
|
|
@@ -1134,26 +1103,26 @@ function QuoteFormView({ quoteId, leadId, onSaved }) {
|
|
|
1134
1103
|
const createQuote = useCrmStore((s) => s.createQuote);
|
|
1135
1104
|
const updateQuote = useCrmStore((s) => s.updateQuote);
|
|
1136
1105
|
const isEdit = !!quoteId;
|
|
1137
|
-
const [loadingExisting, setLoadingExisting] =
|
|
1138
|
-
const [linkedLeadId, setLinkedLeadId] =
|
|
1139
|
-
const [linkedDealId, setLinkedDealId] =
|
|
1140
|
-
const [contactName, setContactName] =
|
|
1141
|
-
const [contactId, setContactId] =
|
|
1142
|
-
const [quoteDate, setQuoteDate] =
|
|
1143
|
-
const [validUntil, setValidUntil] =
|
|
1106
|
+
const [loadingExisting, setLoadingExisting] = React14.useState(isEdit || !!leadId);
|
|
1107
|
+
const [linkedLeadId, setLinkedLeadId] = React14.useState(leadId ?? "");
|
|
1108
|
+
const [linkedDealId, setLinkedDealId] = React14.useState("");
|
|
1109
|
+
const [contactName, setContactName] = React14.useState("");
|
|
1110
|
+
const [contactId, setContactId] = React14.useState("");
|
|
1111
|
+
const [quoteDate, setQuoteDate] = React14.useState((/* @__PURE__ */ new Date()).toISOString().slice(0, 10));
|
|
1112
|
+
const [validUntil, setValidUntil] = React14.useState(() => {
|
|
1144
1113
|
const d = /* @__PURE__ */ new Date();
|
|
1145
1114
|
d.setDate(d.getDate() + 30);
|
|
1146
1115
|
return d.toISOString().slice(0, 10);
|
|
1147
1116
|
});
|
|
1148
|
-
const [currentStatus, setCurrentStatus] =
|
|
1149
|
-
const [paymentConditions, setPaymentConditions] =
|
|
1150
|
-
const [observations, setObservations] =
|
|
1151
|
-
const [items, setItems] =
|
|
1152
|
-
const [expandedItemId, setExpandedItemId] =
|
|
1153
|
-
const [discountVisible, setDiscountVisible] =
|
|
1154
|
-
const [addingItem, setAddingItem] =
|
|
1155
|
-
const [saving, setSaving] =
|
|
1156
|
-
|
|
1117
|
+
const [currentStatus, setCurrentStatus] = React14.useState("draft");
|
|
1118
|
+
const [paymentConditions, setPaymentConditions] = React14.useState("");
|
|
1119
|
+
const [observations, setObservations] = React14.useState("");
|
|
1120
|
+
const [items, setItems] = React14.useState([]);
|
|
1121
|
+
const [expandedItemId, setExpandedItemId] = React14.useState(null);
|
|
1122
|
+
const [discountVisible, setDiscountVisible] = React14.useState(/* @__PURE__ */ new Set());
|
|
1123
|
+
const [addingItem, setAddingItem] = React14.useState(false);
|
|
1124
|
+
const [saving, setSaving] = React14.useState(false);
|
|
1125
|
+
React14.useEffect(() => {
|
|
1157
1126
|
if (!quoteId) return;
|
|
1158
1127
|
provider.getQuoteById(quoteId).then((q) => {
|
|
1159
1128
|
if (q) {
|
|
@@ -1179,7 +1148,7 @@ function QuoteFormView({ quoteId, leadId, onSaved }) {
|
|
|
1179
1148
|
setLoadingExisting(false);
|
|
1180
1149
|
});
|
|
1181
1150
|
}, [quoteId]);
|
|
1182
|
-
|
|
1151
|
+
React14.useEffect(() => {
|
|
1183
1152
|
if (!leadId || quoteId) return;
|
|
1184
1153
|
provider.getLeadById(leadId).then(async (lead) => {
|
|
1185
1154
|
if (lead) {
|
|
@@ -1254,8 +1223,8 @@ function QuoteFormView({ quoteId, leadId, onSaved }) {
|
|
|
1254
1223
|
observations,
|
|
1255
1224
|
items: items.map((it) => ({ itemKind: it.itemKind, description: it.description, quantity: it.quantity, unitPrice: it.unitPrice, discount: it.discount }))
|
|
1256
1225
|
};
|
|
1257
|
-
const snapshot =
|
|
1258
|
-
|
|
1226
|
+
const snapshot = React14__default.default.useRef(null);
|
|
1227
|
+
React14.useEffect(() => {
|
|
1259
1228
|
if (!loadingExisting && snapshot.current === null) snapshot.current = JSON.stringify(currentFields);
|
|
1260
1229
|
}, [loadingExisting]);
|
|
1261
1230
|
const dirty = snapshot.current !== null && JSON.stringify(currentFields) !== snapshot.current;
|
|
@@ -1402,23 +1371,23 @@ function QuoteDetailView({ quoteId, onBack, onEdit, onInvoiceCreated }) {
|
|
|
1402
1371
|
const sendQuote = useCrmStore((s) => s.sendQuote);
|
|
1403
1372
|
const approveQuote = useCrmStore((s) => s.approveQuote);
|
|
1404
1373
|
const rejectQuote = useCrmStore((s) => s.rejectQuote);
|
|
1405
|
-
const [quote, setQuote] =
|
|
1406
|
-
const [loading, setLoading] =
|
|
1407
|
-
const [sendMenuOpen, setSendMenuOpen] =
|
|
1408
|
-
const [sending, setSending] =
|
|
1409
|
-
const [approving, setApproving] =
|
|
1410
|
-
const [rejectOpen, setRejectOpen] =
|
|
1411
|
-
const [rejectReason, setRejectReason] =
|
|
1412
|
-
const [rejecting, setRejecting] =
|
|
1413
|
-
const sendMenuRef =
|
|
1414
|
-
|
|
1374
|
+
const [quote, setQuote] = React14.useState(null);
|
|
1375
|
+
const [loading, setLoading] = React14.useState(true);
|
|
1376
|
+
const [sendMenuOpen, setSendMenuOpen] = React14.useState(false);
|
|
1377
|
+
const [sending, setSending] = React14.useState(false);
|
|
1378
|
+
const [approving, setApproving] = React14.useState(false);
|
|
1379
|
+
const [rejectOpen, setRejectOpen] = React14.useState(false);
|
|
1380
|
+
const [rejectReason, setRejectReason] = React14.useState("");
|
|
1381
|
+
const [rejecting, setRejecting] = React14.useState(false);
|
|
1382
|
+
const sendMenuRef = React14.useRef(null);
|
|
1383
|
+
React14.useEffect(() => {
|
|
1415
1384
|
setLoading(true);
|
|
1416
1385
|
provider.getQuoteById(quoteId).then((q) => {
|
|
1417
1386
|
setQuote(q);
|
|
1418
1387
|
setLoading(false);
|
|
1419
1388
|
});
|
|
1420
1389
|
}, [quoteId]);
|
|
1421
|
-
|
|
1390
|
+
React14.useEffect(() => {
|
|
1422
1391
|
if (!sendMenuOpen) return;
|
|
1423
1392
|
const h = (e) => {
|
|
1424
1393
|
if (sendMenuRef.current && !sendMenuRef.current.contains(e.target)) setSendMenuOpen(false);
|
|
@@ -1764,11 +1733,11 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
|
|
|
1764
1733
|
const provider = useCrmProvider();
|
|
1765
1734
|
const { currency } = useCrmConfig();
|
|
1766
1735
|
const t2 = core.useTranslation();
|
|
1767
|
-
const [lead, setLead] =
|
|
1768
|
-
const [deal, setDeal] =
|
|
1769
|
-
const [quotes, setQuotes] =
|
|
1770
|
-
const [loading, setLoading] =
|
|
1771
|
-
|
|
1736
|
+
const [lead, setLead] = React14.useState(null);
|
|
1737
|
+
const [deal, setDeal] = React14.useState(null);
|
|
1738
|
+
const [quotes, setQuotes] = React14.useState([]);
|
|
1739
|
+
const [loading, setLoading] = React14.useState(true);
|
|
1740
|
+
React14.useEffect(() => {
|
|
1772
1741
|
setLoading(true);
|
|
1773
1742
|
provider.getLeadById(leadId).then(async (l) => {
|
|
1774
1743
|
setLead(l);
|
|
@@ -1932,9 +1901,9 @@ function ActivityListView() {
|
|
|
1932
1901
|
const activities = useCrmStore((s) => s.activities);
|
|
1933
1902
|
const activitiesLoading = useCrmStore((s) => s.activitiesLoading);
|
|
1934
1903
|
const fetchActivities = useCrmStore((s) => s.fetchActivities);
|
|
1935
|
-
const [typeFilter, setTypeFilter] =
|
|
1936
|
-
const [showCompleted, setShowCompleted] =
|
|
1937
|
-
|
|
1904
|
+
const [typeFilter, setTypeFilter] = React14.useState(null);
|
|
1905
|
+
const [showCompleted, setShowCompleted] = React14.useState(null);
|
|
1906
|
+
React14.useEffect(() => {
|
|
1938
1907
|
fetchActivities({
|
|
1939
1908
|
activityType: typeFilter,
|
|
1940
1909
|
completed: showCompleted ?? void 0
|
|
@@ -2103,7 +2072,7 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
2103
2072
|
activities: 0,
|
|
2104
2073
|
settings: 1
|
|
2105
2074
|
}, "dashboard");
|
|
2106
|
-
const [onboardingComplete, setOnboardingComplete] =
|
|
2075
|
+
const [onboardingComplete, setOnboardingComplete] = React14.useState(() => {
|
|
2107
2076
|
try {
|
|
2108
2077
|
return localStorage.getItem("saas-core:crm-onboarded") === "true";
|
|
2109
2078
|
} catch {
|
|
@@ -2114,7 +2083,7 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
2114
2083
|
const isSummary = view === "dashboard";
|
|
2115
2084
|
const nav = buildNav(config, view, navigate);
|
|
2116
2085
|
const t2 = core.useTranslation();
|
|
2117
|
-
const quickActions =
|
|
2086
|
+
const quickActions = React14.useMemo(() => [
|
|
2118
2087
|
{ id: "new-lead", label: t2("crm.quickActions.newLead"), icon: "UserPlus", description: t2("crm.quickActions.newLeadDesc"), action: () => navigate("leads-new") },
|
|
2119
2088
|
{ id: "new-deal", label: t2("crm.quickActions.newDeal"), icon: "Target", description: t2("crm.quickActions.newDealDesc"), action: () => navigate("pipeline") },
|
|
2120
2089
|
...config.modules.quotes ? [{ id: "new-quote", label: t2("crm.quickActions.newQuote"), icon: "FileText", description: t2("crm.quickActions.newQuoteDesc"), action: () => navigate("quotes-new") }] : [],
|
|
@@ -2135,8 +2104,7 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
2135
2104
|
/* @__PURE__ */ jsxRuntime.jsx("h1", { style: { fontSize: "20px", fontWeight: 600, margin: 0 }, children: t2("crm.settingsPage.title") }),
|
|
2136
2105
|
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { color: "var(--muted-foreground, #6b7280)", margin: "4px 0 0", fontSize: "14px" }, children: t2("crm.settingsPage.subtitle") })
|
|
2137
2106
|
] }),
|
|
2138
|
-
/* @__PURE__ */ jsxRuntime.jsx(CrmGeneralSettings, {})
|
|
2139
|
-
/* @__PURE__ */ jsxRuntime.jsx(PipelineSettings, {})
|
|
2107
|
+
/* @__PURE__ */ jsxRuntime.jsx(CrmGeneralSettings, {})
|
|
2140
2108
|
] }) }) });
|
|
2141
2109
|
}
|
|
2142
2110
|
const renderView = saas.createViewRouter([
|
|
@@ -2180,7 +2148,7 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
2180
2148
|
}
|
|
2181
2149
|
function useEnsureSummary() {
|
|
2182
2150
|
const fetchSummary = useCrmStore((s) => s.fetchSummary);
|
|
2183
|
-
|
|
2151
|
+
React14.useEffect(() => {
|
|
2184
2152
|
void fetchSummary();
|
|
2185
2153
|
}, []);
|
|
2186
2154
|
}
|
|
@@ -2188,10 +2156,10 @@ function useEnsureFunnel() {
|
|
|
2188
2156
|
const pipelines = useCrmStore((s) => s.pipelines);
|
|
2189
2157
|
const fetchPipelines = useCrmStore((s) => s.fetchPipelines);
|
|
2190
2158
|
const fetchFunnel = useCrmStore((s) => s.fetchFunnel);
|
|
2191
|
-
|
|
2159
|
+
React14.useEffect(() => {
|
|
2192
2160
|
void fetchPipelines();
|
|
2193
2161
|
}, []);
|
|
2194
|
-
|
|
2162
|
+
React14.useEffect(() => {
|
|
2195
2163
|
if (pipelines.length > 0) void fetchFunnel(pipelines[0].id);
|
|
2196
2164
|
}, [pipelines]);
|
|
2197
2165
|
}
|
|
@@ -2332,7 +2300,7 @@ function RecentLeadsTable() {
|
|
|
2332
2300
|
const t2 = core.useTranslation();
|
|
2333
2301
|
const leads = useCrmStore((s) => s.leads);
|
|
2334
2302
|
const fetchLeads = useCrmStore((s) => s.fetchLeads);
|
|
2335
|
-
|
|
2303
|
+
React14.useEffect(() => {
|
|
2336
2304
|
void fetchLeads({ pageSize: 5 });
|
|
2337
2305
|
}, []);
|
|
2338
2306
|
const columns2 = [
|
|
@@ -2347,7 +2315,7 @@ function RecentQuotesTable() {
|
|
|
2347
2315
|
const { currency } = useCrmConfig();
|
|
2348
2316
|
const quotes = useCrmStore((s) => s.quotes);
|
|
2349
2317
|
const fetchQuotes = useCrmStore((s) => s.fetchQuotes);
|
|
2350
|
-
|
|
2318
|
+
React14.useEffect(() => {
|
|
2351
2319
|
void fetchQuotes({ pageSize: 5 });
|
|
2352
2320
|
}, []);
|
|
2353
2321
|
const columns2 = [
|
|
@@ -2813,6 +2781,17 @@ function createMockCrmProvider(options) {
|
|
|
2813
2781
|
return provider;
|
|
2814
2782
|
}
|
|
2815
2783
|
|
|
2784
|
+
// src/data/tables.ts
|
|
2785
|
+
var T = {
|
|
2786
|
+
activities: "plg_crm_activities",
|
|
2787
|
+
tags: "plg_crm_tags",
|
|
2788
|
+
activityTypes: "plg_crm_activity_types",
|
|
2789
|
+
pipelines: "plg_crm_pipelines",
|
|
2790
|
+
pipelineStages: "plg_crm_pipeline_stages",
|
|
2791
|
+
dealExtensions: "plg_crm_deal_extensions",
|
|
2792
|
+
leadSources: "plg_crm_lead_sources"
|
|
2793
|
+
};
|
|
2794
|
+
|
|
2816
2795
|
// src/data/supabase.ts
|
|
2817
2796
|
function getTenantId() {
|
|
2818
2797
|
return core.getActiveTenantId();
|
|
@@ -2827,19 +2806,19 @@ function snakeToCamel(obj) {
|
|
|
2827
2806
|
function getClients() {
|
|
2828
2807
|
const supabase = core.getSupabaseClientOptional();
|
|
2829
2808
|
if (!supabase) throw new Error("Supabase not initialized");
|
|
2830
|
-
return { core: supabase
|
|
2809
|
+
return { core: supabase, pub: supabase };
|
|
2831
2810
|
}
|
|
2832
2811
|
function createSupabaseCrmProvider(options) {
|
|
2833
2812
|
const provider = {
|
|
2834
|
-
// --- Pipelines (public.
|
|
2813
|
+
// --- Pipelines (public.plg_crm_pipelines + plg_crm_pipeline_stages) ---
|
|
2835
2814
|
async getPipelines() {
|
|
2836
2815
|
const { pub } = getClients();
|
|
2837
|
-
const { data } = await pub.from(
|
|
2816
|
+
const { data } = await pub.from(T.pipelines).select("*").eq("is_active", true).order("name");
|
|
2838
2817
|
return (data ?? []).map((r) => snakeToCamel(r));
|
|
2839
2818
|
},
|
|
2840
2819
|
async getPipelineStages(pipelineId) {
|
|
2841
2820
|
const { pub } = getClients();
|
|
2842
|
-
const { data } = await pub.from(
|
|
2821
|
+
const { data } = await pub.from(T.pipelineStages).select("*").eq("pipeline_id", pipelineId).order("order");
|
|
2843
2822
|
return (data ?? []).map((r) => snakeToCamel(r));
|
|
2844
2823
|
},
|
|
2845
2824
|
// --- Leads (via view — single query) ---
|
|
@@ -2897,7 +2876,7 @@ function createSupabaseCrmProvider(options) {
|
|
|
2897
2876
|
async createLead(input) {
|
|
2898
2877
|
const { core } = getClients();
|
|
2899
2878
|
const tenantId = getTenantId();
|
|
2900
|
-
const { data, error } = await core.from("
|
|
2879
|
+
const { data, error } = await core.from("people").insert({
|
|
2901
2880
|
tenant_id: tenantId,
|
|
2902
2881
|
kind: "lead",
|
|
2903
2882
|
name: input.name,
|
|
@@ -2920,13 +2899,13 @@ function createSupabaseCrmProvider(options) {
|
|
|
2920
2899
|
if (partial.phone !== void 0) row.phone = partial.phone;
|
|
2921
2900
|
if (partial.notes !== void 0) row.notes = partial.notes;
|
|
2922
2901
|
if (partial.status) row.metadata = { status: partial.status };
|
|
2923
|
-
const { data, error } = await core.from("
|
|
2902
|
+
const { data, error } = await core.from("people").update(row).eq("id", id).select().single();
|
|
2924
2903
|
if (error) throw new Error(error.message);
|
|
2925
2904
|
return await provider.getLeadById(id);
|
|
2926
2905
|
},
|
|
2927
2906
|
async convertLeadToDeal(leadId, dealInput) {
|
|
2928
2907
|
const { core } = getClients();
|
|
2929
|
-
await core.from("
|
|
2908
|
+
await core.from("people").update({ metadata: { status: "converted" } }).eq("id", leadId);
|
|
2930
2909
|
return provider.createDeal({ ...dealInput, leadId });
|
|
2931
2910
|
},
|
|
2932
2911
|
// --- Deals (via view — single query with all joins) ---
|
|
@@ -3033,7 +3012,7 @@ function createSupabaseCrmProvider(options) {
|
|
|
3033
3012
|
metadata: { contactName: input.contactName }
|
|
3034
3013
|
}).select().single();
|
|
3035
3014
|
if (error) throw new Error(error.message);
|
|
3036
|
-
await pub.from(
|
|
3015
|
+
await pub.from(T.dealExtensions).insert({
|
|
3037
3016
|
order_id: order.id,
|
|
3038
3017
|
tenant_id: tenantId,
|
|
3039
3018
|
pipeline_id: input.pipelineId,
|
|
@@ -3071,14 +3050,14 @@ function createSupabaseCrmProvider(options) {
|
|
|
3071
3050
|
if (partial.stageId) row.stage_id = partial.stageId;
|
|
3072
3051
|
if (partial.probability != null) row.probability = partial.probability;
|
|
3073
3052
|
if (partial.expectedCloseDate) row.expected_close_date = partial.expectedCloseDate;
|
|
3074
|
-
await pub.from(
|
|
3053
|
+
await pub.from(T.dealExtensions).update(row).eq("order_id", id);
|
|
3075
3054
|
}
|
|
3076
3055
|
return await provider.getDealById(id);
|
|
3077
3056
|
},
|
|
3078
3057
|
async moveDealToStage(dealId, stageId) {
|
|
3079
3058
|
const { core, pub } = getClients();
|
|
3080
|
-
const { data: stageRow } = await pub.from(
|
|
3081
|
-
await pub.from(
|
|
3059
|
+
const { data: stageRow } = await pub.from(T.pipelineStages).select("*").eq("id", stageId).single();
|
|
3060
|
+
await pub.from(T.dealExtensions).update({
|
|
3082
3061
|
stage_id: stageId,
|
|
3083
3062
|
probability: stageRow?.probability ?? 0
|
|
3084
3063
|
}).eq("order_id", dealId);
|
|
@@ -3097,10 +3076,10 @@ function createSupabaseCrmProvider(options) {
|
|
|
3097
3076
|
tenantId: stageRow.tenant_id,
|
|
3098
3077
|
createdAt: stageRow.created_at
|
|
3099
3078
|
};
|
|
3100
|
-
const { data: ext } = await pub.from(
|
|
3079
|
+
const { data: ext } = await pub.from(T.dealExtensions).select("lead_id").eq("order_id", dealId).single();
|
|
3101
3080
|
if (ext?.lead_id) {
|
|
3102
3081
|
const newLeadStatus = deriveLeadStatus(typedStage);
|
|
3103
|
-
await core.from("
|
|
3082
|
+
await core.from("people").update({ metadata: { status: newLeadStatus } }).eq("id", ext.lead_id);
|
|
3104
3083
|
}
|
|
3105
3084
|
const { data: quotes } = await core.from("orders").select("id, status").eq("kind", "quote");
|
|
3106
3085
|
for (const q of quotes ?? []) {
|
|
@@ -3115,10 +3094,10 @@ function createSupabaseCrmProvider(options) {
|
|
|
3115
3094
|
}
|
|
3116
3095
|
return await provider.getDealById(dealId);
|
|
3117
3096
|
},
|
|
3118
|
-
// --- Activities (public.
|
|
3097
|
+
// --- Activities (public.plg_crm_activities) ---
|
|
3119
3098
|
async getActivities(query) {
|
|
3120
3099
|
const { pub } = getClients();
|
|
3121
|
-
let qb = pub.from(
|
|
3100
|
+
let qb = pub.from(T.activities).select("*", { count: "exact" });
|
|
3122
3101
|
if (query.dealId) qb = qb.eq("deal_id", query.dealId);
|
|
3123
3102
|
if (query.leadId) qb = qb.eq("lead_id", query.leadId);
|
|
3124
3103
|
if (query.activityType) qb = qb.eq("activity_type", query.activityType);
|
|
@@ -3133,7 +3112,7 @@ function createSupabaseCrmProvider(options) {
|
|
|
3133
3112
|
async createActivity(input) {
|
|
3134
3113
|
const { pub } = getClients();
|
|
3135
3114
|
const tenantId = getTenantId();
|
|
3136
|
-
const { data, error } = await pub.from(
|
|
3115
|
+
const { data, error } = await pub.from(T.activities).insert({
|
|
3137
3116
|
tenant_id: tenantId,
|
|
3138
3117
|
deal_id: input.dealId,
|
|
3139
3118
|
lead_id: input.leadId,
|
|
@@ -3149,11 +3128,11 @@ function createSupabaseCrmProvider(options) {
|
|
|
3149
3128
|
},
|
|
3150
3129
|
async completeActivity(id) {
|
|
3151
3130
|
const { pub } = getClients();
|
|
3152
|
-
const { data, error } = await pub.from(
|
|
3131
|
+
const { data, error } = await pub.from(T.activities).update({ completed_at: (/* @__PURE__ */ new Date()).toISOString() }).eq("id", id).select().single();
|
|
3153
3132
|
if (error) throw new Error(error.message);
|
|
3154
3133
|
return snakeToCamel(data);
|
|
3155
3134
|
},
|
|
3156
|
-
// --- Quotes (
|
|
3135
|
+
// --- Quotes (public.orders kind='quote' + order_items) ---
|
|
3157
3136
|
async getQuotes(query) {
|
|
3158
3137
|
const { core } = getClients();
|
|
3159
3138
|
let qb = core.from("orders").select("*", { count: "exact" }).eq("kind", "quote");
|
|
@@ -3352,11 +3331,11 @@ function createSupabaseCrmProvider(options) {
|
|
|
3352
3331
|
const personToConvert = quote.leadId ?? quote.contactId;
|
|
3353
3332
|
if (personToConvert) {
|
|
3354
3333
|
const clientKind = options?.clientConversion?.archetypeKind ?? "client";
|
|
3355
|
-
const { data: person } = await core.from("
|
|
3334
|
+
const { data: person } = await core.from("people").select("kind, name, email, phone, tenant_id, metadata").eq("id", personToConvert).single();
|
|
3356
3335
|
const personKind = person?.kind;
|
|
3357
3336
|
if (person && (personKind === "lead" || personKind === "contact")) {
|
|
3358
3337
|
const personMeta = person?.metadata ?? {};
|
|
3359
|
-
await core.from("
|
|
3338
|
+
await core.from("people").update({
|
|
3360
3339
|
kind: clientKind,
|
|
3361
3340
|
metadata: { ...personMeta, convertedFromLead: true }
|
|
3362
3341
|
}).eq("id", personToConvert);
|
|
@@ -3420,7 +3399,7 @@ function createSupabaseCrmProvider(options) {
|
|
|
3420
3399
|
},
|
|
3421
3400
|
async getDealByLeadId(leadId) {
|
|
3422
3401
|
const { pub } = getClients();
|
|
3423
|
-
const { data } = await pub.from(
|
|
3402
|
+
const { data } = await pub.from(T.dealExtensions).select("order_id").eq("lead_id", leadId).limit(1);
|
|
3424
3403
|
if (!data || data.length === 0) return null;
|
|
3425
3404
|
return provider.getDealById(data[0].order_id);
|
|
3426
3405
|
},
|
|
@@ -3429,16 +3408,16 @@ function createSupabaseCrmProvider(options) {
|
|
|
3429
3408
|
const { core, pub } = getClients();
|
|
3430
3409
|
const monthStart = (/* @__PURE__ */ new Date()).toISOString().slice(0, 7) + "-01";
|
|
3431
3410
|
const today2 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
3432
|
-
const { count: totalLeads } = await core.from("
|
|
3433
|
-
const { count: newLeads } = await core.from("
|
|
3411
|
+
const { count: totalLeads } = await core.from("people").select("*", { count: "exact", head: true }).eq("kind", "lead");
|
|
3412
|
+
const { count: newLeads } = await core.from("people").select("*", { count: "exact", head: true }).eq("kind", "lead").gte("created_at", monthStart);
|
|
3434
3413
|
const { data: deals } = await core.from("orders").select("status, total, updated_at").eq("kind", "deal");
|
|
3435
3414
|
const allDeals = deals ?? [];
|
|
3436
3415
|
const openDeals = allDeals.filter((d) => d.status === "open");
|
|
3437
3416
|
const wonDeals = allDeals.filter((d) => d.status === "won");
|
|
3438
3417
|
const wonThisMonth = wonDeals.filter((d) => d.updated_at >= monthStart);
|
|
3439
3418
|
const convertedLeads = allDeals.length;
|
|
3440
|
-
const { count: pendingActs } = await pub.from(
|
|
3441
|
-
const { count: overdueActs } = await pub.from(
|
|
3419
|
+
const { count: pendingActs } = await pub.from(T.activities).select("*", { count: "exact", head: true }).is("completed_at", null);
|
|
3420
|
+
const { count: overdueActs } = await pub.from(T.activities).select("*", { count: "exact", head: true }).is("completed_at", null).lt("due_date", today2);
|
|
3442
3421
|
return {
|
|
3443
3422
|
totalLeads: totalLeads ?? 0,
|
|
3444
3423
|
newLeadsThisMonth: newLeads ?? 0,
|
|
@@ -3780,7 +3759,7 @@ var leadSourceEntity = {
|
|
|
3780
3759
|
{ key: "name", label: "Name", type: "text", required: true, showInTable: true },
|
|
3781
3760
|
{ key: "isActive", label: "Active", type: "boolean", showInTable: true, defaultValue: true }
|
|
3782
3761
|
],
|
|
3783
|
-
data: { table:
|
|
3762
|
+
data: { table: T.leadSources, tenantScoped: true }
|
|
3784
3763
|
};
|
|
3785
3764
|
var tagEntity = {
|
|
3786
3765
|
name: "Tag",
|
|
@@ -3790,10 +3769,34 @@ var tagEntity = {
|
|
|
3790
3769
|
defaultSort: "name",
|
|
3791
3770
|
fields: [
|
|
3792
3771
|
{ key: "name", label: "Name", type: "text", required: true, showInTable: true },
|
|
3793
|
-
{ key: "color", label: "Color", type: "
|
|
3772
|
+
{ key: "color", label: "Color", type: "color", showInTable: true, defaultValue: "#6366f1" },
|
|
3794
3773
|
{ key: "isActive", label: "Active", type: "boolean", showInTable: true, defaultValue: true }
|
|
3795
3774
|
],
|
|
3796
|
-
data: { table:
|
|
3775
|
+
data: { table: T.tags, tenantScoped: true }
|
|
3776
|
+
};
|
|
3777
|
+
var pipelineStageEntity = {
|
|
3778
|
+
name: "Stage",
|
|
3779
|
+
namePlural: "Stages",
|
|
3780
|
+
icon: "Workflow",
|
|
3781
|
+
displayField: "name",
|
|
3782
|
+
defaultSort: "order",
|
|
3783
|
+
fields: [
|
|
3784
|
+
{ key: "name", label: "Name", type: "text", required: true, showInTable: true, searchable: true },
|
|
3785
|
+
{
|
|
3786
|
+
key: "pipelineId",
|
|
3787
|
+
label: "Pipeline",
|
|
3788
|
+
type: "relation",
|
|
3789
|
+
relation: { table: T.pipelines, labelField: "name" },
|
|
3790
|
+
required: true,
|
|
3791
|
+
showInTable: true
|
|
3792
|
+
},
|
|
3793
|
+
{ key: "order", label: "Order", type: "number", required: true, showInTable: true, defaultValue: 0 },
|
|
3794
|
+
{ key: "color", label: "Color", type: "color", showInTable: true, defaultValue: "#6366f1" },
|
|
3795
|
+
{ key: "probability", label: "Probability %", type: "number", min: 0, max: 100, showInTable: true, defaultValue: 0 },
|
|
3796
|
+
{ key: "isWon", label: "Won Stage", type: "boolean", showInTable: true, defaultValue: false },
|
|
3797
|
+
{ key: "isLost", label: "Lost Stage", type: "boolean", showInTable: true, defaultValue: false }
|
|
3798
|
+
],
|
|
3799
|
+
data: { table: T.pipelineStages, tenantScoped: true }
|
|
3797
3800
|
};
|
|
3798
3801
|
var activityTypeEntity = {
|
|
3799
3802
|
name: "Activity Type",
|
|
@@ -3805,9 +3808,24 @@ var activityTypeEntity = {
|
|
|
3805
3808
|
{ key: "name", label: "Name", type: "text", required: true, showInTable: true },
|
|
3806
3809
|
{ key: "isActive", label: "Active", type: "boolean", showInTable: true, defaultValue: true }
|
|
3807
3810
|
],
|
|
3808
|
-
data: { table:
|
|
3811
|
+
data: { table: T.activityTypes, tenantScoped: true }
|
|
3809
3812
|
};
|
|
3810
3813
|
var crmRegistries = [
|
|
3814
|
+
{
|
|
3815
|
+
id: "stages",
|
|
3816
|
+
entity: pipelineStageEntity,
|
|
3817
|
+
icon: "Workflow",
|
|
3818
|
+
description: "Pipeline stages used by CRM deals",
|
|
3819
|
+
display: "table",
|
|
3820
|
+
seedData: [
|
|
3821
|
+
{ id: "stage-new", pipelineId: "pipe-default", name: "New Lead", order: 1, color: "#64748b", probability: 10, isWon: false, isLost: false },
|
|
3822
|
+
{ id: "stage-qualified", pipelineId: "pipe-default", name: "Qualified", order: 2, color: "#3b82f6", probability: 30, isWon: false, isLost: false },
|
|
3823
|
+
{ id: "stage-proposal", pipelineId: "pipe-default", name: "Proposal", order: 3, color: "#8b5cf6", probability: 60, isWon: false, isLost: false },
|
|
3824
|
+
{ id: "stage-negotiation", pipelineId: "pipe-default", name: "Negotiation", order: 4, color: "#f59e0b", probability: 80, isWon: false, isLost: false },
|
|
3825
|
+
{ id: "stage-won", pipelineId: "pipe-default", name: "Won", order: 5, color: "#10b981", probability: 100, isWon: true, isLost: false },
|
|
3826
|
+
{ id: "stage-lost", pipelineId: "pipe-default", name: "Lost", order: 6, color: "#ef4444", probability: 0, isWon: false, isLost: true }
|
|
3827
|
+
]
|
|
3828
|
+
},
|
|
3811
3829
|
{
|
|
3812
3830
|
id: "lead-sources",
|
|
3813
3831
|
entity: leadSourceEntity,
|
|
@@ -4488,7 +4506,7 @@ function createCrmPlugin(options) {
|
|
|
4488
4506
|
() => createMockCrmProvider()
|
|
4489
4507
|
);
|
|
4490
4508
|
const store = createCrmStore(provider);
|
|
4491
|
-
const PageComponent = () =>
|
|
4509
|
+
const PageComponent = () => React14__default.default.createElement(CrmPage, { config, provider, store, registries: crmRegistries });
|
|
4492
4510
|
const dashboardWidgets = createCrmDashboardWidgets({ config, provider, store });
|
|
4493
4511
|
return {
|
|
4494
4512
|
id: "crm",
|
|
@@ -4497,6 +4515,9 @@ function createCrmPlugin(options) {
|
|
|
4497
4515
|
version: "1.0.0",
|
|
4498
4516
|
scope: options?.scope ?? "universal",
|
|
4499
4517
|
verticalId: options?.verticalId,
|
|
4518
|
+
// Sales-pipeline/lead-management is a business-ops tool — targets the
|
|
4519
|
+
// saas/admin Panel world, not the ecommerce storefront.
|
|
4520
|
+
scaffolds: ["saas"],
|
|
4500
4521
|
defaultEnabled: true,
|
|
4501
4522
|
dependencies: [],
|
|
4502
4523
|
declaredFeatures: [
|
|
@@ -4575,15 +4596,17 @@ function createCrmPlugin(options) {
|
|
|
4575
4596
|
label: "Sales & CRM",
|
|
4576
4597
|
icon: "Filter",
|
|
4577
4598
|
component: (() => {
|
|
4578
|
-
const Tab = () =>
|
|
4599
|
+
const Tab = () => React14__default.default.createElement(
|
|
4579
4600
|
CrmContextProvider,
|
|
4580
4601
|
{ config, provider, store },
|
|
4581
|
-
|
|
4582
|
-
"
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4602
|
+
React14__default.default.createElement(saas.PluginSettingsPanel, {
|
|
4603
|
+
title: "Sales & CRM",
|
|
4604
|
+
subtitle: "Pipeline, lead management, and CRM properties",
|
|
4605
|
+
generalSettings: React14__default.default.createElement(CrmGeneralSettings),
|
|
4606
|
+
registries: crmRegistries,
|
|
4607
|
+
hostPluginId: "crm",
|
|
4608
|
+
routeBase: "/settings/crm"
|
|
4609
|
+
})
|
|
4587
4610
|
);
|
|
4588
4611
|
Tab.displayName = "CrmSettingsTab";
|
|
4589
4612
|
return Tab;
|