@fayz-ai/plugin-crm 0.36.0 → 0.38.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-T2HQ67N2.js → CrmPage-EAJCZ47X.js} +263 -111
- package/dist/CrmPage-EAJCZ47X.js.map +1 -0
- package/dist/{SegmentsView-52KIU7NZ.js → SegmentsView-JTFU6XWD.js} +30 -5
- package/dist/SegmentsView-JTFU6XWD.js.map +1 -0
- package/dist/{chunk-J6LYFSFJ.js → chunk-PZMJUORG.js} +5 -2
- package/dist/chunk-PZMJUORG.js.map +1 -0
- package/dist/components/SegmentEditorDialog.d.ts.map +1 -1
- package/dist/data/mock.d.ts.map +1 -1
- package/dist/data/registries.d.ts.map +1 -1
- package/dist/data/supabase.d.ts.map +1 -1
- package/dist/data/types.d.ts +3 -1
- package/dist/data/types.d.ts.map +1 -1
- package/dist/index.js +92 -10
- package/dist/index.js.map +1 -1
- package/dist/locales/en.d.ts.map +1 -1
- package/dist/locales/pt-BR.d.ts.map +1 -1
- package/dist/migrations/index.d.ts +2 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/main.browser.js +3 -1
- package/dist/migrations/main.browser.js.map +1 -1
- package/dist/migrations/main.js +411 -2
- package/dist/migrations/main.js.map +1 -1
- package/dist/schema/index.d.ts +17 -0
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema.cjs +1 -0
- package/dist/schema.cjs.map +1 -1
- package/dist/schema.js +1 -0
- package/dist/schema.js.map +1 -1
- package/dist/types.d.ts +24 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/views/CrmPage.d.ts.map +1 -1
- package/dist/views/PanelsViews.d.ts +4 -0
- package/dist/views/PanelsViews.d.ts.map +1 -0
- package/dist/views/dashboardWidgets.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/CrmPage-T2HQ67N2.js.map +0 -1
- package/dist/SegmentsView-52KIU7NZ.js.map +0 -1
- package/dist/chunk-J6LYFSFJ.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { documentKind, formatDocument, DEFAULT_ACTIVITY_TYPES, buildCrmRegistries, T, localPhoneKey, normalizeDocument, isValidDocument, documentRoot } from './chunk-
|
|
1
|
+
import { documentKind, formatDocument, DEFAULT_ACTIVITY_TYPES, buildCrmRegistries, T, localPhoneKey, normalizeDocument, isValidDocument, documentRoot } from './chunk-PZMJUORG.js';
|
|
2
2
|
import { getCrmTenantId, resolveSourceView, loadMyUserId, evaluateSegment, DEAL_VIEW } from './chunk-EHGAPCZF.js';
|
|
3
3
|
export { TagChips, humanizeTag } from './chunk-EHGAPCZF.js';
|
|
4
4
|
import { CrmContextProvider, useCrmConfig, useCrmStore, formatCurrency, useCrmProvider } from './chunk-7V46TYYX.js';
|
|
@@ -253,7 +253,7 @@ function OpenPipelineKpi() {
|
|
|
253
253
|
label: t("crm.dashboard.openPipeline"),
|
|
254
254
|
icon: "Target",
|
|
255
255
|
value: formatCurrency(summary?.openDealsValue ?? 0, currency),
|
|
256
|
-
sub: t("crm.dashboard.activeDeals", { count: String(summary?.totalDeals ?? 0) })
|
|
256
|
+
sub: t("crm.dashboard.activeDeals", { count: String(summary?.openDeals ?? summary?.totalDeals ?? 0) })
|
|
257
257
|
}
|
|
258
258
|
);
|
|
259
259
|
}
|
|
@@ -267,7 +267,7 @@ function ConversionRateKpi() {
|
|
|
267
267
|
label: t("crm.dashboard.conversionRate"),
|
|
268
268
|
icon: "TrendingUp",
|
|
269
269
|
value: `${(summary?.conversionRate ?? 0).toFixed(1)}%`,
|
|
270
|
-
sub: t("crm.dashboard.
|
|
270
|
+
sub: t("crm.dashboard.wonOfEntered", { won: String(summary?.wonDeals ?? 0), entered: String(summary?.enteredDeals ?? 0) })
|
|
271
271
|
}
|
|
272
272
|
);
|
|
273
273
|
}
|
|
@@ -328,7 +328,10 @@ function PerformancePanel() {
|
|
|
328
328
|
{ label: t("crm.dashboard.dealsWon"), value: String(summary?.wonDealsThisMonth ?? 0) },
|
|
329
329
|
{ label: t("crm.dashboard.revenueWon"), value: formatCurrency(summary?.wonDealsValueThisMonth ?? 0, currency), accent: true },
|
|
330
330
|
{ label: t("crm.dashboard.avgDealValue"), value: formatCurrency(summary?.averageDealValue ?? 0, currency) },
|
|
331
|
-
{ label: t("crm.dashboard.conversionRateLabel"), value: `${(summary?.conversionRate ?? 0).toFixed(1)}%` }
|
|
331
|
+
{ label: t("crm.dashboard.conversionRateLabel"), value: `${(summary?.conversionRate ?? 0).toFixed(1)}%` },
|
|
332
|
+
{ label: t("crm.dashboard.winRate"), value: summary?.winRate == null ? "\u2014" : `${summary.winRate.toFixed(1)}%` },
|
|
333
|
+
{ label: t("crm.dashboard.salesCycle"), value: summary?.avgCycleDays == null ? "\u2014" : t("crm.dashboard.days", { n: String(summary.avgCycleDays) }) },
|
|
334
|
+
{ label: t("crm.dashboard.parked"), value: String(summary?.parkedDeals ?? 0) }
|
|
332
335
|
];
|
|
333
336
|
return /* @__PURE__ */ jsxs(Card, { children: [
|
|
334
337
|
/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsxs(CardTitle, { className: "flex items-center gap-2", children: [
|
|
@@ -1767,6 +1770,26 @@ function createMockCrmProvider(options) {
|
|
|
1767
1770
|
const n = evaluateSegment(seg, mockPeopleRows()).length;
|
|
1768
1771
|
return { rows: n, people: n };
|
|
1769
1772
|
},
|
|
1773
|
+
async previewSegmentRows(sourceView, rules) {
|
|
1774
|
+
const seg = { kind: "rule", sourceView, rules };
|
|
1775
|
+
if (sourceView === DEAL_VIEW) {
|
|
1776
|
+
const rows = store.deals.map((d) => ({
|
|
1777
|
+
id: d.id,
|
|
1778
|
+
stage_name: d.stageName,
|
|
1779
|
+
deal_status: d.status,
|
|
1780
|
+
unit_id: d.unitId,
|
|
1781
|
+
tags: d.tags,
|
|
1782
|
+
owner_id: d.assignedToId,
|
|
1783
|
+
value: d.value,
|
|
1784
|
+
created_at: d.createdAt,
|
|
1785
|
+
updated_at: d.updatedAt
|
|
1786
|
+
}));
|
|
1787
|
+
const ids2 = new Set(evaluateSegment(seg, rows));
|
|
1788
|
+
return store.deals.filter((d) => ids2.has(d.id)).map((d) => ({ id: d.id, title: d.title, subtitle: d.contactName, stage: d.stageName }));
|
|
1789
|
+
}
|
|
1790
|
+
const ids = new Set(evaluateSegment(seg, mockPeopleRows()));
|
|
1791
|
+
return mockPeopleRows().filter((p) => ids.has(p.id)).map((p) => ({ id: p.id, title: String(p.name ?? "\u2014") }));
|
|
1792
|
+
},
|
|
1770
1793
|
async resolveSegmentDeals(id) {
|
|
1771
1794
|
const seg = (await provider.getSegments()).find((s) => s.id === id);
|
|
1772
1795
|
if (!seg || seg.sourceView !== DEAL_VIEW) return [];
|
|
@@ -3831,6 +3854,38 @@ function createSupabaseCrmProvider(options) {
|
|
|
3831
3854
|
const r = Array.isArray(data) ? data[0] : data;
|
|
3832
3855
|
return { rows: Number(r?.rows_count ?? 0), people: Number(r?.people_count ?? 0) };
|
|
3833
3856
|
},
|
|
3857
|
+
async previewSegmentRows(sourceView, rules, unitId) {
|
|
3858
|
+
const { pub } = getClients();
|
|
3859
|
+
const { data, error } = await pub.rpc("crm_segment_preview_rows", {
|
|
3860
|
+
p_source_view: sourceView,
|
|
3861
|
+
p_rules: rules,
|
|
3862
|
+
p_unit: unitId ?? null,
|
|
3863
|
+
p_limit: 500
|
|
3864
|
+
});
|
|
3865
|
+
if (error) throw new Error(error.message);
|
|
3866
|
+
const ids = (data ?? []).map((r) => String(r.id));
|
|
3867
|
+
if (!ids.length) return [];
|
|
3868
|
+
const out = [];
|
|
3869
|
+
for (let i = 0; i < ids.length; i += 200) {
|
|
3870
|
+
const chunk = ids.slice(i, i + 200);
|
|
3871
|
+
if (sourceView === "v_crm_deal_audience") {
|
|
3872
|
+
const { data: rows } = await pub.from("v_deals").select("id, title, company_name, group_name, contact_name, stage_name, stage_color").in("id", chunk);
|
|
3873
|
+
for (const d of rows ?? []) {
|
|
3874
|
+
out.push({
|
|
3875
|
+
id: d.id,
|
|
3876
|
+
title: d.group_name ?? d.company_name ?? d.title ?? "\u2014",
|
|
3877
|
+
subtitle: d.contact_name ?? void 0,
|
|
3878
|
+
stage: d.stage_name ?? void 0,
|
|
3879
|
+
stageColor: d.stage_color ?? void 0
|
|
3880
|
+
});
|
|
3881
|
+
}
|
|
3882
|
+
} else {
|
|
3883
|
+
const { data: rows } = await pub.from("people").select("id, name, phone, email").in("id", chunk);
|
|
3884
|
+
for (const p of rows ?? []) out.push({ id: p.id, title: p.name ?? "\u2014", subtitle: p.phone ?? p.email ?? void 0 });
|
|
3885
|
+
}
|
|
3886
|
+
}
|
|
3887
|
+
return out.sort((a, b) => a.title.localeCompare(b.title));
|
|
3888
|
+
},
|
|
3834
3889
|
async resolveSegmentDeals(id) {
|
|
3835
3890
|
const { pub } = getClients();
|
|
3836
3891
|
const { data, error } = await pub.rpc("crm_resolve_segment_deals", { p_segment_id: id });
|
|
@@ -3845,13 +3900,15 @@ function createSupabaseCrmProvider(options) {
|
|
|
3845
3900
|
},
|
|
3846
3901
|
async getSummary() {
|
|
3847
3902
|
const { pub } = getClients();
|
|
3848
|
-
const { data, error } = await pub.rpc("
|
|
3903
|
+
const { data, error } = await pub.rpc("crm_flow_summary");
|
|
3849
3904
|
if (error) throw new Error(error.message);
|
|
3850
3905
|
const r = Array.isArray(data) ? data[0] : data;
|
|
3851
3906
|
if (!r) throw new Error("crm_summary sem resposta");
|
|
3852
3907
|
const totalLeads = Number(r.total_leads ?? 0);
|
|
3853
3908
|
const totalDeals = Number(r.total_deals ?? 0);
|
|
3854
3909
|
const wonDeals = Number(r.won_deals ?? 0);
|
|
3910
|
+
const lostDeals = Number(r.lost_deals ?? 0);
|
|
3911
|
+
const entered = Number(r.entered_deals ?? totalDeals);
|
|
3855
3912
|
return {
|
|
3856
3913
|
totalLeads,
|
|
3857
3914
|
newLeadsThisMonth: Number(r.new_leads_this_month ?? 0),
|
|
@@ -3859,10 +3916,19 @@ function createSupabaseCrmProvider(options) {
|
|
|
3859
3916
|
openDealsValue: Number(r.open_deals_value ?? 0),
|
|
3860
3917
|
wonDealsThisMonth: Number(r.won_deals_this_month ?? 0),
|
|
3861
3918
|
wonDealsValueThisMonth: Number(r.won_deals_value_this_month ?? 0),
|
|
3862
|
-
|
|
3919
|
+
// A WON deal is the conversion (067): won ÷ deals in the flow. The old
|
|
3920
|
+
// deals ÷ leads read 101% where every lead gets a deal on arrival.
|
|
3921
|
+
conversionRate: entered > 0 ? wonDeals / entered * 100 : 0,
|
|
3863
3922
|
averageDealValue: wonDeals > 0 ? Number(r.won_deals_value ?? 0) / wonDeals : 0,
|
|
3864
3923
|
pendingActivities: Number(r.pending_activities ?? 0),
|
|
3865
|
-
overdueActivities: Number(r.overdue_activities ?? 0)
|
|
3924
|
+
overdueActivities: Number(r.overdue_activities ?? 0),
|
|
3925
|
+
enteredDeals: entered,
|
|
3926
|
+
openDeals: Number(r.open_deals ?? 0),
|
|
3927
|
+
parkedDeals: Number(r.parked_deals ?? 0),
|
|
3928
|
+
wonDeals,
|
|
3929
|
+
lostDeals,
|
|
3930
|
+
winRate: wonDeals + lostDeals > 0 ? wonDeals / (wonDeals + lostDeals) * 100 : null,
|
|
3931
|
+
avgCycleDays: r.avg_cycle_days == null ? null : Number(r.avg_cycle_days)
|
|
3866
3932
|
};
|
|
3867
3933
|
},
|
|
3868
3934
|
// ── empresas ────────────────────────────────────────────────────────
|
|
@@ -4070,7 +4136,7 @@ function createSupabaseCrmProvider(options) {
|
|
|
4070
4136
|
for (const r of data ?? []) {
|
|
4071
4137
|
porEtapa.set(r.stage_id, { deals: Number(r.deals ?? 0), total: Number(r.total_value ?? 0) });
|
|
4072
4138
|
}
|
|
4073
|
-
return stages.filter((s) => !s.isLost).map((stage) => {
|
|
4139
|
+
return stages.filter((s) => !s.isLost && !s.isParked).map((stage) => {
|
|
4074
4140
|
const n = porEtapa.get(stage.id);
|
|
4075
4141
|
return {
|
|
4076
4142
|
stageId: stage.id,
|
|
@@ -5524,6 +5590,11 @@ var en = {
|
|
|
5524
5590
|
"crm.dashboard.avgDealValue": "Avg deal value",
|
|
5525
5591
|
"crm.dashboard.leadsCount": "{{count}} leads",
|
|
5526
5592
|
"crm.dashboard.quotesCount": "{{count}} quotes",
|
|
5593
|
+
"crm.dashboard.wonOfEntered": "{{won}} won of {{entered}} deals in the flow",
|
|
5594
|
+
"crm.dashboard.winRate": "Win rate (won \xF7 closed)",
|
|
5595
|
+
"crm.dashboard.salesCycle": "Sales cycle",
|
|
5596
|
+
"crm.dashboard.days": "{{n}} days",
|
|
5597
|
+
"crm.dashboard.parked": "Waiting (outside the funnel)",
|
|
5527
5598
|
"crm.dashboard.conversionRate": "Conversion Rate",
|
|
5528
5599
|
"crm.dashboard.conversionRateLabel": "Conversion rate",
|
|
5529
5600
|
"crm.dashboard.createFirstLead": "Create your first lead to see the funnel",
|
|
@@ -6222,6 +6293,9 @@ var en = {
|
|
|
6222
6293
|
"crm.segments.dealStatus.archived": "Archived",
|
|
6223
6294
|
"crm.segments.kind.lead": "Lead",
|
|
6224
6295
|
"crm.segments.kind.customer": "Customer",
|
|
6296
|
+
"crm.segments.showList": "Show list",
|
|
6297
|
+
"crm.segments.hideList": "Hide list",
|
|
6298
|
+
"crm.segments.listCapped": "Showing the first {{shown}}.",
|
|
6225
6299
|
"crm.segments.title": "Segments",
|
|
6226
6300
|
"crm.segments.subtitle": "Named cuts of people \u2014 what a campaign points at, instead of a filter in the URL.",
|
|
6227
6301
|
"crm.segments.new": "New segment",
|
|
@@ -6590,6 +6664,11 @@ var ptBR = {
|
|
|
6590
6664
|
"crm.dashboard.avgDealValue": "Valor m\xE9dio do neg\xF3cio",
|
|
6591
6665
|
"crm.dashboard.leadsCount": "{{count}} leads",
|
|
6592
6666
|
"crm.dashboard.quotesCount": "{{count}} or\xE7amentos",
|
|
6667
|
+
"crm.dashboard.wonOfEntered": "{{won}} ganhos de {{entered}} neg\xF3cios no fluxo",
|
|
6668
|
+
"crm.dashboard.winRate": "Taxa de vit\xF3ria (ganhos \xF7 fechados)",
|
|
6669
|
+
"crm.dashboard.salesCycle": "Ciclo de venda",
|
|
6670
|
+
"crm.dashboard.days": "{{n}} dias",
|
|
6671
|
+
"crm.dashboard.parked": "Em espera (fora do funil)",
|
|
6593
6672
|
"crm.dashboard.conversionRate": "Taxa de Convers\xE3o",
|
|
6594
6673
|
"crm.dashboard.conversionRateLabel": "Taxa de convers\xE3o",
|
|
6595
6674
|
"crm.dashboard.createFirstLead": "Crie seu primeiro lead para ver o funil",
|
|
@@ -7288,6 +7367,9 @@ var ptBR = {
|
|
|
7288
7367
|
"crm.segments.dealStatus.archived": "Arquivado",
|
|
7289
7368
|
"crm.segments.kind.lead": "Lead",
|
|
7290
7369
|
"crm.segments.kind.customer": "Cliente",
|
|
7370
|
+
"crm.segments.showList": "Ver lista",
|
|
7371
|
+
"crm.segments.hideList": "Ocultar lista",
|
|
7372
|
+
"crm.segments.listCapped": "Mostrando os primeiros {{shown}}.",
|
|
7291
7373
|
"crm.segments.title": "Segmentos",
|
|
7292
7374
|
"crm.segments.subtitle": "Recortes de pessoas com nome \u2014 o que uma campanha aponta, em vez de um filtro no endere\xE7o.",
|
|
7293
7375
|
"crm.segments.new": "Novo segmento",
|
|
@@ -7962,9 +8044,9 @@ var crmV1SettingsTabs = [
|
|
|
7962
8044
|
];
|
|
7963
8045
|
|
|
7964
8046
|
// src/index.ts
|
|
7965
|
-
var CrmPage = React2.lazy(() => import('./CrmPage-
|
|
8047
|
+
var CrmPage = React2.lazy(() => import('./CrmPage-EAJCZ47X.js').then((m) => ({ default: m.CrmPage })));
|
|
7966
8048
|
var CrmGeneralSettings = lazyComponent(() => import('./CrmGeneralSettings-6XPS3L42.js').then((m) => m.CrmGeneralSettings));
|
|
7967
|
-
var SegmentsView = lazyComponent(() => import('./SegmentsView-
|
|
8049
|
+
var SegmentsView = lazyComponent(() => import('./SegmentsView-JTFU6XWD.js').then((m) => m.SegmentsView));
|
|
7968
8050
|
var DEFAULT_LABELS = {
|
|
7969
8051
|
pageTitle: "Sales",
|
|
7970
8052
|
pageSubtitle: "CRM, leads, deals, and pipeline management"
|