@fayz-ai/plugin-crm 0.35.1 → 0.36.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-Z5OYCBKA.js → CrmPage-T2HQ67N2.js} +92 -127
- package/dist/CrmPage-T2HQ67N2.js.map +1 -0
- package/dist/SegmentsView-52KIU7NZ.js +489 -0
- package/dist/SegmentsView-52KIU7NZ.js.map +1 -0
- package/dist/chunk-EHGAPCZF.js +264 -0
- package/dist/chunk-EHGAPCZF.js.map +1 -0
- package/dist/{chunk-LDBCC67C.js → chunk-J6LYFSFJ.js} +24 -130
- package/dist/chunk-J6LYFSFJ.js.map +1 -0
- package/dist/chunk-VFLS65NL.js +51 -0
- package/dist/chunk-VFLS65NL.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/supabase.d.ts.map +1 -1
- package/dist/data/types.d.ts +5 -1
- package/dist/data/types.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +154 -20
- package/dist/index.js.map +1 -1
- package/dist/lib/segments.d.ts +13 -6
- package/dist/lib/segments.d.ts.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 +390 -2
- package/dist/migrations/main.js.map +1 -1
- package/dist/types.d.ts +20 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/views/DealListView.d.ts.map +1 -1
- package/dist/views/SegmentsView.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/CrmPage-Z5OYCBKA.js.map +0 -1
- package/dist/SegmentsView-PHLN2MOW.js +0 -385
- package/dist/SegmentsView-PHLN2MOW.js.map +0 -1
- package/dist/chunk-LDBCC67C.js.map +0 -1
- package/dist/chunk-QJOLAGGN.js +0 -129
- package/dist/chunk-QJOLAGGN.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { documentKind, formatDocument, DEFAULT_ACTIVITY_TYPES, buildCrmRegistries,
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { documentKind, formatDocument, DEFAULT_ACTIVITY_TYPES, buildCrmRegistries, T, localPhoneKey, normalizeDocument, isValidDocument, documentRoot } from './chunk-J6LYFSFJ.js';
|
|
2
|
+
import { getCrmTenantId, resolveSourceView, loadMyUserId, evaluateSegment, DEAL_VIEW } from './chunk-EHGAPCZF.js';
|
|
3
|
+
export { TagChips, humanizeTag } from './chunk-EHGAPCZF.js';
|
|
4
4
|
import { CrmContextProvider, useCrmConfig, useCrmStore, formatCurrency, useCrmProvider } from './chunk-7V46TYYX.js';
|
|
5
|
-
import
|
|
5
|
+
import React2, { useEffect } from 'react';
|
|
6
6
|
import { tl, lazyComponent, RECORD_GROUP, recordRailFields, activeFacet, registerTranslations, registerMessageDefaults, createSafeDataProvider, getSupabaseClientOptional, getActiveTenantId, countByTenant, getActiveUnitId, useTranslation } from '@fayz-ai/core';
|
|
7
7
|
import { defineSettingsTab, registrySettingsParent, createCrudPage, PluginSettingsPanel, registerTimelineSource, dedup } from '@fayz-ai/admin';
|
|
8
8
|
import { toast, defineKpiWidget, defineChartWidget, defineCustomWidget, defineTableWidget, KpiCard, ChartWidget, Card, CardHeader, CardTitle, CardContent, TableWidget } from '@fayz-ai/ui';
|
|
@@ -343,7 +343,7 @@ function PerformancePanel() {
|
|
|
343
343
|
}
|
|
344
344
|
function NpsKpi() {
|
|
345
345
|
const provider = useCrmProvider();
|
|
346
|
-
const [stats, setStats] =
|
|
346
|
+
const [stats, setStats] = React2.useState(null);
|
|
347
347
|
useEffect(() => {
|
|
348
348
|
let cancelled = false;
|
|
349
349
|
void provider.getSurveyStats().then((s) => {
|
|
@@ -377,8 +377,8 @@ function NpsKpi() {
|
|
|
377
377
|
}
|
|
378
378
|
function useEngagement() {
|
|
379
379
|
const provider = useCrmProvider();
|
|
380
|
-
const [data, setData] =
|
|
381
|
-
|
|
380
|
+
const [data, setData] = React2.useState(null);
|
|
381
|
+
React2.useEffect(() => {
|
|
382
382
|
let alive = true;
|
|
383
383
|
provider.getEngagementSummary().then((d) => {
|
|
384
384
|
if (alive) setData(d);
|
|
@@ -509,8 +509,8 @@ function ActiveCustomersKpi() {
|
|
|
509
509
|
function SourceConversionChart() {
|
|
510
510
|
const t = useTranslation();
|
|
511
511
|
const provider = useCrmProvider();
|
|
512
|
-
const [rows, setRows] =
|
|
513
|
-
|
|
512
|
+
const [rows, setRows] = React2.useState([]);
|
|
513
|
+
React2.useEffect(() => {
|
|
514
514
|
let alive = true;
|
|
515
515
|
provider.getSourceConversion(90).then((r) => {
|
|
516
516
|
if (alive) setRows(r);
|
|
@@ -538,8 +538,8 @@ function SourceConversionChart() {
|
|
|
538
538
|
function MonthlyTrendChart() {
|
|
539
539
|
const t = useTranslation();
|
|
540
540
|
const provider = useCrmProvider();
|
|
541
|
-
const [rows, setRows] =
|
|
542
|
-
|
|
541
|
+
const [rows, setRows] = React2.useState([]);
|
|
542
|
+
React2.useEffect(() => {
|
|
543
543
|
let alive = true;
|
|
544
544
|
provider.getMonthlySeries(6).then((r) => {
|
|
545
545
|
if (alive) setRows(r);
|
|
@@ -1746,6 +1746,43 @@ function createMockCrmProvider(options) {
|
|
|
1746
1746
|
if (i >= 0 && mockSegments[i].isSystem) throw new Error("Segmento do sistema n\xE3o pode ser apagado.");
|
|
1747
1747
|
if (i >= 0) mockSegments.splice(i, 1);
|
|
1748
1748
|
},
|
|
1749
|
+
async previewSegment(sourceView, rules) {
|
|
1750
|
+
const seg = { kind: "rule", sourceView, rules };
|
|
1751
|
+
if (sourceView === DEAL_VIEW) {
|
|
1752
|
+
const rows = store.deals.map((d) => ({
|
|
1753
|
+
id: d.id,
|
|
1754
|
+
person_id: d.contactId,
|
|
1755
|
+
stage_name: d.stageName,
|
|
1756
|
+
deal_status: d.status,
|
|
1757
|
+
unit_id: d.unitId,
|
|
1758
|
+
tags: d.tags,
|
|
1759
|
+
owner_id: d.assignedToId,
|
|
1760
|
+
value: d.value,
|
|
1761
|
+
created_at: d.createdAt,
|
|
1762
|
+
updated_at: d.updatedAt
|
|
1763
|
+
}));
|
|
1764
|
+
const ids = new Set(evaluateSegment(seg, rows));
|
|
1765
|
+
return { rows: ids.size, people: new Set(rows.filter((r) => ids.has(r.id)).map((r) => r.person_id)).size };
|
|
1766
|
+
}
|
|
1767
|
+
const n = evaluateSegment(seg, mockPeopleRows()).length;
|
|
1768
|
+
return { rows: n, people: n };
|
|
1769
|
+
},
|
|
1770
|
+
async resolveSegmentDeals(id) {
|
|
1771
|
+
const seg = (await provider.getSegments()).find((s) => s.id === id);
|
|
1772
|
+
if (!seg || seg.sourceView !== DEAL_VIEW) return [];
|
|
1773
|
+
const rows = store.deals.map((d) => ({
|
|
1774
|
+
id: d.id,
|
|
1775
|
+
stage_name: d.stageName,
|
|
1776
|
+
deal_status: d.status,
|
|
1777
|
+
unit_id: d.unitId,
|
|
1778
|
+
tags: d.tags,
|
|
1779
|
+
owner_id: d.assignedToId,
|
|
1780
|
+
value: d.value,
|
|
1781
|
+
created_at: d.createdAt,
|
|
1782
|
+
updated_at: d.updatedAt
|
|
1783
|
+
}));
|
|
1784
|
+
return evaluateSegment(seg, rows);
|
|
1785
|
+
},
|
|
1749
1786
|
async resolveSegment(id) {
|
|
1750
1787
|
const segs = await provider.getSegments();
|
|
1751
1788
|
const seg = segs.find((s) => s.id === id);
|
|
@@ -2220,7 +2257,11 @@ function toSegment(row) {
|
|
|
2220
2257
|
description: row.description ?? void 0,
|
|
2221
2258
|
kind: row.kind === "list" ? "list" : "rule",
|
|
2222
2259
|
sourceView: row.source_view ?? "people",
|
|
2223
|
-
rules: {
|
|
2260
|
+
rules: {
|
|
2261
|
+
where: Array.isArray(rules?.where) ? rules.where : [],
|
|
2262
|
+
...Array.isArray(rules?.any) && rules.any.length ? { any: rules.any } : {},
|
|
2263
|
+
...Array.isArray(rules?.none) && rules.none.length ? { none: rules.none } : {}
|
|
2264
|
+
},
|
|
2224
2265
|
color: row.color ?? void 0,
|
|
2225
2266
|
icon: row.icon ?? void 0,
|
|
2226
2267
|
isSystem: row.is_system === true,
|
|
@@ -3779,6 +3820,23 @@ function createSupabaseCrmProvider(options) {
|
|
|
3779
3820
|
const { error } = await pub.from(T.segments).delete().eq("id", id);
|
|
3780
3821
|
if (error) throw new Error(error.message);
|
|
3781
3822
|
},
|
|
3823
|
+
async previewSegment(sourceView, rules, unitId) {
|
|
3824
|
+
const { pub } = getClients();
|
|
3825
|
+
const { data, error } = await pub.rpc("crm_segment_preview", {
|
|
3826
|
+
p_source_view: sourceView,
|
|
3827
|
+
p_rules: rules,
|
|
3828
|
+
p_unit: unitId ?? null
|
|
3829
|
+
});
|
|
3830
|
+
if (error) throw new Error(error.message);
|
|
3831
|
+
const r = Array.isArray(data) ? data[0] : data;
|
|
3832
|
+
return { rows: Number(r?.rows_count ?? 0), people: Number(r?.people_count ?? 0) };
|
|
3833
|
+
},
|
|
3834
|
+
async resolveSegmentDeals(id) {
|
|
3835
|
+
const { pub } = getClients();
|
|
3836
|
+
const { data, error } = await pub.rpc("crm_resolve_segment_deals", { p_segment_id: id });
|
|
3837
|
+
if (error) throw new Error(error.message);
|
|
3838
|
+
return (data ?? []).map((r) => typeof r === "string" ? r : r.deal_id);
|
|
3839
|
+
},
|
|
3782
3840
|
async resolveSegment(id) {
|
|
3783
3841
|
const { pub } = getClients();
|
|
3784
3842
|
const { data, error } = await pub.rpc("crm_resolve_segment", { p_segment_id: id });
|
|
@@ -6129,6 +6187,41 @@ var en = {
|
|
|
6129
6187
|
"crm.partners.allUnits": "All",
|
|
6130
6188
|
"crm.partners.unitCount": "{{count}} unit(s)",
|
|
6131
6189
|
"crm.partners.noUnits": "No units registered. The partnership applies network-wide.",
|
|
6190
|
+
"crm.segments.editorDescriptionGroups": "Build the segment from conditions in three groups: all must match, any one is enough, and exclusions.",
|
|
6191
|
+
"crm.segments.audience.label": "Who the segment is about",
|
|
6192
|
+
"crm.segments.audience.people": "People",
|
|
6193
|
+
"crm.segments.audience.deals": "Deals",
|
|
6194
|
+
"crm.segments.audience.peopleHint": "The person's record: type, tags, city, birthday, purchases.",
|
|
6195
|
+
"crm.segments.audience.dealsHint": "The funnel: stage, unit, status, owner and the deal's tags. A campaign talks to each deal's contacts.",
|
|
6196
|
+
"crm.segments.group.where": "Must match ALL",
|
|
6197
|
+
"crm.segments.group.whereHint": "AND",
|
|
6198
|
+
"crm.segments.group.any": "Match ANY ONE of these",
|
|
6199
|
+
"crm.segments.group.anyHint": "OR \u2014 leave empty if not needed",
|
|
6200
|
+
"crm.segments.group.none": "Must match NONE of these",
|
|
6201
|
+
"crm.segments.group.noneHint": "exclusion",
|
|
6202
|
+
"crm.segments.group.anyShort": "any of",
|
|
6203
|
+
"crm.segments.group.noneShort": "except",
|
|
6204
|
+
"crm.segments.pick": "Choose\u2026",
|
|
6205
|
+
"crm.segments.search": "Search\u2026",
|
|
6206
|
+
"crm.segments.noOptions": "Nothing found",
|
|
6207
|
+
"crm.segments.previewIncomplete": "Complete the conditions to see how many match.",
|
|
6208
|
+
"crm.segments.previewDeals": "{{deals}} deals now \xB7 {{people}} people",
|
|
6209
|
+
"crm.segments.previewPeople": "{{count}} people now",
|
|
6210
|
+
"crm.segments.field.stage": "Funnel stage",
|
|
6211
|
+
"crm.segments.field.dealStatus": "Deal status",
|
|
6212
|
+
"crm.segments.field.unit": "Unit",
|
|
6213
|
+
"crm.segments.field.owner": "Owner",
|
|
6214
|
+
"crm.segments.field.value": "Value",
|
|
6215
|
+
"crm.segments.field.dealCreatedAt": "Deal created",
|
|
6216
|
+
"crm.segments.field.dealUpdatedAt": "Deal touched",
|
|
6217
|
+
"crm.segments.op.has_any_tag": "has any of the tags",
|
|
6218
|
+
"crm.segments.rule.hasAnyTag": "has any of: {{value}}",
|
|
6219
|
+
"crm.segments.dealStatus.open": "Open",
|
|
6220
|
+
"crm.segments.dealStatus.won": "Won",
|
|
6221
|
+
"crm.segments.dealStatus.lost": "Lost",
|
|
6222
|
+
"crm.segments.dealStatus.archived": "Archived",
|
|
6223
|
+
"crm.segments.kind.lead": "Lead",
|
|
6224
|
+
"crm.segments.kind.customer": "Customer",
|
|
6132
6225
|
"crm.segments.title": "Segments",
|
|
6133
6226
|
"crm.segments.subtitle": "Named cuts of people \u2014 what a campaign points at, instead of a filter in the URL.",
|
|
6134
6227
|
"crm.segments.new": "New segment",
|
|
@@ -7160,6 +7253,41 @@ var ptBR = {
|
|
|
7160
7253
|
"crm.partners.allUnits": "Todas",
|
|
7161
7254
|
"crm.partners.unitCount": "{{count}} unidade(s)",
|
|
7162
7255
|
"crm.partners.noUnits": "Nenhuma unidade cadastrada. A parceria vale na rede inteira.",
|
|
7256
|
+
"crm.segments.editorDescriptionGroups": "Monte o recorte com condi\xE7\xF5es em tr\xEAs grupos: as que todos precisam atender, as que basta atender uma, e as que excluem.",
|
|
7257
|
+
"crm.segments.audience.label": "Sobre quem \xE9 o recorte",
|
|
7258
|
+
"crm.segments.audience.people": "Pessoas",
|
|
7259
|
+
"crm.segments.audience.deals": "Neg\xF3cios",
|
|
7260
|
+
"crm.segments.audience.peopleHint": "Cadastro da pessoa: tipo, etiquetas, cidade, anivers\xE1rio, compras.",
|
|
7261
|
+
"crm.segments.audience.dealsHint": "O funil: etapa, unidade, status, respons\xE1vel e etiquetas do neg\xF3cio. A campanha fala com os contatos de cada neg\xF3cio.",
|
|
7262
|
+
"crm.segments.group.where": "Precisa atender TODAS",
|
|
7263
|
+
"crm.segments.group.whereHint": "E",
|
|
7264
|
+
"crm.segments.group.any": "Basta atender UMA destas",
|
|
7265
|
+
"crm.segments.group.anyHint": "OU \u2014 deixe vazio se n\xE3o precisar",
|
|
7266
|
+
"crm.segments.group.none": "N\xC3O pode atender nenhuma destas",
|
|
7267
|
+
"crm.segments.group.noneHint": "exclus\xE3o",
|
|
7268
|
+
"crm.segments.group.anyShort": "uma de",
|
|
7269
|
+
"crm.segments.group.noneShort": "exceto",
|
|
7270
|
+
"crm.segments.pick": "Escolher\u2026",
|
|
7271
|
+
"crm.segments.search": "Buscar\u2026",
|
|
7272
|
+
"crm.segments.noOptions": "Nada encontrado",
|
|
7273
|
+
"crm.segments.previewIncomplete": "Complete as condi\xE7\xF5es para ver quantos entram.",
|
|
7274
|
+
"crm.segments.previewDeals": "{{deals}} neg\xF3cios agora \xB7 {{people}} pessoas",
|
|
7275
|
+
"crm.segments.previewPeople": "{{count}} pessoas agora",
|
|
7276
|
+
"crm.segments.field.stage": "Etapa do funil",
|
|
7277
|
+
"crm.segments.field.dealStatus": "Situa\xE7\xE3o do neg\xF3cio",
|
|
7278
|
+
"crm.segments.field.unit": "Unidade",
|
|
7279
|
+
"crm.segments.field.owner": "Respons\xE1vel",
|
|
7280
|
+
"crm.segments.field.value": "Valor",
|
|
7281
|
+
"crm.segments.field.dealCreatedAt": "Neg\xF3cio criado",
|
|
7282
|
+
"crm.segments.field.dealUpdatedAt": "Neg\xF3cio mexido",
|
|
7283
|
+
"crm.segments.op.has_any_tag": "tem alguma das etiquetas",
|
|
7284
|
+
"crm.segments.rule.hasAnyTag": "tem alguma de: {{value}}",
|
|
7285
|
+
"crm.segments.dealStatus.open": "Aberto",
|
|
7286
|
+
"crm.segments.dealStatus.won": "Ganho",
|
|
7287
|
+
"crm.segments.dealStatus.lost": "Perdido",
|
|
7288
|
+
"crm.segments.dealStatus.archived": "Arquivado",
|
|
7289
|
+
"crm.segments.kind.lead": "Lead",
|
|
7290
|
+
"crm.segments.kind.customer": "Cliente",
|
|
7163
7291
|
"crm.segments.title": "Segmentos",
|
|
7164
7292
|
"crm.segments.subtitle": "Recortes de pessoas com nome \u2014 o que uma campanha aponta, em vez de um filtro no endere\xE7o.",
|
|
7165
7293
|
"crm.segments.new": "Novo segmento",
|
|
@@ -7834,9 +7962,9 @@ var crmV1SettingsTabs = [
|
|
|
7834
7962
|
];
|
|
7835
7963
|
|
|
7836
7964
|
// src/index.ts
|
|
7837
|
-
var CrmPage =
|
|
7965
|
+
var CrmPage = React2.lazy(() => import('./CrmPage-T2HQ67N2.js').then((m) => ({ default: m.CrmPage })));
|
|
7838
7966
|
var CrmGeneralSettings = lazyComponent(() => import('./CrmGeneralSettings-6XPS3L42.js').then((m) => m.CrmGeneralSettings));
|
|
7839
|
-
var SegmentsView = lazyComponent(() => import('./SegmentsView-
|
|
7967
|
+
var SegmentsView = lazyComponent(() => import('./SegmentsView-52KIU7NZ.js').then((m) => m.SegmentsView));
|
|
7840
7968
|
var DEFAULT_LABELS = {
|
|
7841
7969
|
pageTitle: "Sales",
|
|
7842
7970
|
pageSubtitle: "CRM, leads, deals, and pipeline management"
|
|
@@ -7879,6 +8007,11 @@ function resolveConfig(options) {
|
|
|
7879
8007
|
talkChannel: options?.talkChannel ?? "whatsapp"
|
|
7880
8008
|
};
|
|
7881
8009
|
}
|
|
8010
|
+
var segmentsSurface = null;
|
|
8011
|
+
function CrmSegmentsSurface() {
|
|
8012
|
+
const Surface = segmentsSurface;
|
|
8013
|
+
return Surface ? React2.createElement(Surface) : null;
|
|
8014
|
+
}
|
|
7882
8015
|
function createCrmPlugin(options) {
|
|
7883
8016
|
const config = resolveConfig(options);
|
|
7884
8017
|
registerTranslations(crmLocales);
|
|
@@ -7891,7 +8024,8 @@ function createCrmPlugin(options) {
|
|
|
7891
8024
|
() => createMockCrmProvider({ activityTypes })
|
|
7892
8025
|
);
|
|
7893
8026
|
const store = createCrmStore(provider);
|
|
7894
|
-
|
|
8027
|
+
segmentsSurface = () => React2.createElement(CrmContextProvider, { config, provider, store }, React2.createElement(SegmentsView));
|
|
8028
|
+
const PageComponent = () => React2.createElement(CrmPage, { config, provider, store, registries: crmRegistries });
|
|
7895
8029
|
const dashboardWidgets = createCrmDashboardWidgets({ config, provider, store });
|
|
7896
8030
|
const vocab = customerVocabulary(options?.tenantVerticalId);
|
|
7897
8031
|
const customerOne = config.labels.customersSingular ?? vocab.one;
|
|
@@ -8416,12 +8550,12 @@ function createCrmPlugin(options) {
|
|
|
8416
8550
|
label: "Sales & CRM",
|
|
8417
8551
|
icon: "Filter",
|
|
8418
8552
|
component: (() => {
|
|
8419
|
-
const Tab = () =>
|
|
8553
|
+
const Tab = () => React2.createElement(
|
|
8420
8554
|
CrmContextProvider,
|
|
8421
8555
|
{ config, provider, store },
|
|
8422
|
-
|
|
8556
|
+
React2.createElement(PluginSettingsPanel, {
|
|
8423
8557
|
title: "Sales & CRM",
|
|
8424
|
-
generalSettings:
|
|
8558
|
+
generalSettings: React2.createElement(CrmGeneralSettings),
|
|
8425
8559
|
// Segmento é CADASTRO, e mora onde os outros moram. Etapas do
|
|
8426
8560
|
// funil, origens, parcerias e tags já estão aqui; ter o recorte
|
|
8427
8561
|
// fora, no rail de trabalho diário, era a inconsistência.
|
|
@@ -8429,7 +8563,7 @@ function createCrmPlugin(options) {
|
|
|
8429
8563
|
id: "segments",
|
|
8430
8564
|
label: "Segmentos",
|
|
8431
8565
|
icon: "Filter",
|
|
8432
|
-
content:
|
|
8566
|
+
content: React2.createElement(SegmentsView)
|
|
8433
8567
|
}],
|
|
8434
8568
|
registries: crmRegistries,
|
|
8435
8569
|
hostPluginId: "crm",
|
|
@@ -8462,6 +8596,6 @@ function createCrmPlugin(options) {
|
|
|
8462
8596
|
};
|
|
8463
8597
|
}
|
|
8464
8598
|
|
|
8465
|
-
export { buildCrmCustomerEntity, buildCrmDomainEvents, buildCrmMessageDefaults, createCrmPlugin, customerVocabulary };
|
|
8599
|
+
export { CrmSegmentsSurface, buildCrmCustomerEntity, buildCrmDomainEvents, buildCrmMessageDefaults, createCrmPlugin, customerVocabulary };
|
|
8466
8600
|
//# sourceMappingURL=index.js.map
|
|
8467
8601
|
//# sourceMappingURL=index.js.map
|