@fayz-ai/plugin-conversations 0.29.0 → 0.31.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/{CampaignsSurface-4NG74KJ3.js → CampaignsSurface-KFWU5XUP.js} +164 -46
- package/dist/CampaignsSurface-KFWU5XUP.js.map +1 -0
- package/dist/{ConversationsPage-TT33VW3H.js → ConversationsPage-VXGZBHZG.js} +78 -21
- package/dist/ConversationsPage-VXGZBHZG.js.map +1 -0
- package/dist/{TemplatesSurface-IWS7FWG6.js → TemplatesSurface-6ICY3LS7.js} +54 -8
- package/dist/TemplatesSurface-6ICY3LS7.js.map +1 -0
- package/dist/{chunk-QHCQBTBZ.js → chunk-GDB5UCPB.js} +27 -4
- package/dist/chunk-GDB5UCPB.js.map +1 -0
- package/dist/components/InboxWatcher.d.ts.map +1 -1
- package/dist/data/journeys.d.ts +14 -1
- package/dist/data/journeys.d.ts.map +1 -1
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/lib/media-cache.d.ts +6 -0
- package/dist/lib/media-cache.d.ts.map +1 -0
- package/dist/migrations/index.d.ts +3 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/main.browser.js +4 -1
- package/dist/migrations/main.browser.js.map +1 -1
- package/dist/migrations/main.js +88 -2
- package/dist/migrations/main.js.map +1 -1
- package/dist/views/MediaBubble.d.ts.map +1 -1
- package/dist/views/MessageThread.d.ts.map +1 -1
- package/dist/views/campaigns/CampaignBreakdown.d.ts +5 -0
- package/dist/views/campaigns/CampaignBreakdown.d.ts.map +1 -0
- package/dist/views/campaigns/CampaignWizard.d.ts.map +1 -1
- package/dist/views/campaigns/CampaignsSurface.d.ts.map +1 -1
- package/dist/views/campaigns/TemplatesSurface.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/CampaignsSurface-4NG74KJ3.js.map +0 -1
- package/dist/ConversationsPage-TT33VW3H.js.map +0 -1
- package/dist/TemplatesSurface-IWS7FWG6.js.map +0 -1
- package/dist/chunk-QHCQBTBZ.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { providersApi } from './chunk-HMWUU5O7.js';
|
|
2
|
-
import { journeysApi, previewBody } from './chunk-
|
|
3
|
-
import
|
|
2
|
+
import { journeysApi, previewBody } from './chunk-GDB5UCPB.js';
|
|
3
|
+
import React3 from 'react';
|
|
4
4
|
import { Plus, Loader2, Megaphone, AlertTriangle, ChevronLeft, RefreshCw, Pause, Play, Pencil, Trash2, ClipboardList, Mail, MessageCircle, ArrowUp, ArrowDown, ChevronRight, CheckCircle2, Briefcase, Users, UserRound, ShieldCheck, ShieldAlert } from 'lucide-react';
|
|
5
|
-
import { toast, Button, Card, StatTiles, ConfirmDialog, StepProgress, Input, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, Textarea, Switch } from '@fayz-ai/ui';
|
|
6
|
-
import { getSupabaseClientOptional } from '@fayz-ai/core';
|
|
5
|
+
import { toast, Button, Card, StatTiles, ConfirmDialog, StepProgress, Input, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, Textarea, Switch, SegmentedControl } from '@fayz-ai/ui';
|
|
6
|
+
import { getSupabaseClientOptional, getActiveTenantId } from '@fayz-ai/core';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
9
|
function NumberProtection({ provider }) {
|
|
@@ -48,9 +48,9 @@ function NumberProtection({ provider }) {
|
|
|
48
48
|
var STEPS = ["P\xFAblico", "Canal", "Jornada", "Ritmo e prote\xE7\xF5es", "Revis\xE3o"];
|
|
49
49
|
var DAY = 1440;
|
|
50
50
|
var DEFAULT_JOURNEY = [
|
|
51
|
-
{ position: 1, waitMinutes: 0, channel: "whatsapp", templateId: null, taskTitle: null, contactRoute: "
|
|
52
|
-
{ position: 2, waitMinutes: 3 * DAY, channel: "whatsapp", templateId: null, taskTitle: null, contactRoute: "
|
|
53
|
-
{ position: 3, waitMinutes:
|
|
51
|
+
{ position: 1, waitMinutes: 0, channel: "whatsapp", templateId: null, taskTitle: null, contactRoute: "same" },
|
|
52
|
+
{ position: 2, waitMinutes: 3 * DAY, channel: "whatsapp", templateId: null, taskTitle: null, contactRoute: "each", repeatMinutes: DAY },
|
|
53
|
+
{ position: 3, waitMinutes: DAY, channel: "task", templateId: null, taskTitle: "Ligar para {{nome_completo}} ({{empresa}}) \u2014 n\xE3o respondeu \xE0 campanha", contactRoute: "same" }
|
|
54
54
|
];
|
|
55
55
|
var CHANNEL_UI = {
|
|
56
56
|
whatsapp: { label: "WhatsApp", icon: MessageCircle },
|
|
@@ -58,14 +58,14 @@ var CHANNEL_UI = {
|
|
|
58
58
|
task: { label: "Tarefa para o vendedor", icon: ClipboardList }
|
|
59
59
|
};
|
|
60
60
|
function CampaignWizard({ campaign, onClose, onSaved }) {
|
|
61
|
-
const [step, setStep] =
|
|
62
|
-
const [segments, setSegments] =
|
|
63
|
-
const [templates, setTemplates] =
|
|
64
|
-
const [providers, setProviders] =
|
|
65
|
-
const [saving, setSaving] =
|
|
66
|
-
const [audience, setAudience] =
|
|
67
|
-
const [loadingAudience, setLoadingAudience] =
|
|
68
|
-
const [draft, setDraft] =
|
|
61
|
+
const [step, setStep] = React3.useState(0);
|
|
62
|
+
const [segments, setSegments] = React3.useState([]);
|
|
63
|
+
const [templates, setTemplates] = React3.useState([]);
|
|
64
|
+
const [providers, setProviders] = React3.useState([]);
|
|
65
|
+
const [saving, setSaving] = React3.useState(false);
|
|
66
|
+
const [audience, setAudience] = React3.useState(null);
|
|
67
|
+
const [loadingAudience, setLoadingAudience] = React3.useState(false);
|
|
68
|
+
const [draft, setDraft] = React3.useState(() => campaign ? { ...campaign } : {
|
|
69
69
|
name: "",
|
|
70
70
|
description: null,
|
|
71
71
|
provider: "evolution",
|
|
@@ -77,16 +77,16 @@ function CampaignWizard({ campaign, onClose, onSaved }) {
|
|
|
77
77
|
settings: {},
|
|
78
78
|
steps: DEFAULT_JOURNEY
|
|
79
79
|
});
|
|
80
|
-
|
|
80
|
+
React3.useEffect(() => {
|
|
81
81
|
void journeysApi.segments().then(setSegments).catch(() => setSegments([]));
|
|
82
82
|
void journeysApi.templates().then(setTemplates).catch(() => setTemplates([]));
|
|
83
83
|
void providersApi.list().then(setProviders).catch(() => setProviders([]));
|
|
84
84
|
}, []);
|
|
85
|
-
|
|
85
|
+
React3.useEffect(() => {
|
|
86
86
|
if (Object.keys(draft.pacing ?? {}).length) return;
|
|
87
87
|
void journeysApi.defaultPacing(draft.provider).then((p) => setDraft((d) => Object.keys(d.pacing ?? {}).length ? d : { ...d, pacing: p }));
|
|
88
88
|
}, [draft.provider, draft.pacing]);
|
|
89
|
-
|
|
89
|
+
React3.useEffect(() => {
|
|
90
90
|
if (!draft.segmentId) {
|
|
91
91
|
setAudience(null);
|
|
92
92
|
return;
|
|
@@ -103,7 +103,7 @@ function CampaignWizard({ campaign, onClose, onSaved }) {
|
|
|
103
103
|
const problems = {
|
|
104
104
|
0: !draft.name.trim() ? "D\xEA um nome \xE0 campanha." : !draft.segmentId ? "Escolha um segmento." : null,
|
|
105
105
|
1: !draft.provider ? "Escolha o n\xFAmero." : null,
|
|
106
|
-
2: draft.steps.length === 0 ? "A jornada precisa de pelo menos um toque." : draft.steps.some((s) => s.channel !== "task" && !s.templateId) ? "Todo toque de WhatsApp ou e-mail precisa de um modelo." : draft.steps.some((s) => s.channel === "email" && tplOf(s.templateId)?.channel !== "email") ? "Toque de e-mail precisa de um modelo de e-mail." : draft.steps.some((s) => s.channel === "whatsapp" && tplOf(s.templateId)?.channel === "email") ? "Toque de WhatsApp precisa de um modelo de WhatsApp." : null,
|
|
106
|
+
2: draft.steps.length === 0 ? "A jornada precisa de pelo menos um toque." : draft.steps.some((s) => s.channel !== "task" && !s.templateId) ? "Todo toque de WhatsApp ou e-mail precisa de um modelo." : draft.steps.some((s) => s.channel === "email" && tplOf(s.templateId)?.channel !== "email") ? "Toque de e-mail precisa de um modelo de e-mail." : draft.steps.some((s) => s.channel === "whatsapp" && tplOf(s.templateId)?.channel === "email") ? "Toque de WhatsApp precisa de um modelo de WhatsApp." : draft.provider === "tyxter" && draft.steps.some((s) => s.channel === "whatsapp" && tplOf(s.templateId)?.status !== "approved") ? "No n\xFAmero oficial, todo toque de WhatsApp precisa de um modelo aprovado pela Meta (Modelos de mensagem \u203A Enviar para aprova\xE7\xE3o)." : null,
|
|
107
107
|
3: null,
|
|
108
108
|
4: null
|
|
109
109
|
};
|
|
@@ -274,19 +274,35 @@ function CampaignWizard({ campaign, onClose, onSaved }) {
|
|
|
274
274
|
/* @__PURE__ */ jsx(SelectContent, { children: options.map((t) => /* @__PURE__ */ jsxs(SelectItem, { value: t.id, children: [
|
|
275
275
|
t.name,
|
|
276
276
|
" \xB7 ",
|
|
277
|
-
1 + t.variants.length
|
|
278
|
-
" vers\xF5es"
|
|
277
|
+
draft.provider === "tyxter" ? t.status === "approved" ? "\u2713 aprovado" : t.status === "submitted" ? "em an\xE1lise" : "n\xE3o aprovado" : `${1 + t.variants.length} vers\xF5es`
|
|
279
278
|
] }, t.id)) })
|
|
280
279
|
] })
|
|
281
280
|
] }) }),
|
|
282
281
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
283
282
|
/* @__PURE__ */ jsx("label", { className: "text-[11px] text-muted-foreground", children: "Para quem" }),
|
|
284
|
-
/* @__PURE__ */ jsxs(Select, { value: i === 0 ? "same" : s.contactRoute, onValueChange: (v) => patchStep(i, { contactRoute: v }), disabled: i === 0, children: [
|
|
283
|
+
/* @__PURE__ */ jsxs(Select, { value: i === 0 ? "same" : s.contactRoute, onValueChange: (v) => patchStep(i, { contactRoute: v, repeatMinutes: s.repeatMinutes ?? DAY }), disabled: i === 0 || s.channel === "task", children: [
|
|
285
284
|
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 text-xs", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
286
285
|
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
287
286
|
/* @__PURE__ */ jsx(SelectItem, { value: "same", children: i === 0 ? "O contato principal" : "O mesmo contato do toque anterior" }),
|
|
288
|
-
/* @__PURE__ */ jsx(SelectItem, { value: "next", children: "Pr\xF3ximo contato do neg\xF3cio" })
|
|
287
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "next", children: "Pr\xF3ximo contato do neg\xF3cio" }),
|
|
288
|
+
s.channel === "whatsapp" && /* @__PURE__ */ jsx(SelectItem, { value: "each", children: "Os outros contatos, um por vez" }),
|
|
289
|
+
s.channel === "whatsapp" && /* @__PURE__ */ jsx(SelectItem, { value: "all", children: "Todos os outros contatos de uma vez" })
|
|
289
290
|
] })
|
|
291
|
+
] }),
|
|
292
|
+
s.contactRoute === "each" && i > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-1", children: [
|
|
293
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] text-muted-foreground", children: "um a cada" }),
|
|
294
|
+
/* @__PURE__ */ jsx(
|
|
295
|
+
Input,
|
|
296
|
+
{
|
|
297
|
+
type: "number",
|
|
298
|
+
min: 0.1,
|
|
299
|
+
step: 0.5,
|
|
300
|
+
className: "h-7 w-14 text-xs",
|
|
301
|
+
value: Math.round((s.repeatMinutes ?? DAY) / DAY * 10) / 10,
|
|
302
|
+
onChange: (e) => patchStep(i, { repeatMinutes: Math.max(0.1, Number(e.target.value)) * DAY })
|
|
303
|
+
}
|
|
304
|
+
),
|
|
305
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] text-muted-foreground", children: "dia(s), at\xE9 acabar" })
|
|
290
306
|
] })
|
|
291
307
|
] })
|
|
292
308
|
] })
|
|
@@ -304,7 +320,7 @@ function CampaignWizard({ campaign, onClose, onSaved }) {
|
|
|
304
320
|
" Parar quando a pessoa responder"
|
|
305
321
|
] })
|
|
306
322
|
] }),
|
|
307
|
-
/* @__PURE__ */ jsx("p", { className: "text-[11px] text-muted-foreground", children: '
|
|
323
|
+
/* @__PURE__ */ jsx("p", { className: "text-[11px] text-muted-foreground", children: 'A ordem dos contatos de um neg\xF3cio: outro telefone da pessoa \u2192 outra pessoa da empresa \u2192 algu\xE9m do grupo. "Um por vez" tenta cada um no intervalo escolhido enquanto ningu\xE9m responde; "todos de uma vez" \xE9 melhor no n\xFAmero oficial, onde volume n\xE3o arrisca o n\xFAmero.' })
|
|
308
324
|
] }),
|
|
309
325
|
step === 3 && /* @__PURE__ */ jsxs("div", { className: "grid gap-3 md:grid-cols-[1fr_1fr]", children: [
|
|
310
326
|
/* @__PURE__ */ jsxs(Card, { className: "space-y-3 p-4", children: [
|
|
@@ -383,7 +399,7 @@ function CampaignWizard({ campaign, onClose, onSaved }) {
|
|
|
383
399
|
] }),
|
|
384
400
|
/* @__PURE__ */ jsxs("li", { children: [
|
|
385
401
|
"Jornada: ",
|
|
386
|
-
draft.steps.map((s, i) => `${i === 0 ? "dia 0" : `+${Math.round(s.waitMinutes / DAY * 10) / 10}d`} ${CHANNEL_UI[s.channel].label}`).join(" \u2192 ")
|
|
402
|
+
draft.steps.map((s, i) => `${i === 0 ? "dia 0" : `+${Math.round(s.waitMinutes / DAY * 10) / 10}d`} ${CHANNEL_UI[s.channel].label}${s.contactRoute === "each" ? ` (outros contatos, 1 a cada ${Math.round((s.repeatMinutes ?? DAY) / DAY * 10) / 10}d)` : s.contactRoute === "all" ? " (todos os outros contatos)" : ""}`).join(" \u2192 ")
|
|
387
403
|
] }),
|
|
388
404
|
/* @__PURE__ */ jsxs("li", { children: [
|
|
389
405
|
"Ritmo: at\xE9 ",
|
|
@@ -490,6 +506,106 @@ function AudienceSummary({ loading, audience, kind }) {
|
|
|
490
506
|
] });
|
|
491
507
|
}
|
|
492
508
|
var VIA = { other_phone: "outro telefone", company: "mesma empresa", group: "mesmo grupo" };
|
|
509
|
+
var DIMENSIONS = {
|
|
510
|
+
template: { label: "Modelo", key: (f) => f.template_name ?? (f.channel === "task" ? "Tarefa" : "\u2014") },
|
|
511
|
+
variant: { label: "Varia\xE7\xE3o", key: (f) => `${f.template_name ?? "\u2014"} \xB7 ${f.variant == null ? "\u2014" : f.variant === 0 ? "texto principal" : `varia\xE7\xE3o ${f.variant}`}` },
|
|
512
|
+
provider: { label: "N\xFAmero", key: (f) => f.provider === "tyxter" ? "Oficial (Tyxter)" : "Dia a dia (Evolution)" },
|
|
513
|
+
via: { label: "Contato", key: (f) => VIA2[f.via] ?? f.via },
|
|
514
|
+
step: { label: "Toque", key: (f) => `Toque ${f.step_position}` },
|
|
515
|
+
attempt: { label: "Tentativa", key: (f) => `${f.attempt}\xAA tentativa no neg\xF3cio` },
|
|
516
|
+
campaign: { label: "Campanha", key: (f) => f.campaign_name }
|
|
517
|
+
};
|
|
518
|
+
var VIA2 = {
|
|
519
|
+
primary: "Contato principal",
|
|
520
|
+
other_phone: "Outro telefone da pessoa",
|
|
521
|
+
company: "Outra pessoa da empresa",
|
|
522
|
+
group: "Algu\xE9m do grupo"
|
|
523
|
+
};
|
|
524
|
+
function CampaignBreakdown({ campaignId }) {
|
|
525
|
+
const [facts, setFacts] = React3.useState(null);
|
|
526
|
+
const [dim, setDim] = React3.useState(campaignId ? "template" : "campaign");
|
|
527
|
+
React3.useEffect(() => {
|
|
528
|
+
let alive = true;
|
|
529
|
+
void (async () => {
|
|
530
|
+
const sb = getSupabaseClientOptional();
|
|
531
|
+
let q = sb.from("v_conversations_campaign_facts").select("campaign_name, provider, channel, step_position, template_name, variant, via, attempt, is_sent, is_delivered, is_read, is_replied, is_failed, is_won, deal_id").eq("tenant_id", getActiveTenantId());
|
|
532
|
+
if (campaignId) q = q.eq("campaign_id", campaignId);
|
|
533
|
+
const { data } = await q.limit(2e4);
|
|
534
|
+
if (alive) setFacts(data ?? []);
|
|
535
|
+
})();
|
|
536
|
+
return () => {
|
|
537
|
+
alive = false;
|
|
538
|
+
};
|
|
539
|
+
}, [campaignId]);
|
|
540
|
+
const rows = React3.useMemo(() => {
|
|
541
|
+
const groups = /* @__PURE__ */ new Map();
|
|
542
|
+
for (const f of (facts ?? []).filter((x) => x.channel !== "task" || dim === "template" || dim === "step")) {
|
|
543
|
+
const k = DIMENSIONS[dim].key(f);
|
|
544
|
+
const g = groups.get(k) ?? { sent: 0, delivered: 0, read: 0, replied: 0, failed: 0, wonDeals: /* @__PURE__ */ new Set() };
|
|
545
|
+
if (f.is_sent) g.sent++;
|
|
546
|
+
if (f.is_delivered) g.delivered++;
|
|
547
|
+
if (f.is_read) g.read++;
|
|
548
|
+
if (f.is_replied) g.replied++;
|
|
549
|
+
if (f.is_failed) g.failed++;
|
|
550
|
+
if (f.is_won && f.deal_id) g.wonDeals.add(f.deal_id);
|
|
551
|
+
groups.set(k, g);
|
|
552
|
+
}
|
|
553
|
+
return [...groups.entries()].map(([k, g]) => ({ k, ...g, won: g.wonDeals.size })).sort((a, b) => b.sent - a.sent);
|
|
554
|
+
}, [facts, dim]);
|
|
555
|
+
const rate = (n, d) => d ? `${Math.round(100 * n / d)}%` : "\u2014";
|
|
556
|
+
return /* @__PURE__ */ jsxs(Card, { className: "overflow-hidden", children: [
|
|
557
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2", children: [
|
|
558
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: "Desempenho das mensagens" }),
|
|
559
|
+
/* @__PURE__ */ jsx(
|
|
560
|
+
SegmentedControl,
|
|
561
|
+
{
|
|
562
|
+
size: "sm",
|
|
563
|
+
value: dim,
|
|
564
|
+
onChange: (v) => setDim(v),
|
|
565
|
+
options: Object.keys(DIMENSIONS).filter((d) => campaignId ? d !== "campaign" : true).map((d) => ({ value: d, label: DIMENSIONS[d].label }))
|
|
566
|
+
}
|
|
567
|
+
)
|
|
568
|
+
] }),
|
|
569
|
+
facts === null ? /* @__PURE__ */ jsx("div", { className: "flex justify-center py-6", children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : rows.length === 0 ? /* @__PURE__ */ jsx("p", { className: "px-3 py-6 text-center text-xs text-muted-foreground", children: "Nenhuma mensagem enviada ainda." }) : /* @__PURE__ */ jsx("div", { className: "overflow-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-xs", children: [
|
|
570
|
+
/* @__PURE__ */ jsx("thead", { className: "text-muted-foreground", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
571
|
+
/* @__PURE__ */ jsx("th", { className: "px-3 py-2 text-left", children: DIMENSIONS[dim].label }),
|
|
572
|
+
/* @__PURE__ */ jsx("th", { className: "px-3 py-2 text-right", children: "Enviadas" }),
|
|
573
|
+
/* @__PURE__ */ jsx("th", { className: "px-3 py-2 text-right", children: "Entregues" }),
|
|
574
|
+
/* @__PURE__ */ jsx("th", { className: "px-3 py-2 text-right", children: "Lidas" }),
|
|
575
|
+
/* @__PURE__ */ jsx("th", { className: "px-3 py-2 text-right", children: "Responderam" }),
|
|
576
|
+
/* @__PURE__ */ jsx("th", { className: "px-3 py-2 text-right", children: "Taxa de resposta" }),
|
|
577
|
+
/* @__PURE__ */ jsx("th", { className: "px-3 py-2 text-right", children: "Neg\xF3cios ganhos depois" }),
|
|
578
|
+
/* @__PURE__ */ jsx("th", { className: "px-3 py-2 text-right", children: "Falhas" })
|
|
579
|
+
] }) }),
|
|
580
|
+
/* @__PURE__ */ jsx("tbody", { children: rows.map((r) => /* @__PURE__ */ jsxs("tr", { className: "border-t", children: [
|
|
581
|
+
/* @__PURE__ */ jsx("td", { className: "px-3 py-2 font-medium", children: r.k }),
|
|
582
|
+
/* @__PURE__ */ jsx("td", { className: "px-3 py-2 text-right tabular-nums", children: r.sent }),
|
|
583
|
+
/* @__PURE__ */ jsxs("td", { className: "px-3 py-2 text-right tabular-nums", children: [
|
|
584
|
+
r.delivered,
|
|
585
|
+
" ",
|
|
586
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
587
|
+
"(",
|
|
588
|
+
rate(r.delivered, r.sent),
|
|
589
|
+
")"
|
|
590
|
+
] })
|
|
591
|
+
] }),
|
|
592
|
+
/* @__PURE__ */ jsxs("td", { className: "px-3 py-2 text-right tabular-nums", children: [
|
|
593
|
+
r.read,
|
|
594
|
+
" ",
|
|
595
|
+
/* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
|
|
596
|
+
"(",
|
|
597
|
+
rate(r.read, r.sent),
|
|
598
|
+
")"
|
|
599
|
+
] })
|
|
600
|
+
] }),
|
|
601
|
+
/* @__PURE__ */ jsx("td", { className: "px-3 py-2 text-right tabular-nums font-semibold text-success", children: r.replied }),
|
|
602
|
+
/* @__PURE__ */ jsx("td", { className: "px-3 py-2 text-right tabular-nums font-semibold", children: rate(r.replied, r.sent) }),
|
|
603
|
+
/* @__PURE__ */ jsx("td", { className: "px-3 py-2 text-right tabular-nums", children: r.won }),
|
|
604
|
+
/* @__PURE__ */ jsx("td", { className: `px-3 py-2 text-right tabular-nums ${r.failed ? "text-destructive" : "text-muted-foreground"}`, children: r.failed })
|
|
605
|
+
] }, r.k)) })
|
|
606
|
+
] }) })
|
|
607
|
+
] });
|
|
608
|
+
}
|
|
493
609
|
var STATUS = {
|
|
494
610
|
draft: { label: "rascunho", cls: "bg-muted text-muted-foreground" },
|
|
495
611
|
scheduled: { label: "agendada", cls: "bg-info-soft text-info-soft-foreground" },
|
|
@@ -508,7 +624,7 @@ var ENROLL_STATE = {
|
|
|
508
624
|
exited: "saiu"
|
|
509
625
|
};
|
|
510
626
|
function CampaignsSurface() {
|
|
511
|
-
const [view, setView] =
|
|
627
|
+
const [view, setView] = React3.useState({ kind: "list" });
|
|
512
628
|
if (view.kind === "edit") {
|
|
513
629
|
return /* @__PURE__ */ jsx(
|
|
514
630
|
CampaignWizard,
|
|
@@ -525,9 +641,9 @@ function CampaignsSurface() {
|
|
|
525
641
|
return /* @__PURE__ */ jsx(CampaignList, { onNew: () => setView({ kind: "edit", campaign: null }), onOpen: (c) => setView(c.status === "draft" ? { kind: "edit", campaign: c } : { kind: "monitor", id: c.id }) });
|
|
526
642
|
}
|
|
527
643
|
function CampaignList({ onNew, onOpen }) {
|
|
528
|
-
const [rows, setRows] =
|
|
529
|
-
const [stats, setStats] =
|
|
530
|
-
const load =
|
|
644
|
+
const [rows, setRows] = React3.useState(null);
|
|
645
|
+
const [stats, setStats] = React3.useState({});
|
|
646
|
+
const load = React3.useCallback(async () => {
|
|
531
647
|
try {
|
|
532
648
|
const list = (await journeysApi.campaigns()).filter((c) => c.steps.length > 0 || c.status === "draft");
|
|
533
649
|
setRows(list);
|
|
@@ -537,7 +653,7 @@ function CampaignList({ onNew, onOpen }) {
|
|
|
537
653
|
setRows([]);
|
|
538
654
|
}
|
|
539
655
|
}, []);
|
|
540
|
-
|
|
656
|
+
React3.useEffect(() => {
|
|
541
657
|
void load();
|
|
542
658
|
}, [load]);
|
|
543
659
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
@@ -596,16 +712,16 @@ function Metric({ label, value, strong }) {
|
|
|
596
712
|
] });
|
|
597
713
|
}
|
|
598
714
|
function CampaignMonitor({ id, onBack, onEdit }) {
|
|
599
|
-
const [c, setC] =
|
|
600
|
-
const [stats, setStats] =
|
|
601
|
-
const [steps, setSteps] =
|
|
602
|
-
const [enrollments, setEnrollments] =
|
|
603
|
-
const [targets, setTargets] =
|
|
604
|
-
const [deals, setDeals] =
|
|
605
|
-
const [filter, setFilter] =
|
|
606
|
-
const [busy, setBusy] =
|
|
607
|
-
const [confirmDelete, setConfirmDelete] =
|
|
608
|
-
const load =
|
|
715
|
+
const [c, setC] = React3.useState(null);
|
|
716
|
+
const [stats, setStats] = React3.useState(null);
|
|
717
|
+
const [steps, setSteps] = React3.useState([]);
|
|
718
|
+
const [enrollments, setEnrollments] = React3.useState([]);
|
|
719
|
+
const [targets, setTargets] = React3.useState([]);
|
|
720
|
+
const [deals, setDeals] = React3.useState({});
|
|
721
|
+
const [filter, setFilter] = React3.useState("all");
|
|
722
|
+
const [busy, setBusy] = React3.useState(false);
|
|
723
|
+
const [confirmDelete, setConfirmDelete] = React3.useState(false);
|
|
724
|
+
const load = React3.useCallback(async () => {
|
|
609
725
|
try {
|
|
610
726
|
const camp = await journeysApi.campaign(id);
|
|
611
727
|
setC(camp);
|
|
@@ -632,7 +748,7 @@ function CampaignMonitor({ id, onBack, onEdit }) {
|
|
|
632
748
|
toast.error(e.message);
|
|
633
749
|
}
|
|
634
750
|
}, [id]);
|
|
635
|
-
|
|
751
|
+
React3.useEffect(() => {
|
|
636
752
|
void load();
|
|
637
753
|
const t = window.setInterval(() => {
|
|
638
754
|
if (document.visibilityState === "visible") void load();
|
|
@@ -739,6 +855,7 @@ function CampaignMonitor({ id, onBack, onEdit }) {
|
|
|
739
855
|
] }, s.position);
|
|
740
856
|
}) })
|
|
741
857
|
] }),
|
|
858
|
+
/* @__PURE__ */ jsx(CampaignBreakdown, { campaignId: id }),
|
|
742
859
|
/* @__PURE__ */ jsxs(Card, { className: "overflow-hidden", children: [
|
|
743
860
|
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-1 border-b px-3 py-2", children: ["all", "active", "replied", "opted_out", "completed", "no_route"].map((f) => /* @__PURE__ */ jsxs(Button, { size: "sm", variant: filter === f ? "secondary" : "ghost", className: "h-7 text-xs", onClick: () => setFilter(f), children: [
|
|
744
861
|
f === "all" ? "Todos" : ENROLL_STATE[f],
|
|
@@ -807,9 +924,9 @@ function CampaignMonitor({ id, onBack, onEdit }) {
|
|
|
807
924
|
] });
|
|
808
925
|
}
|
|
809
926
|
function SendHistorySurface() {
|
|
810
|
-
const [rows, setRows] =
|
|
811
|
-
const [names, setNames] =
|
|
812
|
-
|
|
927
|
+
const [rows, setRows] = React3.useState(null);
|
|
928
|
+
const [names, setNames] = React3.useState({});
|
|
929
|
+
React3.useEffect(() => {
|
|
813
930
|
void Promise.all([journeysApi.targets({ limit: 500 }), journeysApi.campaigns()]).then(([t, c]) => {
|
|
814
931
|
setRows(t);
|
|
815
932
|
setNames(Object.fromEntries(c.map((x) => [x.id, x.name])));
|
|
@@ -823,6 +940,7 @@ function SendHistorySurface() {
|
|
|
823
940
|
/* @__PURE__ */ jsx("h2", { className: "text-base font-semibold", children: "Hist\xF3rico de envios" }),
|
|
824
941
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Cada mensagem que as campanhas mandaram, a quem, e o que aconteceu com ela." })
|
|
825
942
|
] }),
|
|
943
|
+
/* @__PURE__ */ jsx(CampaignBreakdown, {}),
|
|
826
944
|
/* @__PURE__ */ jsx(Card, { className: "overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "max-h-[640px] overflow-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-xs", children: [
|
|
827
945
|
/* @__PURE__ */ jsx("thead", { className: "sticky top-0 bg-card text-left text-muted-foreground", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
828
946
|
/* @__PURE__ */ jsx("th", { className: "px-3 py-2", children: "Quando" }),
|
|
@@ -858,5 +976,5 @@ function SendHistorySurface() {
|
|
|
858
976
|
}
|
|
859
977
|
|
|
860
978
|
export { CampaignsSurface, SendHistorySurface };
|
|
861
|
-
//# sourceMappingURL=CampaignsSurface-
|
|
862
|
-
//# sourceMappingURL=CampaignsSurface-
|
|
979
|
+
//# sourceMappingURL=CampaignsSurface-KFWU5XUP.js.map
|
|
980
|
+
//# sourceMappingURL=CampaignsSurface-KFWU5XUP.js.map
|