@fayz-ai/plugin-crm 0.33.1 → 0.33.3
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-GWYW2YMM.js → CrmPage-QR3MSBZP.js} +22 -19
- package/dist/CrmPage-QR3MSBZP.js.map +1 -0
- package/dist/{chunk-BIQL232X.js → chunk-LDBCC67C.js} +35 -24
- package/dist/chunk-LDBCC67C.js.map +1 -0
- package/dist/components/FormAnswers.d.ts.map +1 -1
- package/dist/index.js +71 -77
- package/dist/index.js.map +1 -1
- package/dist/lib/team.d.ts.map +1 -1
- package/dist/views/DealCardModal.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/CrmPage-GWYW2YMM.js.map +0 -1
- package/dist/chunk-BIQL232X.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { documentKind, formatDocument, DEFAULT_ACTIVITY_TYPES, buildCrmRegistries, T, localPhoneKey, normalizeDocument, loadMyUserId, isValidDocument, documentRoot } from './chunk-
|
|
2
|
-
export { TagChips, humanizeTag } from './chunk-
|
|
1
|
+
import { documentKind, formatDocument, DEFAULT_ACTIVITY_TYPES, buildCrmRegistries, getCrmTenantId, T, localPhoneKey, normalizeDocument, loadMyUserId, isValidDocument, documentRoot } from './chunk-LDBCC67C.js';
|
|
2
|
+
export { TagChips, humanizeTag } from './chunk-LDBCC67C.js';
|
|
3
3
|
import { resolveSourceView, evaluateSegment } from './chunk-QJOLAGGN.js';
|
|
4
4
|
import { CrmContextProvider, useCrmConfig, useCrmStore, formatCurrency, useCrmProvider } from './chunk-7V46TYYX.js';
|
|
5
5
|
import React, { useEffect } from 'react';
|
|
@@ -229,64 +229,64 @@ function StatusDot({ status, palette }) {
|
|
|
229
229
|
] });
|
|
230
230
|
}
|
|
231
231
|
function TotalLeadsKpi() {
|
|
232
|
-
const
|
|
232
|
+
const t = useTranslation();
|
|
233
233
|
const summary = useCrmStore((s) => s.summary);
|
|
234
234
|
useEnsureSummary();
|
|
235
235
|
return /* @__PURE__ */ jsx(
|
|
236
236
|
KpiCard,
|
|
237
237
|
{
|
|
238
|
-
label:
|
|
238
|
+
label: t("crm.dashboard.totalLeads"),
|
|
239
239
|
icon: "Users",
|
|
240
240
|
value: String(summary?.totalLeads ?? 0),
|
|
241
|
-
sub:
|
|
241
|
+
sub: t("crm.dashboard.newThisMonth", { count: String(summary?.newLeadsThisMonth ?? 0) })
|
|
242
242
|
}
|
|
243
243
|
);
|
|
244
244
|
}
|
|
245
245
|
function OpenPipelineKpi() {
|
|
246
|
-
const
|
|
246
|
+
const t = useTranslation();
|
|
247
247
|
const { currency } = useCrmConfig();
|
|
248
248
|
const summary = useCrmStore((s) => s.summary);
|
|
249
249
|
useEnsureSummary();
|
|
250
250
|
return /* @__PURE__ */ jsx(
|
|
251
251
|
KpiCard,
|
|
252
252
|
{
|
|
253
|
-
label:
|
|
253
|
+
label: t("crm.dashboard.openPipeline"),
|
|
254
254
|
icon: "Target",
|
|
255
255
|
value: formatCurrency(summary?.openDealsValue ?? 0, currency),
|
|
256
|
-
sub:
|
|
256
|
+
sub: t("crm.dashboard.activeDeals", { count: String(summary?.totalDeals ?? 0) })
|
|
257
257
|
}
|
|
258
258
|
);
|
|
259
259
|
}
|
|
260
260
|
function ConversionRateKpi() {
|
|
261
|
-
const
|
|
261
|
+
const t = useTranslation();
|
|
262
262
|
const summary = useCrmStore((s) => s.summary);
|
|
263
263
|
useEnsureSummary();
|
|
264
264
|
return /* @__PURE__ */ jsx(
|
|
265
265
|
KpiCard,
|
|
266
266
|
{
|
|
267
|
-
label:
|
|
267
|
+
label: t("crm.dashboard.conversionRate"),
|
|
268
268
|
icon: "TrendingUp",
|
|
269
269
|
value: `${(summary?.conversionRate ?? 0).toFixed(1)}%`,
|
|
270
|
-
sub:
|
|
270
|
+
sub: t("crm.dashboard.leadToDeal")
|
|
271
271
|
}
|
|
272
272
|
);
|
|
273
273
|
}
|
|
274
274
|
function PendingTasksKpi() {
|
|
275
|
-
const
|
|
275
|
+
const t = useTranslation();
|
|
276
276
|
const summary = useCrmStore((s) => s.summary);
|
|
277
277
|
useEnsureSummary();
|
|
278
278
|
return /* @__PURE__ */ jsx(
|
|
279
279
|
KpiCard,
|
|
280
280
|
{
|
|
281
|
-
label:
|
|
281
|
+
label: t("crm.dashboard.pendingTasks"),
|
|
282
282
|
icon: summary?.overdueActivities ? "AlertTriangle" : "Clock",
|
|
283
283
|
value: String(summary?.pendingActivities ?? 0),
|
|
284
|
-
sub:
|
|
284
|
+
sub: t("crm.dashboard.overdueCount", { count: String(summary?.overdueActivities ?? 0) })
|
|
285
285
|
}
|
|
286
286
|
);
|
|
287
287
|
}
|
|
288
288
|
function SalesFunnelChart() {
|
|
289
|
-
const
|
|
289
|
+
const t = useTranslation();
|
|
290
290
|
const funnel = useCrmStore((s) => s.funnel);
|
|
291
291
|
useEnsureFunnel();
|
|
292
292
|
const data = funnel.map((s) => ({ name: s.stageName, deals: s.dealCount }));
|
|
@@ -294,7 +294,7 @@ function SalesFunnelChart() {
|
|
|
294
294
|
ChartWidget,
|
|
295
295
|
{
|
|
296
296
|
type: "bar",
|
|
297
|
-
title:
|
|
297
|
+
title: t("crm.dashboard.pipelineOverview"),
|
|
298
298
|
icon: "BarChart3",
|
|
299
299
|
categoryKey: "name",
|
|
300
300
|
data,
|
|
@@ -303,7 +303,7 @@ function SalesFunnelChart() {
|
|
|
303
303
|
);
|
|
304
304
|
}
|
|
305
305
|
function PipelineValueChart() {
|
|
306
|
-
const
|
|
306
|
+
const t = useTranslation();
|
|
307
307
|
const funnel = useCrmStore((s) => s.funnel);
|
|
308
308
|
useEnsureFunnel();
|
|
309
309
|
const data = funnel.map((s) => ({ name: s.stageName, value: s.totalValue }));
|
|
@@ -311,29 +311,29 @@ function PipelineValueChart() {
|
|
|
311
311
|
ChartWidget,
|
|
312
312
|
{
|
|
313
313
|
type: "bar",
|
|
314
|
-
title:
|
|
314
|
+
title: t("crm.dashboard.pipelineValue"),
|
|
315
315
|
icon: "Target",
|
|
316
316
|
categoryKey: "name",
|
|
317
317
|
data,
|
|
318
|
-
series: [{ dataKey: "value", label:
|
|
318
|
+
series: [{ dataKey: "value", label: t("crm.dashboard.pipelineValue"), color: "hsl(var(--magic))" }]
|
|
319
319
|
}
|
|
320
320
|
);
|
|
321
321
|
}
|
|
322
322
|
function PerformancePanel() {
|
|
323
|
-
const
|
|
323
|
+
const t = useTranslation();
|
|
324
324
|
const { currency } = useCrmConfig();
|
|
325
325
|
const summary = useCrmStore((s) => s.summary);
|
|
326
326
|
useEnsureSummary();
|
|
327
327
|
const rows = [
|
|
328
|
-
{ label:
|
|
329
|
-
{ label:
|
|
330
|
-
{ label:
|
|
331
|
-
{ label:
|
|
328
|
+
{ label: t("crm.dashboard.dealsWon"), value: String(summary?.wonDealsThisMonth ?? 0) },
|
|
329
|
+
{ label: t("crm.dashboard.revenueWon"), value: formatCurrency(summary?.wonDealsValueThisMonth ?? 0, currency), accent: true },
|
|
330
|
+
{ label: t("crm.dashboard.avgDealValue"), value: formatCurrency(summary?.averageDealValue ?? 0, currency) },
|
|
331
|
+
{ label: t("crm.dashboard.conversionRateLabel"), value: `${(summary?.conversionRate ?? 0).toFixed(1)}%` }
|
|
332
332
|
];
|
|
333
333
|
return /* @__PURE__ */ jsxs(Card, { children: [
|
|
334
334
|
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsxs(CardTitle, { className: "flex items-center gap-2", children: [
|
|
335
335
|
/* @__PURE__ */ jsx("span", { className: "text-warning", children: "\u2605" }),
|
|
336
|
-
|
|
336
|
+
t("crm.dashboard.performance")
|
|
337
337
|
] }) }),
|
|
338
338
|
/* @__PURE__ */ jsx(CardContent, { className: "space-y-3", children: rows.map((r) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
339
339
|
/* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: r.label }),
|
|
@@ -392,29 +392,29 @@ function useEngagement() {
|
|
|
392
392
|
return data;
|
|
393
393
|
}
|
|
394
394
|
function AtRiskKpi() {
|
|
395
|
-
const
|
|
395
|
+
const t = useTranslation();
|
|
396
396
|
const d = useEngagement();
|
|
397
397
|
return /* @__PURE__ */ jsx(
|
|
398
398
|
KpiCard,
|
|
399
399
|
{
|
|
400
|
-
label:
|
|
400
|
+
label: t("crm.engagement.atRisk"),
|
|
401
401
|
value: d ? String(d.at_risk) : "\u2014",
|
|
402
402
|
icon: "AlarmClock",
|
|
403
|
-
sub: d ?
|
|
403
|
+
sub: d ? t("crm.engagement.atRiskSub", { days: String(d.settings.activeDays) }) : ""
|
|
404
404
|
}
|
|
405
405
|
);
|
|
406
406
|
}
|
|
407
407
|
function RetentionKpi() {
|
|
408
|
-
const
|
|
408
|
+
const t = useTranslation();
|
|
409
409
|
const d = useEngagement();
|
|
410
410
|
const rate = d && d.returnable > 0 ? Math.round(d.returned / d.returnable * 100) : null;
|
|
411
411
|
return /* @__PURE__ */ jsx(
|
|
412
412
|
KpiCard,
|
|
413
413
|
{
|
|
414
|
-
label:
|
|
414
|
+
label: t("crm.engagement.retention"),
|
|
415
415
|
value: rate === null ? "\u2014" : `${rate}%`,
|
|
416
416
|
icon: "Repeat",
|
|
417
|
-
sub: d ?
|
|
417
|
+
sub: d ? t("crm.engagement.retentionSub", { returned: String(d.returned), base: String(d.returnable) }) : ""
|
|
418
418
|
}
|
|
419
419
|
);
|
|
420
420
|
}
|
|
@@ -427,22 +427,22 @@ var LADDER = [
|
|
|
427
427
|
{ key: "dormant", labelKey: "crm.engagement.dormant", tone: "bg-destructive/70" }
|
|
428
428
|
];
|
|
429
429
|
function LifecyclePanel() {
|
|
430
|
-
const
|
|
430
|
+
const t = useTranslation();
|
|
431
431
|
const d = useEngagement();
|
|
432
432
|
const total = d?.people ?? 0;
|
|
433
433
|
return /* @__PURE__ */ jsxs(Card, { children: [
|
|
434
|
-
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "text-sm", children:
|
|
434
|
+
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "text-sm", children: t("crm.engagement.ladder") }) }),
|
|
435
435
|
/* @__PURE__ */ jsxs(CardContent, { className: "space-y-2", children: [
|
|
436
436
|
LADDER.map((row) => {
|
|
437
437
|
const n = d ? Number(d[row.key] ?? 0) : 0;
|
|
438
438
|
const pct = total > 0 ? Math.round(n / total * 100) : 0;
|
|
439
439
|
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", "data-testid": `lifecycle-${row.key}`, children: [
|
|
440
|
-
/* @__PURE__ */ jsx("span", { className: "w-28 shrink-0 text-xs text-muted-foreground", children:
|
|
440
|
+
/* @__PURE__ */ jsx("span", { className: "w-28 shrink-0 text-xs text-muted-foreground", children: t(row.labelKey) }),
|
|
441
441
|
/* @__PURE__ */ jsx("div", { className: "h-2 flex-1 overflow-hidden rounded-full bg-muted/40", children: /* @__PURE__ */ jsx("div", { className: `h-full rounded-full ${row.tone}`, style: { width: `${pct}%` } }) }),
|
|
442
442
|
/* @__PURE__ */ jsx("span", { className: "w-10 shrink-0 text-right text-xs font-medium", children: d ? n : "\xB7" })
|
|
443
443
|
] }, row.key);
|
|
444
444
|
}),
|
|
445
|
-
/* @__PURE__ */ jsx("p", { className: "pt-1 text-[10px] text-muted-foreground", children: d ?
|
|
445
|
+
/* @__PURE__ */ jsx("p", { className: "pt-1 text-[10px] text-muted-foreground", children: d ? t("crm.engagement.derivedNote", {
|
|
446
446
|
active: String(d.settings.activeDays),
|
|
447
447
|
risk: String(d.settings.atRiskDays)
|
|
448
448
|
}) : "" })
|
|
@@ -464,21 +464,21 @@ var QUOTE_STATUS = {
|
|
|
464
464
|
expired: "bg-warning"
|
|
465
465
|
};
|
|
466
466
|
function RecentLeadsTable() {
|
|
467
|
-
const
|
|
467
|
+
const t = useTranslation();
|
|
468
468
|
const leads2 = useCrmStore((s) => s.leads);
|
|
469
469
|
const fetchLeads = useCrmStore((s) => s.fetchLeads);
|
|
470
470
|
useEffect(() => {
|
|
471
471
|
void fetchLeads({ pageSize: 5 });
|
|
472
472
|
}, []);
|
|
473
473
|
const columns = [
|
|
474
|
-
{ accessorKey: "name", header:
|
|
474
|
+
{ accessorKey: "name", header: t("crm.dashboard.recentLeads"), cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "font-medium", children: row.original.name }) },
|
|
475
475
|
{ id: "contact", header: "", cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: row.original.email || row.original.phone || row.original.sourceName || "\u2014" }) },
|
|
476
476
|
{ accessorKey: "status", header: "", cell: ({ row }) => /* @__PURE__ */ jsx(StatusDot, { status: row.original.status, palette: LEAD_STATUS }) }
|
|
477
477
|
];
|
|
478
|
-
return /* @__PURE__ */ jsx(TableWidget, { title:
|
|
478
|
+
return /* @__PURE__ */ jsx(TableWidget, { title: t("crm.dashboard.recentLeads"), icon: "Users", columns, data: leads2.slice(0, 5), emptyMessage: t("crm.dashboard.noLeadsYet") });
|
|
479
479
|
}
|
|
480
480
|
function RecentQuotesTable() {
|
|
481
|
-
const
|
|
481
|
+
const t = useTranslation();
|
|
482
482
|
const { currency } = useCrmConfig();
|
|
483
483
|
const quotes2 = useCrmStore((s) => s.quotes);
|
|
484
484
|
const fetchQuotes = useCrmStore((s) => s.fetchQuotes);
|
|
@@ -486,28 +486,28 @@ function RecentQuotesTable() {
|
|
|
486
486
|
void fetchQuotes({ pageSize: 5 });
|
|
487
487
|
}, []);
|
|
488
488
|
const columns = [
|
|
489
|
-
{ accessorKey: "quoteNumber", header:
|
|
489
|
+
{ accessorKey: "quoteNumber", header: t("crm.dashboard.recentQuotes"), cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "font-medium", children: row.original.quoteNumber }) },
|
|
490
490
|
{ id: "contact", header: "", cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: row.original.contactName || "\u2014" }) },
|
|
491
491
|
{ accessorKey: "status", header: "", cell: ({ row }) => /* @__PURE__ */ jsx(StatusDot, { status: row.original.status, palette: QUOTE_STATUS }) },
|
|
492
492
|
{ accessorKey: "totalAmount", header: "", cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "font-semibold", children: formatCurrency(row.original.totalAmount, currency) }) }
|
|
493
493
|
];
|
|
494
|
-
return /* @__PURE__ */ jsx(TableWidget, { title:
|
|
494
|
+
return /* @__PURE__ */ jsx(TableWidget, { title: t("crm.dashboard.recentQuotes"), icon: "FileText", columns, data: quotes2.slice(0, 5), emptyMessage: t("crm.dashboard.noQuotesYet") });
|
|
495
495
|
}
|
|
496
496
|
function ActiveCustomersKpi() {
|
|
497
|
-
const
|
|
497
|
+
const t = useTranslation();
|
|
498
498
|
const d = useEngagement();
|
|
499
499
|
return /* @__PURE__ */ jsx(
|
|
500
500
|
KpiCard,
|
|
501
501
|
{
|
|
502
|
-
label:
|
|
502
|
+
label: t("crm.engagement.active"),
|
|
503
503
|
value: d ? String(d.active) : "\u2014",
|
|
504
504
|
icon: "UserCheck",
|
|
505
|
-
sub: d ?
|
|
505
|
+
sub: d ? t("crm.dashboard.activeSub", { days: String(d.settings.activeDays) }) : ""
|
|
506
506
|
}
|
|
507
507
|
);
|
|
508
508
|
}
|
|
509
509
|
function SourceConversionChart() {
|
|
510
|
-
const
|
|
510
|
+
const t = useTranslation();
|
|
511
511
|
const provider = useCrmProvider();
|
|
512
512
|
const [rows, setRows] = React.useState([]);
|
|
513
513
|
React.useEffect(() => {
|
|
@@ -523,20 +523,20 @@ function SourceConversionChart() {
|
|
|
523
523
|
return /* @__PURE__ */ jsx(
|
|
524
524
|
ChartWidget,
|
|
525
525
|
{
|
|
526
|
-
title:
|
|
526
|
+
title: t("crm.dashboard.bySource"),
|
|
527
527
|
icon: "Globe",
|
|
528
528
|
type: "bar",
|
|
529
529
|
data: rows.map((r) => ({ name: r.sourceName, leads: r.leads, converted: r.converted })),
|
|
530
530
|
categoryKey: "name",
|
|
531
531
|
series: [
|
|
532
|
-
{ dataKey: "leads", label:
|
|
533
|
-
{ dataKey: "converted", label:
|
|
532
|
+
{ dataKey: "leads", label: t("crm.dashboard.leadsLabel"), color: "hsl(var(--muted-foreground))" },
|
|
533
|
+
{ dataKey: "converted", label: t("crm.dashboard.convertedLabel"), color: "hsl(var(--magic))" }
|
|
534
534
|
]
|
|
535
535
|
}
|
|
536
536
|
);
|
|
537
537
|
}
|
|
538
538
|
function MonthlyTrendChart() {
|
|
539
|
-
const
|
|
539
|
+
const t = useTranslation();
|
|
540
540
|
const provider = useCrmProvider();
|
|
541
541
|
const [rows, setRows] = React.useState([]);
|
|
542
542
|
React.useEffect(() => {
|
|
@@ -552,14 +552,14 @@ function MonthlyTrendChart() {
|
|
|
552
552
|
return /* @__PURE__ */ jsx(
|
|
553
553
|
ChartWidget,
|
|
554
554
|
{
|
|
555
|
-
title:
|
|
555
|
+
title: t("crm.dashboard.monthly"),
|
|
556
556
|
icon: "TrendingUp",
|
|
557
557
|
type: "line",
|
|
558
558
|
data: rows.map((r) => ({ name: r.month, leads: r.leads, converted: r.converted })),
|
|
559
559
|
categoryKey: "name",
|
|
560
560
|
series: [
|
|
561
|
-
{ dataKey: "leads", label:
|
|
562
|
-
{ dataKey: "converted", label:
|
|
561
|
+
{ dataKey: "leads", label: t("crm.dashboard.leadsLabel"), color: "hsl(var(--muted-foreground))" },
|
|
562
|
+
{ dataKey: "converted", label: t("crm.dashboard.convertedLabel"), color: "hsl(var(--magic))" }
|
|
563
563
|
]
|
|
564
564
|
}
|
|
565
565
|
);
|
|
@@ -921,7 +921,7 @@ function createMockCrmProvider(options) {
|
|
|
921
921
|
results = results.filter((l) => l.name.toLowerCase().includes(s) || l.email?.toLowerCase().includes(s) || l.company?.toLowerCase().includes(s));
|
|
922
922
|
}
|
|
923
923
|
if (query.tags?.length) {
|
|
924
|
-
results = results.filter((l) => query.tags.every((
|
|
924
|
+
results = results.filter((l) => query.tags.every((t) => (l.tags ?? []).includes(t)));
|
|
925
925
|
}
|
|
926
926
|
if (query.assignedToId === "none") results = results.filter((l) => !l.assignedToId);
|
|
927
927
|
else if (query.assignedToId) results = results.filter((l) => l.assignedToId === query.assignedToId);
|
|
@@ -1001,11 +1001,11 @@ function createMockCrmProvider(options) {
|
|
|
1001
1001
|
async getDealsByStage(pipelineId, filter, knownStages, limits) {
|
|
1002
1002
|
const stages = knownStages ?? store.stages.filter((s) => s.pipelineId === pipelineId).sort((a, b) => a.order - b.order);
|
|
1003
1003
|
const matches = (d) => {
|
|
1004
|
-
if (filter?.tags?.length && !filter.tags.some((
|
|
1004
|
+
if (filter?.tags?.length && !filter.tags.some((t) => (d.tags ?? []).includes(t))) return false;
|
|
1005
1005
|
if (filter?.search) {
|
|
1006
|
-
const
|
|
1006
|
+
const t = filter.search.toLowerCase();
|
|
1007
1007
|
const campos = [d.title, d.contactName, d.notes, d.lostReason, d.stageName, d.contactStatusName];
|
|
1008
|
-
const porTexto = campos.some((c) => (c ?? "").toLowerCase().includes(
|
|
1008
|
+
const porTexto = campos.some((c) => (c ?? "").toLowerCase().includes(t));
|
|
1009
1009
|
const porTag = filter.searchTags?.some((slug) => (d.tags ?? []).includes(slug)) ?? false;
|
|
1010
1010
|
if (!porTexto && !porTag) return false;
|
|
1011
1011
|
}
|
|
@@ -1160,12 +1160,12 @@ function createMockCrmProvider(options) {
|
|
|
1160
1160
|
{ value: "task", label: "Task", icon: "CheckSquare" },
|
|
1161
1161
|
{ value: "whatsapp", label: "WhatsApp", icon: "MessageCircle" }
|
|
1162
1162
|
];
|
|
1163
|
-
return seed.map((
|
|
1163
|
+
return seed.map((t, i) => ({ id: `at-${i}`, name: t.label, icon: t.icon, isActive: true }));
|
|
1164
1164
|
},
|
|
1165
1165
|
async getTagDefs() {
|
|
1166
1166
|
const used = /* @__PURE__ */ new Set();
|
|
1167
|
-
for (const l of store.leads) for (const
|
|
1168
|
-
for (const d of store.deals) for (const
|
|
1167
|
+
for (const l of store.leads) for (const t of l.tags ?? []) used.add(t);
|
|
1168
|
+
for (const d of store.deals) for (const t of d.tags ?? []) used.add(t);
|
|
1169
1169
|
return [...used].sort().map((slug, i) => ({
|
|
1170
1170
|
id: `tag-${i}`,
|
|
1171
1171
|
slug,
|
|
@@ -1431,7 +1431,7 @@ function createMockCrmProvider(options) {
|
|
|
1431
1431
|
const yesno = of("yesno");
|
|
1432
1432
|
const promoters = nps.filter((a) => (a.rating ?? 0) >= 9).length;
|
|
1433
1433
|
const detractors = nps.filter((a) => (a.rating ?? 0) <= 6).length;
|
|
1434
|
-
const starAvg = stars.length > 0 ? stars.reduce((
|
|
1434
|
+
const starAvg = stars.length > 0 ? stars.reduce((t, a) => t + (a.rating ?? 0), 0) / stars.length : 0;
|
|
1435
1435
|
return {
|
|
1436
1436
|
surveyId: s.id,
|
|
1437
1437
|
responses: mockResponses.filter((r) => r.surveyId === s.id).length,
|
|
@@ -1971,7 +1971,7 @@ function createMockCrmProvider(options) {
|
|
|
1971
1971
|
async getFunnel(pipelineId, filter) {
|
|
1972
1972
|
const stages = store.stages.filter((s) => s.pipelineId === pipelineId && !s.isLost).sort((a, b) => a.order - b.order);
|
|
1973
1973
|
return stages.map((stage) => {
|
|
1974
|
-
const deals = store.deals.filter((d) => d.stageId === stage.id && (!filter?.tags?.length || (d.tags ?? []).some((
|
|
1974
|
+
const deals = store.deals.filter((d) => d.stageId === stage.id && (!filter?.tags?.length || (d.tags ?? []).some((t) => filter.tags.includes(t))) && (!filter?.assignedToId || (filter.assignedToId === "none" ? !d.assignedToId : d.assignedToId === filter.assignedToId)) && (!filter?.createdFrom || (d.createdAt ?? "") >= filter.createdFrom) && (!filter?.createdTo || (d.createdAt ?? "") <= filter.createdTo));
|
|
1975
1975
|
return {
|
|
1976
1976
|
stageId: stage.id,
|
|
1977
1977
|
stageName: stage.name,
|
|
@@ -2062,12 +2062,6 @@ function createMockCrmProvider(options) {
|
|
|
2062
2062
|
};
|
|
2063
2063
|
return provider;
|
|
2064
2064
|
}
|
|
2065
|
-
|
|
2066
|
-
// src/lib/tenant.ts
|
|
2067
|
-
var t;
|
|
2068
|
-
function getCrmTenantId() {
|
|
2069
|
-
return t;
|
|
2070
|
-
}
|
|
2071
2065
|
function serves(pipeline2, scope) {
|
|
2072
2066
|
const units = pipeline2.unitIds ?? [];
|
|
2073
2067
|
const teams = pipeline2.teamIds ?? [];
|
|
@@ -2243,7 +2237,7 @@ function slugifySegmentName(name) {
|
|
|
2243
2237
|
return base || `segmento-${Date.now().toString(36)}`;
|
|
2244
2238
|
}
|
|
2245
2239
|
function getTenantId() {
|
|
2246
|
-
return getActiveTenantId();
|
|
2240
|
+
return getCrmTenantId() ?? getActiveTenantId();
|
|
2247
2241
|
}
|
|
2248
2242
|
function humanizeTagSlug(slug) {
|
|
2249
2243
|
return slug.replace(/^[a-z]+:/, "").replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
@@ -2337,7 +2331,7 @@ function createSupabaseCrmProvider(options) {
|
|
|
2337
2331
|
typesSeeded.add(tenantId);
|
|
2338
2332
|
const { pub } = getClients();
|
|
2339
2333
|
await pub.from(T.activityTypes).upsert(
|
|
2340
|
-
seed.map((
|
|
2334
|
+
seed.map((t) => ({ tenant_id: tenantId, name: t.label, icon: t.icon ?? null, is_active: true })),
|
|
2341
2335
|
{ onConflict: "tenant_id,name", ignoreDuplicates: true }
|
|
2342
2336
|
);
|
|
2343
2337
|
}
|
|
@@ -2597,9 +2591,9 @@ function createSupabaseCrmProvider(options) {
|
|
|
2597
2591
|
qb = stage.isLost ? qb.neq("status", "archived") : qb.not("status", "in", "(lost,archived)");
|
|
2598
2592
|
if (filter?.tags?.length) qb = qb.overlaps("tags", filter.tags);
|
|
2599
2593
|
if (filter?.search) {
|
|
2600
|
-
const
|
|
2601
|
-
if (
|
|
2602
|
-
const ramos = BUSCA_NO_QUADRO.map((c) => `${c}.ilike.*${
|
|
2594
|
+
const t = filter.search.replace(/[(),]/g, " ").trim();
|
|
2595
|
+
if (t) {
|
|
2596
|
+
const ramos = BUSCA_NO_QUADRO.map((c) => `${c}.ilike.*${t}*`);
|
|
2603
2597
|
if (filter.searchTags?.length) ramos.push(`tags.ov.{${filter.searchTags.join(",")}}`);
|
|
2604
2598
|
qb = qb.or(ramos.join(","));
|
|
2605
2599
|
}
|
|
@@ -4356,10 +4350,10 @@ function createSupabaseCrmProvider(options) {
|
|
|
4356
4350
|
},
|
|
4357
4351
|
async searchCompanies(term, limit = 12) {
|
|
4358
4352
|
const { pub } = getClients();
|
|
4359
|
-
const
|
|
4360
|
-
if (
|
|
4361
|
-
const digits =
|
|
4362
|
-
const quoted = `"%${
|
|
4353
|
+
const t = term.trim();
|
|
4354
|
+
if (t.length < 2) return [];
|
|
4355
|
+
const digits = t.replace(/\D/g, "");
|
|
4356
|
+
const quoted = `"%${t.replace(/["\\]/g, "")}%"`;
|
|
4363
4357
|
const clauses = [`name.ilike.${quoted}`, `legal_name.ilike.${quoted}`];
|
|
4364
4358
|
if (digits.length >= 4) clauses.push(`document_number.ilike."%${digits}%"`);
|
|
4365
4359
|
const { data, error } = await pub.from(T.companies).select("id, name, document_number").or(clauses.join(",")).limit(limit);
|
|
@@ -7823,7 +7817,7 @@ var crmV1SettingsTabs = [
|
|
|
7823
7817
|
];
|
|
7824
7818
|
|
|
7825
7819
|
// src/index.ts
|
|
7826
|
-
var CrmPage = React.lazy(() => import('./CrmPage-
|
|
7820
|
+
var CrmPage = React.lazy(() => import('./CrmPage-QR3MSBZP.js').then((m) => ({ default: m.CrmPage })));
|
|
7827
7821
|
var CrmGeneralSettings = lazyComponent(() => import('./CrmGeneralSettings-6XPS3L42.js').then((m) => m.CrmGeneralSettings));
|
|
7828
7822
|
var SegmentsView = lazyComponent(() => import('./SegmentsView-PHLN2MOW.js').then((m) => m.SegmentsView));
|
|
7829
7823
|
var DEFAULT_LABELS = {
|