@fayz-ai/plugin-crm 0.2.3 → 0.3.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/dist/CrmPage.d.ts.map +1 -1
- package/dist/index.cjs +134 -125
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +54 -45
- package/dist/index.js.map +1 -1
- package/dist/registries.d.ts.map +1 -1
- package/package.json +5 -8
- package/src/CrmPage.tsx +0 -2
- package/src/index.ts +9 -8
- package/src/registries.ts +41 -1
package/dist/CrmPage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrmPage.d.ts","sourceRoot":"","sources":["../src/CrmPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG/C,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"CrmPage.d.ts","sourceRoot":"","sources":["../src/CrmPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG/C,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,eAAe,CAAA;AAgDzE,wBAAgB,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;IAC/D,MAAM,EAAE,iBAAiB,CAAA;IACzB,QAAQ,EAAE,eAAe,CAAA;IACzB,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAA;IAC3B,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAA;CACjC,qBAyFA"}
|
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 = [
|
|
@@ -3790,11 +3758,35 @@ var tagEntity = {
|
|
|
3790
3758
|
defaultSort: "name",
|
|
3791
3759
|
fields: [
|
|
3792
3760
|
{ key: "name", label: "Name", type: "text", required: true, showInTable: true },
|
|
3793
|
-
{ key: "color", label: "Color", type: "
|
|
3761
|
+
{ key: "color", label: "Color", type: "color", showInTable: true, defaultValue: "#6366f1" },
|
|
3794
3762
|
{ key: "isActive", label: "Active", type: "boolean", showInTable: true, defaultValue: true }
|
|
3795
3763
|
],
|
|
3796
3764
|
data: { table: "crm_tags", tenantScoped: true }
|
|
3797
3765
|
};
|
|
3766
|
+
var pipelineStageEntity = {
|
|
3767
|
+
name: "Stage",
|
|
3768
|
+
namePlural: "Stages",
|
|
3769
|
+
icon: "Workflow",
|
|
3770
|
+
displayField: "name",
|
|
3771
|
+
defaultSort: "order",
|
|
3772
|
+
fields: [
|
|
3773
|
+
{ key: "name", label: "Name", type: "text", required: true, showInTable: true, searchable: true },
|
|
3774
|
+
{
|
|
3775
|
+
key: "pipelineId",
|
|
3776
|
+
label: "Pipeline",
|
|
3777
|
+
type: "relation",
|
|
3778
|
+
relation: { table: "pipelines", labelField: "name" },
|
|
3779
|
+
required: true,
|
|
3780
|
+
showInTable: true
|
|
3781
|
+
},
|
|
3782
|
+
{ key: "order", label: "Order", type: "number", required: true, showInTable: true, defaultValue: 0 },
|
|
3783
|
+
{ key: "color", label: "Color", type: "color", showInTable: true, defaultValue: "#6366f1" },
|
|
3784
|
+
{ key: "probability", label: "Probability %", type: "number", min: 0, max: 100, showInTable: true, defaultValue: 0 },
|
|
3785
|
+
{ key: "isWon", label: "Won Stage", type: "boolean", showInTable: true, defaultValue: false },
|
|
3786
|
+
{ key: "isLost", label: "Lost Stage", type: "boolean", showInTable: true, defaultValue: false }
|
|
3787
|
+
],
|
|
3788
|
+
data: { table: "pipeline_stages", tenantScoped: true }
|
|
3789
|
+
};
|
|
3798
3790
|
var activityTypeEntity = {
|
|
3799
3791
|
name: "Activity Type",
|
|
3800
3792
|
namePlural: "Activity Types",
|
|
@@ -3808,6 +3800,21 @@ var activityTypeEntity = {
|
|
|
3808
3800
|
data: { table: "crm_activity_types", tenantScoped: true }
|
|
3809
3801
|
};
|
|
3810
3802
|
var crmRegistries = [
|
|
3803
|
+
{
|
|
3804
|
+
id: "stages",
|
|
3805
|
+
entity: pipelineStageEntity,
|
|
3806
|
+
icon: "Workflow",
|
|
3807
|
+
description: "Pipeline stages used by CRM deals",
|
|
3808
|
+
display: "table",
|
|
3809
|
+
seedData: [
|
|
3810
|
+
{ id: "stage-new", pipelineId: "pipe-default", name: "New Lead", order: 1, color: "#64748b", probability: 10, isWon: false, isLost: false },
|
|
3811
|
+
{ id: "stage-qualified", pipelineId: "pipe-default", name: "Qualified", order: 2, color: "#3b82f6", probability: 30, isWon: false, isLost: false },
|
|
3812
|
+
{ id: "stage-proposal", pipelineId: "pipe-default", name: "Proposal", order: 3, color: "#8b5cf6", probability: 60, isWon: false, isLost: false },
|
|
3813
|
+
{ id: "stage-negotiation", pipelineId: "pipe-default", name: "Negotiation", order: 4, color: "#f59e0b", probability: 80, isWon: false, isLost: false },
|
|
3814
|
+
{ id: "stage-won", pipelineId: "pipe-default", name: "Won", order: 5, color: "#10b981", probability: 100, isWon: true, isLost: false },
|
|
3815
|
+
{ id: "stage-lost", pipelineId: "pipe-default", name: "Lost", order: 6, color: "#ef4444", probability: 0, isWon: false, isLost: true }
|
|
3816
|
+
]
|
|
3817
|
+
},
|
|
3811
3818
|
{
|
|
3812
3819
|
id: "lead-sources",
|
|
3813
3820
|
entity: leadSourceEntity,
|
|
@@ -4488,7 +4495,7 @@ function createCrmPlugin(options) {
|
|
|
4488
4495
|
() => createMockCrmProvider()
|
|
4489
4496
|
);
|
|
4490
4497
|
const store = createCrmStore(provider);
|
|
4491
|
-
const PageComponent = () =>
|
|
4498
|
+
const PageComponent = () => React14__default.default.createElement(CrmPage, { config, provider, store, registries: crmRegistries });
|
|
4492
4499
|
const dashboardWidgets = createCrmDashboardWidgets({ config, provider, store });
|
|
4493
4500
|
return {
|
|
4494
4501
|
id: "crm",
|
|
@@ -4575,15 +4582,17 @@ function createCrmPlugin(options) {
|
|
|
4575
4582
|
label: "Sales & CRM",
|
|
4576
4583
|
icon: "Filter",
|
|
4577
4584
|
component: (() => {
|
|
4578
|
-
const Tab = () =>
|
|
4585
|
+
const Tab = () => React14__default.default.createElement(
|
|
4579
4586
|
CrmContextProvider,
|
|
4580
4587
|
{ config, provider, store },
|
|
4581
|
-
|
|
4582
|
-
"
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4588
|
+
React14__default.default.createElement(saas.PluginSettingsPanel, {
|
|
4589
|
+
title: "Sales & CRM",
|
|
4590
|
+
subtitle: "Pipeline, lead management, and CRM properties",
|
|
4591
|
+
generalSettings: React14__default.default.createElement(CrmGeneralSettings),
|
|
4592
|
+
registries: crmRegistries,
|
|
4593
|
+
hostPluginId: "crm",
|
|
4594
|
+
routeBase: "/settings/crm"
|
|
4595
|
+
})
|
|
4587
4596
|
);
|
|
4588
4597
|
Tab.displayName = "CrmSettingsTab";
|
|
4589
4598
|
return Tab;
|