@fayz-ai/plugin-crm 0.26.0 → 0.27.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/components/ActivityTimeline.d.ts +4 -1
- package/dist/components/ActivityTimeline.d.ts.map +1 -1
- package/dist/data/supabase.d.ts.map +1 -1
- package/dist/index.js +333 -76
- 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/views/DealCardModal.d.ts.map +1 -1
- package/dist/views/PipelineView.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Activity } from '../types';
|
|
3
|
-
export declare function ActivityTimeline({ activities, loading, locale }: {
|
|
3
|
+
export declare function ActivityTimeline({ activities, loading, locale, contactName }: {
|
|
4
4
|
activities: Activity[];
|
|
5
5
|
loading: boolean;
|
|
6
6
|
/** Mesmo idioma do resto do card — "há 2 dias", não "2 days ago". */
|
|
7
7
|
locale?: string;
|
|
8
|
+
/** O ponto de contato do card, para não repetir o nome dele em cada linha.
|
|
9
|
+
* Ausente numa tela de uma pessoa só, onde toda atividade é dela. */
|
|
10
|
+
contactName?: string;
|
|
8
11
|
}): React.JSX.Element;
|
|
9
12
|
//# sourceMappingURL=ActivityTimeline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActivityTimeline.d.ts","sourceRoot":"","sources":["../../src/components/ActivityTimeline.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAuBxC,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"ActivityTimeline.d.ts","sourceRoot":"","sources":["../../src/components/ActivityTimeline.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAuBxC,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE;IAC7E,UAAU,EAAE,QAAQ,EAAE,CAAA;IACtB,OAAO,EAAE,OAAO,CAAA;IAChB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;0EACsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,qBA4EA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../../src/data/supabase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../../src/data/supabase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAsT9C,wBAAgB,yBAAyB,CAAC,OAAO,CAAC,EAAE;IAClD,gBAAgB,CAAC,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;IACtF,kFAAkF;IAClF,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACvE,GAAG,eAAe,CA+vElB"}
|
package/dist/index.js
CHANGED
|
@@ -1011,7 +1011,7 @@ function DealCard({ deal, saving, currency, tagDefs, onClick, onArchive, onDragS
|
|
|
1011
1011
|
className: `group rounded-card border bg-card p-3 transition-shadow ${saving ? "opacity-70" : "hover:shadow-sm cursor-grab active:cursor-grabbing active:opacity-70"}`,
|
|
1012
1012
|
children: [
|
|
1013
1013
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1014
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-sm font-medium", children: deal.
|
|
1014
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-sm font-medium", children: deal.companyName || deal.contactName || deal.title }),
|
|
1015
1015
|
saving && /* @__PURE__ */ jsx(Loader2, { className: "h-3 w-3 animate-spin text-muted-foreground shrink-0" }),
|
|
1016
1016
|
!saving && onArchive && /* @__PURE__ */ jsx(
|
|
1017
1017
|
"button",
|
|
@@ -1028,8 +1028,14 @@ function DealCard({ deal, saving, currency, tagDefs, onClick, onArchive, onDragS
|
|
|
1028
1028
|
] }),
|
|
1029
1029
|
(() => {
|
|
1030
1030
|
const partes = [
|
|
1031
|
-
|
|
1032
|
-
|
|
1031
|
+
// O PONTO DE CONTATO, quando a manchete ja e a empresa. Invertido em
|
|
1032
|
+
// relacao ao que era: antes a empresa e que descia para ca.
|
|
1033
|
+
deal.companyName && deal.contactName ? deal.contactName : null,
|
|
1034
|
+
// O título só quando ele DIZ outra coisa. Hoje ele é o nome da
|
|
1035
|
+
// pessoa em quase todos os 316 negócios — herança de quando o
|
|
1036
|
+
// negócio era da pessoa —, e repeti-lo ao lado do ponto de contato
|
|
1037
|
+
// dava "Victor Brandes · Victor Brandes" no card.
|
|
1038
|
+
deal.title && deal.title !== deal.companyName && deal.title !== deal.contactName ? deal.title : null,
|
|
1033
1039
|
deal.contactCity || null
|
|
1034
1040
|
].filter(Boolean);
|
|
1035
1041
|
if (!partes.length) return null;
|
|
@@ -2358,7 +2364,7 @@ var TYPE_ICONS = {
|
|
|
2358
2364
|
deal_archived: Archive,
|
|
2359
2365
|
quote_archived: Archive
|
|
2360
2366
|
};
|
|
2361
|
-
function ActivityTimeline({ activities, loading, locale }) {
|
|
2367
|
+
function ActivityTimeline({ activities, loading, locale, contactName }) {
|
|
2362
2368
|
const t2 = useTranslation();
|
|
2363
2369
|
const messages = useActivityAutomations();
|
|
2364
2370
|
if (loading) {
|
|
@@ -2383,7 +2389,13 @@ function ActivityTimeline({ activities, loading, locale }) {
|
|
|
2383
2389
|
] }),
|
|
2384
2390
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 pt-0.5", children: [
|
|
2385
2391
|
/* @__PURE__ */ jsxs("div", { className: "flex items-baseline gap-2", children: [
|
|
2386
|
-
/* @__PURE__ */
|
|
2392
|
+
/* @__PURE__ */ jsxs("p", { className: "min-w-0 flex-1 truncate text-xs font-medium leading-5", children: [
|
|
2393
|
+
a.title,
|
|
2394
|
+
a.contactName && a.contactName !== contactName && /* @__PURE__ */ jsxs("span", { className: "ml-1.5 font-normal text-muted-foreground", children: [
|
|
2395
|
+
"\xB7 ",
|
|
2396
|
+
a.contactName
|
|
2397
|
+
] })
|
|
2398
|
+
] }),
|
|
2387
2399
|
a.completedAt && /* @__PURE__ */ jsx(Check, { className: "h-3 w-3 shrink-0 text-success" }),
|
|
2388
2400
|
/* @__PURE__ */ jsx(AutomationBolt, { activityType: a.activityType, messages }),
|
|
2389
2401
|
/* @__PURE__ */ jsx("time", { className: "shrink-0 text-[10px] tabular-nums text-muted-foreground/70", children: formatRelativeTime(a.createdAt, locale) })
|
|
@@ -3149,6 +3161,49 @@ function LogActivityButton({ target, onLogged }) {
|
|
|
3149
3161
|
] }) })
|
|
3150
3162
|
] });
|
|
3151
3163
|
}
|
|
3164
|
+
function useCanTalk() {
|
|
3165
|
+
const runtime = usePluginRuntimeOptional();
|
|
3166
|
+
return Boolean(runtime?.activePlugins.some((p) => p.id === "conversations"));
|
|
3167
|
+
}
|
|
3168
|
+
function href(personId, name, phone) {
|
|
3169
|
+
return `/conversations?personId=${encodeURIComponent(personId)}&name=${encodeURIComponent(name)}&handle=${encodeURIComponent(phone)}&channel=whatsapp`;
|
|
3170
|
+
}
|
|
3171
|
+
function TalkToPerson({ personId, name, phone, variant = "button", className }) {
|
|
3172
|
+
const t2 = useTranslation();
|
|
3173
|
+
const canTalk = useCanTalk();
|
|
3174
|
+
if (!canTalk || !phone) return null;
|
|
3175
|
+
const label2 = t2("crm.leadDetail.whatsapp");
|
|
3176
|
+
const go = (e) => {
|
|
3177
|
+
e.stopPropagation();
|
|
3178
|
+
e.preventDefault();
|
|
3179
|
+
adminNavigateTo(href(personId, name ?? "", phone));
|
|
3180
|
+
};
|
|
3181
|
+
if (variant === "icon") {
|
|
3182
|
+
return /* @__PURE__ */ jsx(
|
|
3183
|
+
"button",
|
|
3184
|
+
{
|
|
3185
|
+
onClick: go,
|
|
3186
|
+
title: label2,
|
|
3187
|
+
"aria-label": label2,
|
|
3188
|
+
className: className ?? "inline-flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
3189
|
+
children: /* @__PURE__ */ jsx(MessageCircle, { className: "h-3.5 w-3.5" })
|
|
3190
|
+
}
|
|
3191
|
+
);
|
|
3192
|
+
}
|
|
3193
|
+
return /* @__PURE__ */ jsxs(
|
|
3194
|
+
"button",
|
|
3195
|
+
{
|
|
3196
|
+
onClick: go,
|
|
3197
|
+
title: label2,
|
|
3198
|
+
className: className ?? "inline-flex items-center gap-1.5 rounded-lg border bg-card px-3 py-1.5 text-xs font-medium text-muted-foreground shadow-button transition-colors hover:bg-muted hover:text-foreground active:shadow-button-inset",
|
|
3199
|
+
children: [
|
|
3200
|
+
/* @__PURE__ */ jsx(MessageCircle, { className: "h-3 w-3" }),
|
|
3201
|
+
" ",
|
|
3202
|
+
label2
|
|
3203
|
+
]
|
|
3204
|
+
}
|
|
3205
|
+
);
|
|
3206
|
+
}
|
|
3152
3207
|
function Section({ title, action, children }) {
|
|
3153
3208
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
3154
3209
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
@@ -3213,6 +3268,8 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
3213
3268
|
const [closing, setClosing] = useState(false);
|
|
3214
3269
|
const [draft, setDraft] = useState(null);
|
|
3215
3270
|
const [company, setCompany] = useState(null);
|
|
3271
|
+
const [pessoasDaCasa, setPessoasDaCasa] = useState([]);
|
|
3272
|
+
const [trocandoContato, setTrocandoContato] = useState(false);
|
|
3216
3273
|
const [team, setTeam] = useState(null);
|
|
3217
3274
|
const [myUserId, setMyUserId] = useState(null);
|
|
3218
3275
|
const [savingOwner, setSavingOwner] = useState(false);
|
|
@@ -3252,6 +3309,8 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
3252
3309
|
if (companyId) {
|
|
3253
3310
|
const c = await provider.getCompanyById(companyId);
|
|
3254
3311
|
if (!cancelled) setCompany(c);
|
|
3312
|
+
const gente = await provider.getCompanyPeople(companyId).catch(() => []);
|
|
3313
|
+
if (!cancelled) setPessoasDaCasa(gente);
|
|
3255
3314
|
}
|
|
3256
3315
|
if (!cancelled) setLoading(false);
|
|
3257
3316
|
});
|
|
@@ -3320,6 +3379,19 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
3320
3379
|
setClosing(false);
|
|
3321
3380
|
}
|
|
3322
3381
|
}
|
|
3382
|
+
async function trocarPontoDeContato(personId) {
|
|
3383
|
+
if (!deal || trocandoContato) return;
|
|
3384
|
+
setTrocandoContato(true);
|
|
3385
|
+
try {
|
|
3386
|
+
const atualizado = await provider.updateDeal(deal.id, { contactId: personId });
|
|
3387
|
+
const nova = pessoasDaCasa.find((x) => x.personId === personId);
|
|
3388
|
+
setDeal({ ...atualizado, contactName: nova?.personName ?? atualizado.contactName });
|
|
3389
|
+
} catch (err) {
|
|
3390
|
+
toast.error(t2("crm.card.saveFailed"), { description: err?.message });
|
|
3391
|
+
} finally {
|
|
3392
|
+
setTrocandoContato(false);
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3323
3395
|
async function changeOwner(userId) {
|
|
3324
3396
|
if (!deal || savingOwner) return;
|
|
3325
3397
|
setSavingOwner(true);
|
|
@@ -3462,31 +3534,55 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
3462
3534
|
/* @__PURE__ */ jsx("div", { className: "h-64 animate-pulse rounded-lg bg-muted/40" })
|
|
3463
3535
|
] }) : /* @__PURE__ */ jsxs("div", { className: "grid gap-0 lg:grid-cols-2", children: [
|
|
3464
3536
|
/* @__PURE__ */ jsxs("div", { className: "space-y-5 border-b p-5 lg:border-b-0 lg:border-r", children: [
|
|
3465
|
-
/* @__PURE__ */ jsxs(
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3537
|
+
/* @__PURE__ */ jsxs(
|
|
3538
|
+
Section,
|
|
3539
|
+
{
|
|
3540
|
+
title: t2("crm.card.pointOfContact"),
|
|
3541
|
+
action: lead?.id ? /* @__PURE__ */ jsx(TalkToPerson, { personId: lead.id, name: lead.name, phone: lead.phone, variant: "icon" }) : void 0,
|
|
3542
|
+
children: [
|
|
3543
|
+
pessoasDaCasa.length > 1 && /* @__PURE__ */ jsx("div", { className: "mb-3", children: /* @__PURE__ */ jsxs(
|
|
3544
|
+
Select,
|
|
3545
|
+
{
|
|
3546
|
+
value: deal?.contactId ?? "",
|
|
3547
|
+
onValueChange: (v) => {
|
|
3548
|
+
void trocarPontoDeContato(v);
|
|
3549
|
+
},
|
|
3550
|
+
disabled: trocandoContato,
|
|
3551
|
+
children: [
|
|
3552
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-9", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: t2("crm.card.pointOfContact") }) }),
|
|
3553
|
+
/* @__PURE__ */ jsx(SelectContent, { children: pessoasDaCasa.map((x) => /* @__PURE__ */ jsxs(SelectItem, { value: x.personId, children: [
|
|
3554
|
+
x.personName,
|
|
3555
|
+
x.role ? ` \xB7 ${x.role}` : ""
|
|
3556
|
+
] }, x.personId)) })
|
|
3557
|
+
]
|
|
3558
|
+
}
|
|
3559
|
+
) }),
|
|
3560
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
3561
|
+
/* @__PURE__ */ jsx(Field, { label: t2("crm.leadDetail.name"), children: /* @__PURE__ */ jsx(Input, { className: "h-9", value: draft.name, onChange: (e) => setDraft({ ...draft, name: e.target.value }) }) }),
|
|
3562
|
+
/* @__PURE__ */ jsx(Field, { label: t2("crm.leadDetail.phone"), children: /* @__PURE__ */ jsx(Input, { className: "h-9", value: draft.phone, onChange: (e) => setDraft({ ...draft, phone: e.target.value }) }) }),
|
|
3563
|
+
/* @__PURE__ */ jsx(Field, { label: t2("crm.leadDetail.email"), children: /* @__PURE__ */ jsx(Input, { className: "h-9", type: "email", value: draft.email, onChange: (e) => setDraft({ ...draft, email: e.target.value }) }) }),
|
|
3564
|
+
/* @__PURE__ */ jsx(Field, { label: t2("crm.leadDetail.company"), children: /* @__PURE__ */ jsx(Input, { className: "h-9", value: draft.company, onChange: (e) => setDraft({ ...draft, company: e.target.value }) }) }),
|
|
3565
|
+
/* @__PURE__ */ jsx(Field, { label: t2("crm.dealSidebar.value"), children: /* @__PURE__ */ jsx(CurrencyInput, { value: draft.value, onChange: (v) => setDraft({ ...draft, value: v ?? 0 }) }) }),
|
|
3566
|
+
/* @__PURE__ */ jsx(Field, { label: t2("crm.dealSidebar.expectedClose"), children: /* @__PURE__ */ jsx(DatePicker, { value: draft.expectedCloseDate, onChange: (v) => setDraft({ ...draft, expectedCloseDate: v }) }) })
|
|
3567
|
+
] }),
|
|
3568
|
+
/* @__PURE__ */ jsx(Field, { label: t2("crm.leadDetail.notes"), children: /* @__PURE__ */ jsx(
|
|
3569
|
+
"textarea",
|
|
3570
|
+
{
|
|
3571
|
+
rows: 3,
|
|
3572
|
+
value: draft.notes,
|
|
3573
|
+
onChange: (e) => setDraft({ ...draft, notes: e.target.value }),
|
|
3574
|
+
className: "w-full resize-none rounded-lg border bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring"
|
|
3575
|
+
}
|
|
3576
|
+
) }),
|
|
3577
|
+
/* @__PURE__ */ jsxs(Button, { className: "w-full", onClick: () => {
|
|
3578
|
+
void save();
|
|
3579
|
+
}, disabled: saving, children: [
|
|
3580
|
+
saving && /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
3581
|
+
t2("crm.card.save")
|
|
3582
|
+
] })
|
|
3583
|
+
]
|
|
3584
|
+
}
|
|
3585
|
+
),
|
|
3490
3586
|
company && /* @__PURE__ */ jsx(Section, { title: t2("crm.card.companyTitle"), children: /* @__PURE__ */ jsxs(
|
|
3491
3587
|
"button",
|
|
3492
3588
|
{
|
|
@@ -3594,7 +3690,7 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
3594
3690
|
onLogged: (activity) => setActivities((prev) => [activity, ...prev])
|
|
3595
3691
|
}
|
|
3596
3692
|
),
|
|
3597
|
-
children: /* @__PURE__ */ jsx(ActivityTimeline, { activities, loading: activitiesLoading, locale: currency.locale })
|
|
3693
|
+
children: /* @__PURE__ */ jsx(ActivityTimeline, { activities, loading: activitiesLoading, locale: currency.locale, contactName: deal?.contactName })
|
|
3598
3694
|
}
|
|
3599
3695
|
) })
|
|
3600
3696
|
] }) })
|
|
@@ -3724,49 +3820,6 @@ function LeadStatusBadge({ status, className }) {
|
|
|
3724
3820
|
}
|
|
3725
3821
|
);
|
|
3726
3822
|
}
|
|
3727
|
-
function useCanTalk() {
|
|
3728
|
-
const runtime = usePluginRuntimeOptional();
|
|
3729
|
-
return Boolean(runtime?.activePlugins.some((p) => p.id === "conversations"));
|
|
3730
|
-
}
|
|
3731
|
-
function href(personId, name, phone) {
|
|
3732
|
-
return `/conversations?personId=${encodeURIComponent(personId)}&name=${encodeURIComponent(name)}&handle=${encodeURIComponent(phone)}&channel=whatsapp`;
|
|
3733
|
-
}
|
|
3734
|
-
function TalkToPerson({ personId, name, phone, variant = "button", className }) {
|
|
3735
|
-
const t2 = useTranslation();
|
|
3736
|
-
const canTalk = useCanTalk();
|
|
3737
|
-
if (!canTalk || !phone) return null;
|
|
3738
|
-
const label2 = t2("crm.leadDetail.whatsapp");
|
|
3739
|
-
const go = (e) => {
|
|
3740
|
-
e.stopPropagation();
|
|
3741
|
-
e.preventDefault();
|
|
3742
|
-
adminNavigateTo(href(personId, name ?? "", phone));
|
|
3743
|
-
};
|
|
3744
|
-
if (variant === "icon") {
|
|
3745
|
-
return /* @__PURE__ */ jsx(
|
|
3746
|
-
"button",
|
|
3747
|
-
{
|
|
3748
|
-
onClick: go,
|
|
3749
|
-
title: label2,
|
|
3750
|
-
"aria-label": label2,
|
|
3751
|
-
className: className ?? "inline-flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
3752
|
-
children: /* @__PURE__ */ jsx(MessageCircle, { className: "h-3.5 w-3.5" })
|
|
3753
|
-
}
|
|
3754
|
-
);
|
|
3755
|
-
}
|
|
3756
|
-
return /* @__PURE__ */ jsxs(
|
|
3757
|
-
"button",
|
|
3758
|
-
{
|
|
3759
|
-
onClick: go,
|
|
3760
|
-
title: label2,
|
|
3761
|
-
className: className ?? "inline-flex items-center gap-1.5 rounded-lg border bg-card px-3 py-1.5 text-xs font-medium text-muted-foreground shadow-button transition-colors hover:bg-muted hover:text-foreground active:shadow-button-inset",
|
|
3762
|
-
children: [
|
|
3763
|
-
/* @__PURE__ */ jsx(MessageCircle, { className: "h-3 w-3" }),
|
|
3764
|
-
" ",
|
|
3765
|
-
label2
|
|
3766
|
-
]
|
|
3767
|
-
}
|
|
3768
|
-
);
|
|
3769
|
-
}
|
|
3770
3823
|
function topAnswerKeys(leads2, limit = 3) {
|
|
3771
3824
|
const count = /* @__PURE__ */ new Map();
|
|
3772
3825
|
for (const lead of leads2) {
|
|
@@ -10419,7 +10472,7 @@ function snakeToCamel(obj) {
|
|
|
10419
10472
|
return result;
|
|
10420
10473
|
}
|
|
10421
10474
|
var DEALS_POR_ETAPA = 100;
|
|
10422
|
-
var BUSCA_NO_QUADRO = ["title", "contact_name", "notes", "lost_reason", "stage_name", "contact_status_name"];
|
|
10475
|
+
var BUSCA_NO_QUADRO = ["title", "contact_name", "company_name", "notes", "lost_reason", "stage_name", "contact_status_name"];
|
|
10423
10476
|
async function callBacklog(limit, dryRun) {
|
|
10424
10477
|
const supabase = getSupabaseClientOptional();
|
|
10425
10478
|
if (!supabase) throw new Error("Supabase not initialized");
|
|
@@ -25663,6 +25716,206 @@ CREATE VIEW public.v_crm_leads WITH (security_invoker = true) AS
|
|
|
25663
25716
|
|
|
25664
25717
|
GRANT SELECT ON public.v_crm_leads TO authenticated, service_role;
|
|
25665
25718
|
`;
|
|
25719
|
+
var MIGRATION_052_O_NEGOCIO_DIZ_DE_QUE_CASA_ELE_E = `-- ---------------------------------------------------------------------------
|
|
25720
|
+
-- 052_o_negocio_diz_de_que_casa_ele_e.sql
|
|
25721
|
+
--
|
|
25722
|
+
-- \u2500\u2500 o buraco \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
25723
|
+
--
|
|
25724
|
+
-- O card do funil mostrava o nome da PESSOA mesmo quando o neg\xF3cio tinha
|
|
25725
|
+
-- empresa ligada. A causa n\xE3o era a tela: \`v_deals\` exp\xF5e \`company_id\` e nunca
|
|
25726
|
+
-- exp\xF4s \`company_name\`, e o mapeador do cliente l\xEA \`r.company_name\` \u2014 que
|
|
25727
|
+
-- voltava indefinido em todas as 316 linhas.
|
|
25728
|
+
--
|
|
25729
|
+
-- Ent\xE3o \`deal.companyName\` era sempre vazio, a tela ca\xEDa no nome da pessoa, e
|
|
25730
|
+
-- nada em lugar nenhum indicava que faltava um dado. Um \`undefined\` silencioso
|
|
25731
|
+
-- atravessando quatro camadas.
|
|
25732
|
+
--
|
|
25733
|
+
-- \u2500\u2500 por que aqui e n\xE3o uma segunda consulta na tela \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
25734
|
+
--
|
|
25735
|
+
-- O quadro carrega centenas de cards de uma vez. Buscar a empresa card a card
|
|
25736
|
+
-- seriam centenas de idas ao servidor para preencher uma linha de texto; o
|
|
25737
|
+
-- JOIN custa uma vez, do lado onde o \xEDndice j\xE1 existe.
|
|
25738
|
+
--
|
|
25739
|
+
-- Vem tamb\xE9m o \`document_number\`: quem agrupa casas por raiz de CNPJ precisa
|
|
25740
|
+
-- dele no card, e uma segunda migration para acrescentar uma coluna irm\xE3 seria
|
|
25741
|
+
-- a mesma view derrubada duas vezes.
|
|
25742
|
+
--
|
|
25743
|
+
-- \u2500\u2500 e o dependente volta junto \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
25744
|
+
--
|
|
25745
|
+
-- \`plg_crm_rep_deals\` l\xEA desta view, e \`DROP ... CASCADE\` a levaria embora.
|
|
25746
|
+
-- Isso j\xE1 aconteceu com a \`v_leads\`: um script a derrubou, o dependente foi
|
|
25747
|
+
-- junto, e a lista de leads ficou VAZIA em produ\xE7\xE3o at\xE9 algu\xE9m reclamar.
|
|
25748
|
+
--
|
|
25749
|
+
-- Recriar na MESMA migration \xE9 o que torna a troca at\xF4mica: ou as duas voltam,
|
|
25750
|
+
-- ou nenhuma cai.
|
|
25751
|
+
--
|
|
25752
|
+
-- Idempotente e replay-safe: a view \xE9 DERRUBADA antes de criada.
|
|
25753
|
+
-- ---------------------------------------------------------------------------
|
|
25754
|
+
|
|
25755
|
+
DROP VIEW IF EXISTS public.v_deals CASCADE;
|
|
25756
|
+
CREATE VIEW public.v_deals WITH (security_invoker = true) AS
|
|
25757
|
+
SELECT d.id,
|
|
25758
|
+
d.tenant_id,
|
|
25759
|
+
d.status,
|
|
25760
|
+
d.value,
|
|
25761
|
+
COALESCE(d.title, d.notes) AS title,
|
|
25762
|
+
d.contact_id,
|
|
25763
|
+
d.assigned_to_id,
|
|
25764
|
+
d.tags,
|
|
25765
|
+
d.metadata ->> 'contactName'::text AS contact_name,
|
|
25766
|
+
d.created_at,
|
|
25767
|
+
d.updated_at,
|
|
25768
|
+
d.pipeline_id,
|
|
25769
|
+
d.stage_id,
|
|
25770
|
+
d.probability,
|
|
25771
|
+
d.expected_close_date,
|
|
25772
|
+
d.lead_id,
|
|
25773
|
+
d.lost_reason,
|
|
25774
|
+
ps.name AS stage_name,
|
|
25775
|
+
ps.color AS stage_color,
|
|
25776
|
+
ps."order" AS stage_order,
|
|
25777
|
+
ps.name AS stage,
|
|
25778
|
+
d.won_at,
|
|
25779
|
+
d.lost_at,
|
|
25780
|
+
d.company_id,
|
|
25781
|
+
d.contact_status,
|
|
25782
|
+
d.contact_status_at,
|
|
25783
|
+
cs.name AS contact_status_name,
|
|
25784
|
+
cs.color AS contact_status_color,
|
|
25785
|
+
d.notes,
|
|
25786
|
+
cs.derived_from AS contact_status_derived_from,
|
|
25787
|
+
-- 052: o NOME da empresa do neg\xF3cio.
|
|
25788
|
+
--
|
|
25789
|
+
-- \`company_id\` estava aqui desde sempre, o nome n\xE3o \u2014 e o mapeador do
|
|
25790
|
+
-- cliente lia \`r.company_name\`, que voltava indefinido em toda linha. O
|
|
25791
|
+
-- card do funil tinha \`deal.companyName\` sempre vazio e ca\xEDa no nome da
|
|
25792
|
+
-- pessoa, sem nada indicando que faltava um dado.
|
|
25793
|
+
emp.name AS company_name,
|
|
25794
|
+
emp.document_number AS company_document
|
|
25795
|
+
FROM plg_crm_deals d
|
|
25796
|
+
LEFT JOIN plg_crm_companies emp ON emp.id = d.company_id
|
|
25797
|
+
LEFT JOIN plg_crm_pipeline_stages ps ON ps.id = d.stage_id
|
|
25798
|
+
LEFT JOIN LATERAL ( SELECT s.name,
|
|
25799
|
+
s.color,
|
|
25800
|
+
s.derived_from
|
|
25801
|
+
FROM plg_crm_deal_statuses s
|
|
25802
|
+
WHERE s.tenant_id = d.tenant_id AND s.key = d.contact_status AND (s.stage_id IS NULL OR s.stage_id = d.stage_id)
|
|
25803
|
+
ORDER BY (s.stage_id IS NOT NULL) DESC
|
|
25804
|
+
LIMIT 1) cs ON true;
|
|
25805
|
+
|
|
25806
|
+
GRANT SELECT ON public.v_deals TO authenticated, service_role;
|
|
25807
|
+
|
|
25808
|
+
-- O dependente, recriado a partir do que estava no ar.
|
|
25809
|
+
CREATE VIEW public.plg_crm_rep_deals WITH (security_invoker = true) AS
|
|
25810
|
+
SELECT id AS deal_id,
|
|
25811
|
+
tenant_id,
|
|
25812
|
+
created_at,
|
|
25813
|
+
title,
|
|
25814
|
+
contact_name,
|
|
25815
|
+
status,
|
|
25816
|
+
pipeline_id,
|
|
25817
|
+
COALESCE(NULLIF(stage_name, ''::text), 'Sem etapa'::text) AS stage_name,
|
|
25818
|
+
assigned_to_id,
|
|
25819
|
+
expected_close_date,
|
|
25820
|
+
lost_reason,
|
|
25821
|
+
COALESCE(value, 0::numeric) AS value,
|
|
25822
|
+
1 AS deals,
|
|
25823
|
+
CASE
|
|
25824
|
+
WHEN status = 'won'::text THEN COALESCE(value, 0::numeric)
|
|
25825
|
+
ELSE 0::numeric
|
|
25826
|
+
END AS won_value,
|
|
25827
|
+
CASE
|
|
25828
|
+
WHEN status = 'open'::text THEN COALESCE(value, 0::numeric)
|
|
25829
|
+
ELSE 0::numeric
|
|
25830
|
+
END AS open_value,
|
|
25831
|
+
CASE
|
|
25832
|
+
WHEN status = 'won'::text THEN 1
|
|
25833
|
+
ELSE 0
|
|
25834
|
+
END AS is_won,
|
|
25835
|
+
CASE
|
|
25836
|
+
WHEN status = 'lost'::text THEN 1
|
|
25837
|
+
ELSE 0
|
|
25838
|
+
END AS is_lost,
|
|
25839
|
+
CASE
|
|
25840
|
+
WHEN status = 'open'::text THEN 1
|
|
25841
|
+
ELSE 0
|
|
25842
|
+
END AS is_open
|
|
25843
|
+
FROM v_deals d
|
|
25844
|
+
WHERE status <> 'archived'::text;
|
|
25845
|
+
|
|
25846
|
+
GRANT SELECT ON public.plg_crm_rep_deals TO authenticated, service_role;
|
|
25847
|
+
`;
|
|
25848
|
+
var MIGRATION_053_A_ATIVIDADE_DIZ_DE_QUEM_ELA_E = `-- ---------------------------------------------------------------------------
|
|
25849
|
+
-- 053_a_atividade_diz_de_quem_ela_e.sql
|
|
25850
|
+
--
|
|
25851
|
+
-- \u2500\u2500 o buraco \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
25852
|
+
--
|
|
25853
|
+
-- A linha do tempo do card da KEETA mostra OITO linhas id\xEAnticas:
|
|
25854
|
+
--
|
|
25855
|
+
-- Contato presencial na feira
|
|
25856
|
+
-- Sal\xE3o Abrasel \u2014 o crach\xE1 foi lido no estande e o contato entrou na base.
|
|
25857
|
+
--
|
|
25858
|
+
-- Parece duplica\xE7\xE3o e n\xE3o \xE9: s\xE3o oito pessoas distintas \u2014 Vitor, Victor Piva,
|
|
25859
|
+
-- Natan, Jonathan, Marco Antonio, julia, Larissa e Fabio \u2014, cada uma com o
|
|
25860
|
+
-- crach\xE1 lido no estande. Oito eventos reais.
|
|
25861
|
+
--
|
|
25862
|
+
-- O texto nunca precisou dizer de quem era porque cada card era de UMA pessoa:
|
|
25863
|
+
-- o nome estava no t\xEDtulo do card. Quando os cards viraram um por casa, a
|
|
25864
|
+
-- informa\xE7\xE3o que tornava cada linha distinta ficou de fora, e o hist\xF3rico
|
|
25865
|
+
-- passou a parecer defeito.
|
|
25866
|
+
--
|
|
25867
|
+
-- \u2500\u2500 por que preencher em vez de juntar na leitura \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
25868
|
+
--
|
|
25869
|
+
-- \`contact_name\` j\xE1 existe na tabela e est\xE1 preenchido em 18 de 382 linhas.
|
|
25870
|
+
-- \`lead_id\` est\xE1 em 370. O nome sempre esteve alcan\xE7\xE1vel; ningu\xE9m o copiou.
|
|
25871
|
+
--
|
|
25872
|
+
-- Um JOIN na leitura resolveria a tela e deixaria a coluna mentindo \u2014 e a
|
|
25873
|
+
-- pr\xF3xima tela a ler a tabela cairia no mesmo vazio. Preencher conserta a
|
|
25874
|
+
-- origem, e o gatilho abaixo impede que volte a acontecer.
|
|
25875
|
+
--
|
|
25876
|
+
-- \u2500\u2500 por que um gatilho, e n\xE3o s\xF3 o backfill \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
25877
|
+
--
|
|
25878
|
+
-- Quem grava atividade hoje s\xE3o cinco caminhos diferentes (webhook, campanha,
|
|
25879
|
+
-- tela, importa\xE7\xE3o, automa\xE7\xE3o). Exigir que todos lembrem de copiar o nome \xE9
|
|
25880
|
+
-- garantir que um deles n\xE3o vai lembrar. O banco preenche quando falta.
|
|
25881
|
+
--
|
|
25882
|
+
-- Idempotente e replay-safe.
|
|
25883
|
+
-- ---------------------------------------------------------------------------
|
|
25884
|
+
|
|
25885
|
+
CREATE OR REPLACE FUNCTION public.plg_crm_atividade_nomeia_a_pessoa()
|
|
25886
|
+
RETURNS trigger
|
|
25887
|
+
LANGUAGE plpgsql
|
|
25888
|
+
SECURITY DEFINER
|
|
25889
|
+
SET search_path = ''
|
|
25890
|
+
AS $$
|
|
25891
|
+
BEGIN
|
|
25892
|
+
-- S\xF3 quando FALTA. Um nome escrito \xE0 m\xE3o \u2014 "a recepcionista", "o s\xF3cio que
|
|
25893
|
+
-- atendeu" \u2014 vale mais que o cadastro e n\xE3o deve ser sobrescrito.
|
|
25894
|
+
IF NEW.contact_name IS NULL OR btrim(NEW.contact_name) = '' THEN
|
|
25895
|
+
SELECT p.name INTO NEW.contact_name
|
|
25896
|
+
FROM public.people p
|
|
25897
|
+
WHERE p.id = coalesce(NEW.contact_id, NEW.lead_id);
|
|
25898
|
+
END IF;
|
|
25899
|
+
RETURN NEW;
|
|
25900
|
+
END $$;
|
|
25901
|
+
|
|
25902
|
+
REVOKE ALL ON FUNCTION public.plg_crm_atividade_nomeia_a_pessoa() FROM public, anon, authenticated;
|
|
25903
|
+
|
|
25904
|
+
DROP TRIGGER IF EXISTS plg_crm_atividade_nomeia_a_pessoa ON public.plg_crm_activities;
|
|
25905
|
+
CREATE TRIGGER plg_crm_atividade_nomeia_a_pessoa
|
|
25906
|
+
BEFORE INSERT OR UPDATE OF contact_id, lead_id ON public.plg_crm_activities
|
|
25907
|
+
FOR EACH ROW EXECUTE FUNCTION public.plg_crm_atividade_nomeia_a_pessoa();
|
|
25908
|
+
|
|
25909
|
+
-- O passado, que \xE9 o que est\xE1 na tela agora.
|
|
25910
|
+
UPDATE public.plg_crm_activities a
|
|
25911
|
+
SET contact_name = p.name
|
|
25912
|
+
FROM public.people p
|
|
25913
|
+
WHERE p.id = coalesce(a.contact_id, a.lead_id)
|
|
25914
|
+
AND (a.contact_name IS NULL OR btrim(a.contact_name) = '');
|
|
25915
|
+
|
|
25916
|
+
COMMENT ON COLUMN public.plg_crm_activities.contact_name IS
|
|
25917
|
+
'De QUEM \xE9 a atividade. Redundante com \`lead_id\` de prop\xF3sito: quando os cards passaram a ser por empresa, oito visitas de oito pessoas viraram oito linhas id\xEAnticas na tela (053).';
|
|
25918
|
+
`;
|
|
25666
25919
|
var MIGRATIONS = [
|
|
25667
25920
|
{ id: "000_baseline", sql: MIGRATION_000_BASELINE },
|
|
25668
25921
|
{ id: "001_de_onde_veio_e_quem_indicou", sql: MIGRATION_001_DE_ONDE_VEIO_E_QUEM_INDICOU },
|
|
@@ -25714,7 +25967,9 @@ var MIGRATIONS = [
|
|
|
25714
25967
|
{ id: "048_a_empresa_tambem_tem_um_arroba", sql: MIGRATION_048_A_EMPRESA_TAMBEM_TEM_UM_ARROBA },
|
|
25715
25968
|
{ id: "049_o_arroba_chega_ate_a_lista", sql: MIGRATION_049_O_ARROBA_CHEGA_ATE_A_LISTA },
|
|
25716
25969
|
{ id: "050_a_reuniao_e_uma_especie_declarada", sql: MIGRATION_050_A_REUNIAO_E_UMA_ESPECIE_DECLARADA },
|
|
25717
|
-
{ id: "051_o_cracha_e_o_telefone_recusado_aparecem", sql: MIGRATION_051_O_CRACHA_E_O_TELEFONE_RECUSADO_APARECEM }
|
|
25970
|
+
{ id: "051_o_cracha_e_o_telefone_recusado_aparecem", sql: MIGRATION_051_O_CRACHA_E_O_TELEFONE_RECUSADO_APARECEM },
|
|
25971
|
+
{ id: "052_o_negocio_diz_de_que_casa_ele_e", sql: MIGRATION_052_O_NEGOCIO_DIZ_DE_QUE_CASA_ELE_E },
|
|
25972
|
+
{ id: "053_a_atividade_diz_de_quem_ela_e", sql: MIGRATION_053_A_ATIVIDADE_DIZ_DE_QUEM_ELA_E }
|
|
25718
25973
|
];
|
|
25719
25974
|
|
|
25720
25975
|
// src/locales/en.ts
|
|
@@ -25960,6 +26215,7 @@ var en = {
|
|
|
25960
26215
|
"crm.segments.field.lastEngagedAt": "Last sign of life",
|
|
25961
26216
|
"crm.segments.field.ordersCount": "Purchases",
|
|
25962
26217
|
"crm.segments.field.totalSpent": "Total spent",
|
|
26218
|
+
"crm.card.pointOfContact": "Point of contact",
|
|
25963
26219
|
"crm.card.record": "Record",
|
|
25964
26220
|
"crm.card.timeline": "Timeline",
|
|
25965
26221
|
"crm.card.save": "Save record",
|
|
@@ -26757,6 +27013,7 @@ var ptBR = {
|
|
|
26757
27013
|
"crm.segments.field.lastEngagedAt": "\xDAltimo sinal de vida",
|
|
26758
27014
|
"crm.segments.field.ordersCount": "N\xBA de compras",
|
|
26759
27015
|
"crm.segments.field.totalSpent": "Total gasto",
|
|
27016
|
+
"crm.card.pointOfContact": "Ponto de contato",
|
|
26760
27017
|
"crm.card.record": "Ficha de cadastro",
|
|
26761
27018
|
"crm.card.timeline": "Linha do tempo",
|
|
26762
27019
|
"crm.card.save": "Salvar cadastro",
|