@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.
Files changed (38) hide show
  1. package/dist/{CrmPage-T2HQ67N2.js → CrmPage-EAJCZ47X.js} +263 -111
  2. package/dist/CrmPage-EAJCZ47X.js.map +1 -0
  3. package/dist/{SegmentsView-52KIU7NZ.js → SegmentsView-JTFU6XWD.js} +30 -5
  4. package/dist/SegmentsView-JTFU6XWD.js.map +1 -0
  5. package/dist/{chunk-J6LYFSFJ.js → chunk-PZMJUORG.js} +5 -2
  6. package/dist/chunk-PZMJUORG.js.map +1 -0
  7. package/dist/components/SegmentEditorDialog.d.ts.map +1 -1
  8. package/dist/data/mock.d.ts.map +1 -1
  9. package/dist/data/registries.d.ts.map +1 -1
  10. package/dist/data/supabase.d.ts.map +1 -1
  11. package/dist/data/types.d.ts +3 -1
  12. package/dist/data/types.d.ts.map +1 -1
  13. package/dist/index.js +92 -10
  14. package/dist/index.js.map +1 -1
  15. package/dist/locales/en.d.ts.map +1 -1
  16. package/dist/locales/pt-BR.d.ts.map +1 -1
  17. package/dist/migrations/index.d.ts +2 -0
  18. package/dist/migrations/index.d.ts.map +1 -1
  19. package/dist/migrations/main.browser.js +3 -1
  20. package/dist/migrations/main.browser.js.map +1 -1
  21. package/dist/migrations/main.js +411 -2
  22. package/dist/migrations/main.js.map +1 -1
  23. package/dist/schema/index.d.ts +17 -0
  24. package/dist/schema/index.d.ts.map +1 -1
  25. package/dist/schema.cjs +1 -0
  26. package/dist/schema.cjs.map +1 -1
  27. package/dist/schema.js +1 -0
  28. package/dist/schema.js.map +1 -1
  29. package/dist/types.d.ts +24 -0
  30. package/dist/types.d.ts.map +1 -1
  31. package/dist/views/CrmPage.d.ts.map +1 -1
  32. package/dist/views/PanelsViews.d.ts +4 -0
  33. package/dist/views/PanelsViews.d.ts.map +1 -0
  34. package/dist/views/dashboardWidgets.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/CrmPage-T2HQ67N2.js.map +0 -1
  37. package/dist/SegmentsView-52KIU7NZ.js.map +0 -1
  38. package/dist/chunk-J6LYFSFJ.js.map +0 -1
@@ -1,17 +1,199 @@
1
- import { AssigneeName, formatDocument, DEFAULT_ACTIVITY_TYPES, localPhoneKey, normalizeDocument, isValidDocument } from './chunk-J6LYFSFJ.js';
1
+ import { AssigneeName, formatDocument, DEFAULT_ACTIVITY_TYPES, localPhoneKey, normalizeDocument, isValidDocument } from './chunk-PZMJUORG.js';
2
2
  import { CrmGeneralSettings } from './chunk-CA24LK57.js';
3
3
  import { useCrmUnitFilter, UnitPicker } from './chunk-VFLS65NL.js';
4
4
  import { loadTeamOrNull, loadMyUserId, DotChip, humanizeTag, TagChips, resolveSourceView } from './chunk-EHGAPCZF.js';
5
5
  import { CrmContextProvider, useCrmProvider, useCrmStore, useCrmConfig, formatCurrency } from './chunk-7V46TYYX.js';
6
- import React, { useCallback, useMemo, useState, useEffect, useRef } from 'react';
7
- import { Archive, FileX2, FileCheck2, Send, FilePlus2, XCircle, Trophy, PhoneCall, MoveRight, Target, ArrowRightLeft, UserPlus, MapPin, MessageCircle, CheckSquare, FileText, Users, Mail, Phone, Filter, Globe, Check, ChevronRight, Plus, Settings, Tag, Briefcase, CircleDot, User, Download, CircleDashed, Search, Inbox, X, Play, Clock, Sparkles, Calendar, ArrowRight, MoreHorizontal, ChevronDown, Printer, Pencil, CircleCheckBig, Ban, Receipt, Package, CalendarClock, Loader2, Network, Building2, Star, Trash2, MessageSquareQuote, UserRound, CalendarDays, ThumbsDown, SignalHigh, CalendarRange, TrendingDown, UserCheck, AlertTriangle, Settings2, Repeat, Zap, Snowflake, Sun, Flame, Merge, Fingerprint, Paperclip, ImageOff, CircleAlert, Link2, CheckCircle2, ExternalLink, Clipboard, DollarSign, ThumbsUp, SlidersHorizontal, ChevronLeft, UserRoundPlus } from 'lucide-react';
8
- import { PageTransition, ModulePage, Button, useIsWide, PageHeaderActions, usePageSize, toast, FilterChip, MultiSelect, FilterMenu, FilterMenuRow, PersonAvatar, SubpageHeader, ListView, ConfirmDialog, Modal, ModalContent, ModalHeader, ModalTitle, ModalBody, Input, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, Textarea, ModalFooter, useSaveBar, SearchSelect, DatePicker, useFilterDraft, FilterPanel, FilterPanelField, RequiredFilter, Card, DataTable, Dropdown, DropdownTrigger, DropdownContent, DropdownItem, PhoneLink, ComingSoon, Switch, TooltipProvider, Tooltip, TooltipTrigger, TooltipContent, DashboardCanvas, Pagination, PersonPicker, cn, HeaderTabs, SheetBody, SheetFooter, Popover, PopoverTrigger, PopoverContent, getLucideIcon, DictateButton, DropdownLabel, DropdownSeparator, ModalDescription, normalizePhone } from '@fayz-ai/ui';
9
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
+ import React2, { useCallback, useMemo, useState, useEffect, useRef } from 'react';
7
+ import { Archive, FileX2, FileCheck2, Send, FilePlus2, XCircle, Trophy, PhoneCall, MoveRight, Target, ArrowRightLeft, UserPlus, MapPin, MessageCircle, CheckSquare, FileText, Users, Mail, Phone, Filter, Globe, Check, ChevronRight, Plus, Settings, Tag, Briefcase, CircleDot, User, Download, CircleDashed, Search, Inbox, X, Play, Clock, Sparkles, Calendar, ArrowRight, MoreHorizontal, ChevronDown, Printer, Pencil, CircleCheckBig, Ban, Receipt, Package, CalendarClock, Loader2, Network, Building2, CheckCircle2, AlertTriangle, Star, Trash2, MessageSquareQuote, UserRound, CalendarDays, ThumbsDown, SignalHigh, CalendarRange, TrendingDown, UserCheck, Settings2, Repeat, Zap, Snowflake, Sun, Flame, Merge, Fingerprint, Paperclip, ImageOff, CircleAlert, Link2, RefreshCw, ExternalLink, Clipboard, DollarSign, ThumbsUp, SlidersHorizontal, ChevronLeft, UserRoundPlus } from 'lucide-react';
8
+ import { PageTransition, ModulePage, Button, useIsWide, PageHeaderActions, usePageSize, toast, FilterChip, MultiSelect, FilterMenu, FilterMenuRow, PersonAvatar, SubpageHeader, ListView, ConfirmDialog, Modal, ModalContent, ModalHeader, ModalTitle, ModalBody, Input, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, Textarea, ModalFooter, useSaveBar, SearchSelect, DatePicker, useFilterDraft, FilterPanel, FilterPanelField, RequiredFilter, Card, DataTable, Dropdown, DropdownTrigger, DropdownContent, DropdownItem, PhoneLink, ComingSoon, StatTiles, Switch, TooltipProvider, Tooltip, TooltipTrigger, TooltipContent, DashboardCanvas, Pagination, PersonPicker, cn, HeaderTabs, SheetBody, SheetFooter, Popover, PopoverTrigger, PopoverContent, getLucideIcon, DictateButton, DropdownLabel, DropdownSeparator, ModalDescription, normalizePhone } from '@fayz-ai/ui';
10
9
  import { usePluginRuntimeOptional, useTranslation, currentAppPath, navigateApp, useActiveTenantId, exportCSV, getCurrentLocale, appHref, getSupabaseClientOptional, loadMessageOverrides, resolveMessages, useActiveUnitId } from '@fayz-ai/core';
10
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
11
11
  import { useModuleNavigation, usePluginOnboardingGate, useUnitStore, PluginOnboardingGateSkeleton, createViewRouter, ModuleActionBar, adminNavigateTo, PageActions, usePermissionOptional, usePersistedState, useScrollMemory, useLimitGuard, useCatalogedItemTypes, OrderFormSkeleton, OrderFormBlock, OrderFormView, OrderFormItemsCard, OrderFormItemRow, OrderFormAddItemStep, createArchetypeLookup, useRecordVisit, AddressesTab, OrderDetailSkeleton, OrderDetailBlock, OrderDetailView, PersonLink, CrudFormSkeleton, CrudFormPage, CrudDetailSkeleton, CrudDetailPage, AskAIButton, KanbanBoard, InlineField, invalidateLimit, useAccessOptional, useOrganizationStore, getRailPage, RightRailPage, ContactPicker, useAgentSurface } from '@fayz-ai/admin';
12
12
  import { createPortal } from 'react-dom';
13
13
  import { HelpdeskStatusPanel } from '@fayz-ai/plugin-support';
14
14
 
15
+ function usePanel(fn, args = {}) {
16
+ const [data, setData] = React2.useState(null);
17
+ const [error, setError] = React2.useState(null);
18
+ const [loading, setLoading] = React2.useState(true);
19
+ const load = React2.useCallback(async () => {
20
+ setLoading(true);
21
+ try {
22
+ const sb = getSupabaseClientOptional();
23
+ const { data: d, error: e } = await sb.rpc(fn, args);
24
+ if (e) throw new Error(e.message);
25
+ setData(d);
26
+ setError(null);
27
+ } catch (e) {
28
+ setError(e.message);
29
+ } finally {
30
+ setLoading(false);
31
+ }
32
+ }, [fn]);
33
+ React2.useEffect(() => {
34
+ void load();
35
+ }, [load]);
36
+ return { data, error, loading, reload: load };
37
+ }
38
+ function Header({ title, subtitle, onReload, loading }) {
39
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start justify-between gap-2", children: [
40
+ /* @__PURE__ */ jsxs("div", { children: [
41
+ /* @__PURE__ */ jsx("h2", { className: "text-base font-semibold", children: title }),
42
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: subtitle })
43
+ ] }),
44
+ /* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", onClick: onReload, disabled: loading, children: [
45
+ loading ? /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ jsx(RefreshCw, { className: "h-3.5 w-3.5" }),
46
+ " Atualizar"
47
+ ] })
48
+ ] });
49
+ }
50
+ var cell = "px-3 py-2 text-right tabular-nums";
51
+ var warn = (n) => n > 0 ? "font-semibold text-destructive" : "text-muted-foreground";
52
+ function OperationalPanelView() {
53
+ const { data, error, loading, reload } = usePanel("crm_operational_panel", { p_stalled_days: 14 });
54
+ const totals = data?.totals ?? {};
55
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
56
+ /* @__PURE__ */ jsx(Header, { title: "Painel operacional", subtitle: "O dia de cada vendedor: o que est\xE1 atrasado, o que ningu\xE9m tocou, quem est\xE1 esperando resposta.", onReload: reload, loading }),
57
+ error && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive", children: error }),
58
+ /* @__PURE__ */ jsx(
59
+ StatTiles,
60
+ {
61
+ loading: loading && !data,
62
+ tiles: [
63
+ { id: "open", label: "Neg\xF3cios no fluxo", value: totals.open_deals, hint: "abertos, fora das etapas de espera" },
64
+ { id: "uncontacted", label: "Sem nenhum contato", value: totals.uncontacted, hint: "nenhuma mensagem, liga\xE7\xE3o ou visita registrada" },
65
+ { id: "stalled", label: "Parados h\xE1 14+ dias", value: totals.stalled, hint: "sem nenhuma movimenta\xE7\xE3o" },
66
+ { id: "waiting", label: "Conversas esperando", value: totals.waiting_conversations, hint: `${totals.overdue_tasks ?? 0} tarefas vencidas \xB7 ${totals.today_tasks ?? 0} para hoje` }
67
+ ]
68
+ }
69
+ ),
70
+ /* @__PURE__ */ jsxs(Card, { className: "overflow-hidden", children: [
71
+ /* @__PURE__ */ jsx("p", { className: "border-b px-3 py-2 text-sm font-medium", children: "Por vendedor" }),
72
+ /* @__PURE__ */ jsx("div", { className: "overflow-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-xs", children: [
73
+ /* @__PURE__ */ jsx("thead", { className: "text-muted-foreground", children: /* @__PURE__ */ jsxs("tr", { children: [
74
+ /* @__PURE__ */ jsx("th", { className: "px-3 py-2 text-left", children: "Vendedor" }),
75
+ /* @__PURE__ */ jsx("th", { className: cell, children: "No fluxo" }),
76
+ /* @__PURE__ */ jsx("th", { className: cell, children: "Sem contato" }),
77
+ /* @__PURE__ */ jsx("th", { className: cell, children: "Parados" }),
78
+ /* @__PURE__ */ jsx("th", { className: cell, children: "Tarefas vencidas" }),
79
+ /* @__PURE__ */ jsx("th", { className: cell, children: "Para hoje" }),
80
+ /* @__PURE__ */ jsx("th", { className: cell, children: "Conversas esperando" })
81
+ ] }) }),
82
+ /* @__PURE__ */ jsx("tbody", { children: (data?.by_owner ?? []).filter((o) => o.open_deals || o.overdue_tasks || o.waiting_conversations).sort((a, b) => b.open_deals - a.open_deals).map((o) => /* @__PURE__ */ jsxs("tr", { className: "border-t", children: [
83
+ /* @__PURE__ */ jsx("td", { className: "px-3 py-2 font-medium", children: o.name }),
84
+ /* @__PURE__ */ jsx("td", { className: cell, children: o.open_deals }),
85
+ /* @__PURE__ */ jsx("td", { className: `${cell} ${warn(o.uncontacted)}`, children: o.uncontacted }),
86
+ /* @__PURE__ */ jsx("td", { className: `${cell} ${warn(o.stalled)}`, children: o.stalled }),
87
+ /* @__PURE__ */ jsx("td", { className: `${cell} ${warn(o.overdue_tasks)}`, children: o.overdue_tasks }),
88
+ /* @__PURE__ */ jsx("td", { className: cell, children: o.today_tasks }),
89
+ /* @__PURE__ */ jsx("td", { className: `${cell} ${warn(o.waiting_conversations)}`, children: o.waiting_conversations })
90
+ ] }, o.owner_id ?? "none")) })
91
+ ] }) })
92
+ ] }),
93
+ /* @__PURE__ */ jsxs(Card, { className: "overflow-hidden", children: [
94
+ /* @__PURE__ */ jsx("p", { className: "border-b px-3 py-2 text-sm font-medium", children: "Por etapa" }),
95
+ /* @__PURE__ */ jsxs("table", { className: "w-full text-xs", children: [
96
+ /* @__PURE__ */ jsx("thead", { className: "text-muted-foreground", children: /* @__PURE__ */ jsxs("tr", { children: [
97
+ /* @__PURE__ */ jsx("th", { className: "px-3 py-2 text-left", children: "Etapa" }),
98
+ /* @__PURE__ */ jsx("th", { className: cell, children: "Neg\xF3cios" }),
99
+ /* @__PURE__ */ jsx("th", { className: cell, children: "Parados 14+ dias" }),
100
+ /* @__PURE__ */ jsx("th", { className: cell, children: "Dias desde o \xFAltimo movimento (m\xE9dia)" })
101
+ ] }) }),
102
+ /* @__PURE__ */ jsx("tbody", { children: (data?.by_stage ?? []).map((s) => /* @__PURE__ */ jsxs("tr", { className: "border-t", children: [
103
+ /* @__PURE__ */ jsx("td", { className: "px-3 py-2 font-medium", children: s.stage }),
104
+ /* @__PURE__ */ jsx("td", { className: cell, children: s.open }),
105
+ /* @__PURE__ */ jsx("td", { className: `${cell} ${warn(s.stalled)}`, children: s.stalled }),
106
+ /* @__PURE__ */ jsx("td", { className: cell, children: s.avg_days })
107
+ ] }, s.stage)) })
108
+ ] })
109
+ ] })
110
+ ] });
111
+ }
112
+ function MaturityPanelView() {
113
+ const { data, error, loading, reload } = usePanel("crm_maturity_panel");
114
+ const deals = Number(data?.deals ?? 0);
115
+ const h = data?.hygiene ?? {};
116
+ const inbox = data?.inbox ?? {};
117
+ const pct2 = (n) => deals ? Math.round(100 * (deals - n) / deals) : 0;
118
+ const checks = [
119
+ { label: "Neg\xF3cios com respons\xE1vel", ok: pct2(h.no_owner ?? 0), missing: h.no_owner },
120
+ { label: "Neg\xF3cios com empresa", ok: pct2(h.no_company ?? 0), missing: h.no_company },
121
+ { label: "Neg\xF3cios com contato (lead)", ok: pct2(h.no_contact ?? 0), missing: h.no_contact },
122
+ { label: "Contato com telefone", ok: pct2(h.no_phone ?? 0), missing: h.no_phone },
123
+ { label: "Abertos que se mexeram em 30 dias", ok: pct2(h.stale_30d ?? 0), missing: h.stale_30d }
124
+ ];
125
+ const score = checks.length ? Math.round(checks.reduce((a, c) => a + c.ok, 0) / checks.length) : 0;
126
+ const outPlatform = Number(inbox.outbound_platform_30d ?? 0);
127
+ const outPhone = Number(inbox.outbound_phone_30d ?? 0);
128
+ const sellers = data?.activity_by_seller ?? [];
129
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
130
+ /* @__PURE__ */ jsx(Header, { title: "Maturidade", subtitle: "O CRM est\xE1 sendo usado do jeito que foi montado? Cadastro completo, atividade registrada e conversa pela plataforma.", onReload: reload, loading }),
131
+ error && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive", children: error }),
132
+ /* @__PURE__ */ jsx(
133
+ StatTiles,
134
+ {
135
+ loading: loading && !data,
136
+ tiles: [
137
+ { id: "score", label: "Nota do cadastro", value: data ? `${score}/100` : void 0, hint: "m\xE9dia das checagens abaixo" },
138
+ { id: "deals", label: "Neg\xF3cios avaliados", value: deals },
139
+ { id: "active", label: "Vendedores ativos (7 dias)", value: sellers.filter((s) => s.last_7d > 0).length, hint: `de ${sellers.length} na equipe` },
140
+ { id: "inbox", label: "WhatsApp pela plataforma", value: data ? `${outPlatform + outPhone ? Math.round(100 * outPlatform / (outPlatform + outPhone)) : 0}%` : void 0, hint: `${outPhone} respostas pelo celular em 30 dias` }
141
+ ]
142
+ }
143
+ ),
144
+ /* @__PURE__ */ jsxs(Card, { className: "space-y-2 p-4", children: [
145
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: "Cadastro" }),
146
+ checks.map((c) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 text-xs", children: [
147
+ c.ok >= 90 ? /* @__PURE__ */ jsx(CheckCircle2, { className: "h-4 w-4 shrink-0 text-success" }) : /* @__PURE__ */ jsx(AlertTriangle, { className: "h-4 w-4 shrink-0 text-warning" }),
148
+ /* @__PURE__ */ jsx("span", { className: "w-64 shrink-0", children: c.label }),
149
+ /* @__PURE__ */ jsx("div", { className: "h-2 flex-1 overflow-hidden rounded-full bg-muted", children: /* @__PURE__ */ jsx("div", { className: `h-full ${c.ok >= 90 ? "bg-success" : "bg-warning"}`, style: { width: `${c.ok}%` } }) }),
150
+ /* @__PURE__ */ jsxs("span", { className: "w-24 shrink-0 text-right tabular-nums", children: [
151
+ c.ok,
152
+ "% \xB7 faltam ",
153
+ c.missing ?? 0
154
+ ] })
155
+ ] }, c.label))
156
+ ] }),
157
+ /* @__PURE__ */ jsxs(Card, { className: "overflow-hidden", children: [
158
+ /* @__PURE__ */ jsx("p", { className: "border-b px-3 py-2 text-sm font-medium", children: "Atividade registrada por vendedor" }),
159
+ /* @__PURE__ */ jsxs("table", { className: "w-full text-xs", children: [
160
+ /* @__PURE__ */ jsx("thead", { className: "text-muted-foreground", children: /* @__PURE__ */ jsxs("tr", { children: [
161
+ /* @__PURE__ */ jsx("th", { className: "px-3 py-2 text-left", children: "Vendedor" }),
162
+ /* @__PURE__ */ jsx("th", { className: cell, children: "\xDAltimos 7 dias" }),
163
+ /* @__PURE__ */ jsx("th", { className: cell, children: "\xDAltimos 30 dias" }),
164
+ /* @__PURE__ */ jsx("th", { className: cell, children: "WhatsApp (30 dias)" })
165
+ ] }) }),
166
+ /* @__PURE__ */ jsx("tbody", { children: sellers.map((s) => /* @__PURE__ */ jsxs("tr", { className: "border-t", children: [
167
+ /* @__PURE__ */ jsx("td", { className: "px-3 py-2 font-medium", children: s.name }),
168
+ /* @__PURE__ */ jsx("td", { className: `${cell} ${s.last_7d ? "" : "text-muted-foreground"}`, children: s.last_7d }),
169
+ /* @__PURE__ */ jsx("td", { className: cell, children: s.last_30d }),
170
+ /* @__PURE__ */ jsx("td", { className: cell, children: s.whatsapp_30d })
171
+ ] }, s.user_id)) })
172
+ ] })
173
+ ] }),
174
+ /* @__PURE__ */ jsxs(Card, { className: "p-4 text-xs", children: [
175
+ /* @__PURE__ */ jsx("p", { className: "mb-2 text-sm font-medium", children: "Conversas (30 dias)" }),
176
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-2 sm:grid-cols-4", children: [
177
+ /* @__PURE__ */ jsxs("div", { children: [
178
+ /* @__PURE__ */ jsx("p", { className: "text-lg font-semibold", children: inbox.inbound_30d ?? 0 }),
179
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "mensagens recebidas" })
180
+ ] }),
181
+ /* @__PURE__ */ jsxs("div", { children: [
182
+ /* @__PURE__ */ jsx("p", { className: "text-lg font-semibold", children: outPlatform }),
183
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "respondidas pela plataforma" })
184
+ ] }),
185
+ /* @__PURE__ */ jsxs("div", { children: [
186
+ /* @__PURE__ */ jsx("p", { className: "text-lg font-semibold", children: outPhone }),
187
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "respondidas pelo celular" })
188
+ ] }),
189
+ /* @__PURE__ */ jsxs("div", { children: [
190
+ /* @__PURE__ */ jsx("p", { className: "text-lg font-semibold", children: inbox.outbound_campaign_30d ?? 0 }),
191
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "enviadas por campanha" })
192
+ ] })
193
+ ] })
194
+ ] })
195
+ ] });
196
+ }
15
197
  var EVIDENCE_LABEL = {
16
198
  cnpj_root: "mesma raiz de CNPJ",
17
199
  document_root: "mesma raiz de CNPJ",
@@ -29,13 +211,13 @@ var KINDS = [
29
211
  ];
30
212
  function GroupRow({ g, onOpen, open, members, roll, onEdit, onAdd, onRemove, onDelete, search }) {
31
213
  const { currency } = useCrmConfig();
32
- const [editing, setEditing] = React.useState(false);
33
- const [draftName, setDraftName] = React.useState(g.name);
34
- const [draftKind, setDraftKind] = React.useState(g.kind ?? "economic_group");
35
- const [term, setTerm] = React.useState("");
36
- const [hits, setHits] = React.useState([]);
37
- const [busy, setBusy] = React.useState(false);
38
- React.useEffect(() => {
214
+ const [editing, setEditing] = React2.useState(false);
215
+ const [draftName, setDraftName] = React2.useState(g.name);
216
+ const [draftKind, setDraftKind] = React2.useState(g.kind ?? "economic_group");
217
+ const [term, setTerm] = React2.useState("");
218
+ const [hits, setHits] = React2.useState([]);
219
+ const [busy, setBusy] = React2.useState(false);
220
+ React2.useEffect(() => {
39
221
  if (term.trim().length < 2) {
40
222
  setHits([]);
41
223
  return;
@@ -229,16 +411,16 @@ function GroupRow({ g, onOpen, open, members, roll, onEdit, onAdd, onRemove, onD
229
411
  }
230
412
  function CompanyGroupsView() {
231
413
  const provider = useCrmProvider();
232
- const [groups, setGroups] = React.useState(null);
233
- const [candidates, setCandidates] = React.useState([]);
234
- const [openId, setOpenId] = React.useState(null);
235
- const [members, setMembers] = React.useState({});
236
- const [rollups, setRollups] = React.useState({});
237
- const [names, setNames] = React.useState({});
238
- const [busy, setBusy] = React.useState(null);
239
- const [novoAberto, setNovoAberto] = React.useState(false);
240
- const [novoNome, setNovoNome] = React.useState("");
241
- const [criando, setCriando] = React.useState(false);
414
+ const [groups, setGroups] = React2.useState(null);
415
+ const [candidates, setCandidates] = React2.useState([]);
416
+ const [openId, setOpenId] = React2.useState(null);
417
+ const [members, setMembers] = React2.useState({});
418
+ const [rollups, setRollups] = React2.useState({});
419
+ const [names, setNames] = React2.useState({});
420
+ const [busy, setBusy] = React2.useState(null);
421
+ const [novoAberto, setNovoAberto] = React2.useState(false);
422
+ const [novoNome, setNovoNome] = React2.useState("");
423
+ const [criando, setCriando] = React2.useState(false);
242
424
  async function criarGrupo() {
243
425
  const nome = novoNome.trim();
244
426
  if (!nome || criando) return;
@@ -255,7 +437,7 @@ function CompanyGroupsView() {
255
437
  setCriando(false);
256
438
  }
257
439
  }
258
- const load = React.useCallback(async () => {
440
+ const load = React2.useCallback(async () => {
259
441
  try {
260
442
  const [g, c, r] = await Promise.all([
261
443
  provider.getCompanyGroups(),
@@ -270,7 +452,7 @@ function CompanyGroupsView() {
270
452
  setGroups([]);
271
453
  }
272
454
  }, [provider]);
273
- React.useEffect(() => {
455
+ React2.useEffect(() => {
274
456
  void load();
275
457
  }, [load]);
276
458
  async function toggle(id) {
@@ -1096,7 +1278,7 @@ function usePipelineAgentSurface(deps) {
1096
1278
  }
1097
1279
  var CHIP_ROW = "flex w-full justify-start whitespace-normal font-normal gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-muted";
1098
1280
  function BoardFilterChip({ trigger, onClear, clearLabel, closeOnSelect, children }) {
1099
- const [open, setOpen] = React.useState(false);
1281
+ const [open, setOpen] = React2.useState(false);
1100
1282
  return /* @__PURE__ */ jsxs(Dropdown, { open, onOpenChange: setOpen, children: [
1101
1283
  /* @__PURE__ */ jsx(DropdownTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
1102
1284
  Button,
@@ -3536,7 +3718,7 @@ function formatDocument2(doc) {
3536
3718
  return doc;
3537
3719
  }
3538
3720
  function CopyDocument({ document: doc, label: label2 }) {
3539
- const [copied, setCopied] = React.useState(false);
3721
+ const [copied, setCopied] = React2.useState(false);
3540
3722
  return /* @__PURE__ */ jsx(
3541
3723
  Button,
3542
3724
  {
@@ -4689,7 +4871,7 @@ function DealsView({ mode, onChangeMode, openDealId, onOpenDeal, onCloseDeal, on
4689
4871
  const refreshBoard = useCrmStore((s) => s.refreshBoard);
4690
4872
  const addLead = onAddLead ? (stageId) => setNovoLead({ stageId }) : void 0;
4691
4873
  const dealsByStage = useCrmStore((s) => s.dealsByStage);
4692
- const seedDeal = React.useMemo(() => {
4874
+ const seedDeal = React2.useMemo(() => {
4693
4875
  if (!openId) return null;
4694
4876
  for (const lista of dealsByStage.values()) {
4695
4877
  const d = lista.find((x) => x.id === openId);
@@ -4969,36 +5151,6 @@ function PendingReturnsView() {
4969
5151
  }
4970
5152
  );
4971
5153
  }
4972
- function OperationalDashboardView() {
4973
- return /* @__PURE__ */ jsx(
4974
- ComingSoon,
4975
- {
4976
- title: "Painel operacional",
4977
- summary: "O dia da opera\xE7\xE3o num quadro: agenda ocupada, atendimentos, ticket, o que est\xE1 atrasado.",
4978
- v1Path: "CRM \u2192 Dashboard Operacional",
4979
- measured: "Vista de leitura no V1, montada sobre agendamentos e faturas. Sem venda pelo sistema n\xE3o tem o que mostrar.",
4980
- missing: [
4981
- "Definir os cinco n\xFAmeros que importam antes de desenhar \u2014 um painel com vinte cart\xF5es n\xE3o \xE9 lido",
4982
- "O Resumo do CRM j\xE1 responde parte disto; decidir se s\xE3o duas telas ou uma"
4983
- ]
4984
- }
4985
- );
4986
- }
4987
- function MaturityView() {
4988
- return /* @__PURE__ */ jsx(
4989
- ComingSoon,
4990
- {
4991
- title: "Maturidade operacional",
4992
- summary: "O quanto a casa usa o sistema de verdade: o que est\xE1 configurado, o que est\xE1 pela metade, o que nunca foi ligado.",
4993
- v1Path: "CRM \u2192 Maturidade Operacional",
4994
- measured: "Vista de leitura no V1 \u2014 pontua a conta contra uma lista de checagens.",
4995
- missing: [
4996
- "A lista de checagens \xE9 a tela: sem ela combinada, a nota n\xE3o quer dizer nada",
4997
- "Os \xABPrimeiros passos\xBB daqui j\xE1 fazem parte disto, e para a conta nova s\xE3o melhores \u2014 isto \xE9 a mesma pergunta para quem j\xE1 rodou um ano"
4998
- ]
4999
- }
5000
- );
5001
- }
5002
5154
  var LEAD_STATUS_OPTIONS = [
5003
5155
  { value: "new", labelKey: "crm.leads.statusNew", dot: "#3B82F6" },
5004
5156
  { value: "contacted", labelKey: "crm.leads.statusContacted", dot: "#8B5CF6" },
@@ -6067,7 +6219,7 @@ function QuoteFormView({ quoteId, leadId, onSaved }) {
6067
6219
  const config = useCrmConfig();
6068
6220
  const provider = useCrmProvider();
6069
6221
  const { currency, itemTypes: declaredItemTypes } = config;
6070
- const translatedItemTypes = React.useMemo(
6222
+ const translatedItemTypes = React2.useMemo(
6071
6223
  () => declaredItemTypes.map((tp) => {
6072
6224
  const traduzido = t(`crm.itemType.${tp.value}`);
6073
6225
  return traduzido === `crm.itemType.${tp.value}` ? tp : { ...tp, label: traduzido };
@@ -6142,7 +6294,7 @@ function QuoteFormView({ quoteId, leadId, onSaved }) {
6142
6294
  setQuoteDate(iso);
6143
6295
  if (validityDays !== null) setValidUntil(addDays(iso, validityDays));
6144
6296
  }
6145
- const openCustomOnMount = React.useRef(false);
6297
+ const openCustomOnMount = React2.useRef(false);
6146
6298
  function pickValidity(days) {
6147
6299
  openCustomOnMount.current = days === null && validityDays !== null;
6148
6300
  setValidityDays(days);
@@ -6219,7 +6371,7 @@ function QuoteFormView({ quoteId, leadId, onSaved }) {
6219
6371
  observations,
6220
6372
  items: items.map((it) => ({ itemKind: it.itemKind, description: it.description, quantity: it.quantity, unitPrice: it.unitPrice, discount: it.discount }))
6221
6373
  };
6222
- const snapshot = React.useRef(null);
6374
+ const snapshot = React2.useRef(null);
6223
6375
  useEffect(() => {
6224
6376
  if (!loadingExisting && snapshot.current === null) snapshot.current = JSON.stringify(currentFields);
6225
6377
  }, [loadingExisting]);
@@ -8020,8 +8172,8 @@ var INLINE_LINK = "text-xs font-normal text-primary hover:underline";
8020
8172
  function CompanyGroupBadge({ companyId, onOpenCompany }) {
8021
8173
  const provider = useCrmProvider();
8022
8174
  const { currency } = useCrmConfig();
8023
- const [data, setData] = React.useState(null);
8024
- React.useEffect(() => {
8175
+ const [data, setData] = React2.useState(null);
8176
+ React2.useEffect(() => {
8025
8177
  let alive = true;
8026
8178
  provider.getGroupOfCompany(companyId).then((d) => {
8027
8179
  if (alive) setData(d);
@@ -9027,10 +9179,10 @@ function NetworkView() {
9027
9179
  const t = useTranslation();
9028
9180
  const provider = useCrmProvider();
9029
9181
  const { currency } = useCrmConfig();
9030
- const [days, setDays] = React.useState("90");
9031
- const [rows, setRows] = React.useState(null);
9032
- const [weights, setWeights] = React.useState({});
9033
- React.useEffect(() => {
9182
+ const [days, setDays] = React2.useState("90");
9183
+ const [rows, setRows] = React2.useState(null);
9184
+ const [weights, setWeights] = React2.useState({});
9185
+ React2.useEffect(() => {
9034
9186
  let alive = true;
9035
9187
  const to = (/* @__PURE__ */ new Date()).toISOString();
9036
9188
  const from = new Date(Date.now() - Number(days) * 864e5).toISOString();
@@ -9047,10 +9199,10 @@ function NetworkView() {
9047
9199
  alive = false;
9048
9200
  };
9049
9201
  }, [provider, days]);
9050
- const scored = React.useMemo(() => scoreUnits(rows ?? [], weights), [rows, weights]);
9202
+ const scored = React2.useMemo(() => scoreUnits(rows ?? [], weights), [rows, weights]);
9051
9203
  const avg = networkScore(scored);
9052
- const ranked = React.useMemo(() => [...scored].sort((a, b) => b.revenue - a.revenue), [scored]);
9053
- const columns = React.useMemo(() => {
9204
+ const ranked = React2.useMemo(() => [...scored].sort((a, b) => b.revenue - a.revenue), [scored]);
9205
+ const columns = React2.useMemo(() => {
9054
9206
  const NUM = { className: "text-right" };
9055
9207
  return [
9056
9208
  {
@@ -9248,11 +9400,11 @@ function SurveyScale({ type, value, onChange, readOnly, compact }) {
9248
9400
  ] });
9249
9401
  }
9250
9402
  function SurveyEditorDialog({ survey, provider, answeredQuestionIds, onClose, onSaved }) {
9251
- const [name, setName] = React.useState(survey?.name ?? "Pesquisa p\xF3s-atendimento");
9252
- const [isActive, setIsActive] = React.useState(survey?.isActive ?? true);
9253
- const [askOnCheckout, setAskOnCheckout] = React.useState(survey?.askOnCheckout ?? true);
9254
- const [thanks, setThanks] = React.useState(survey?.thankYouMessage ?? "");
9255
- const [questions, setQuestions] = React.useState(
9403
+ const [name, setName] = React2.useState(survey?.name ?? "Pesquisa p\xF3s-atendimento");
9404
+ const [isActive, setIsActive] = React2.useState(survey?.isActive ?? true);
9405
+ const [askOnCheckout, setAskOnCheckout] = React2.useState(survey?.askOnCheckout ?? true);
9406
+ const [thanks, setThanks] = React2.useState(survey?.thankYouMessage ?? "");
9407
+ const [questions, setQuestions] = React2.useState(
9256
9408
  (survey?.questions ?? []).map((q) => ({
9257
9409
  id: q.id,
9258
9410
  text: q.text,
@@ -9262,8 +9414,8 @@ function SurveyEditorDialog({ survey, provider, answeredQuestionIds, onClose, on
9262
9414
  answered: answeredQuestionIds?.has(q.id)
9263
9415
  }))
9264
9416
  );
9265
- const [saving, setSaving] = React.useState(false);
9266
- const [error, setError] = React.useState(null);
9417
+ const [saving, setSaving] = React2.useState(false);
9418
+ const [error, setError] = React2.useState(null);
9267
9419
  function patch(i, changes) {
9268
9420
  setQuestions((qs) => qs.map((q, j) => j === i ? { ...q, ...changes } : q));
9269
9421
  }
@@ -9448,13 +9600,13 @@ function SurveyEditorDialog({ survey, provider, answeredQuestionIds, onClose, on
9448
9600
  }
9449
9601
  function SurveyCollectDialog({ survey, provider, contactLookup, onClose, onSaved }) {
9450
9602
  const unitId = useActiveUnitId();
9451
- const [contact, setContact] = React.useState(null);
9452
- const [answers, setAnswers] = React.useState(
9603
+ const [contact, setContact] = React2.useState(null);
9604
+ const [answers, setAnswers] = React2.useState(
9453
9605
  Object.fromEntries(survey.questions.map((q) => [q.id, { rating: null, comment: "" }]))
9454
9606
  );
9455
- const [saving, setSaving] = React.useState(false);
9456
- const [done, setDone] = React.useState(false);
9457
- const [error, setError] = React.useState(null);
9607
+ const [saving, setSaving] = React2.useState(false);
9608
+ const [done, setDone] = React2.useState(false);
9609
+ const [error, setError] = React2.useState(null);
9458
9610
  function patch(id, changes) {
9459
9611
  setAnswers((a) => ({ ...a, [id]: { ...a[id], ...changes } }));
9460
9612
  }
@@ -9552,8 +9704,8 @@ function ResponseSkeleton() {
9552
9704
  ] }, i)) });
9553
9705
  }
9554
9706
  function SurveyResponsesRail({ survey, provider, onClose }) {
9555
- const [responses, setResponses] = React.useState(null);
9556
- React.useEffect(() => {
9707
+ const [responses, setResponses] = React2.useState(null);
9708
+ React2.useEffect(() => {
9557
9709
  let cancelled = false;
9558
9710
  setResponses(null);
9559
9711
  void provider.getSurveyResponses(survey.id).then((r) => {
@@ -9613,19 +9765,19 @@ function SurveysView() {
9613
9765
  const can = usePermissionOptional();
9614
9766
  const canEdit = can("sales", "edit");
9615
9767
  const canDelete = can("sales", "delete");
9616
- const [surveys, setSurveys] = React.useState(null);
9617
- const [stats, setStats] = React.useState({});
9618
- const [editing, setEditing] = React.useState(void 0);
9619
- const [collecting, setCollecting] = React.useState(null);
9620
- const [viewing, setViewing] = React.useState(null);
9621
- const [removing, setRemoving] = React.useState(null);
9622
- const [answeredIds, setAnsweredIds] = React.useState(/* @__PURE__ */ new Set());
9623
- const load = React.useCallback(async () => {
9768
+ const [surveys, setSurveys] = React2.useState(null);
9769
+ const [stats, setStats] = React2.useState({});
9770
+ const [editing, setEditing] = React2.useState(void 0);
9771
+ const [collecting, setCollecting] = React2.useState(null);
9772
+ const [viewing, setViewing] = React2.useState(null);
9773
+ const [removing, setRemoving] = React2.useState(null);
9774
+ const [answeredIds, setAnsweredIds] = React2.useState(/* @__PURE__ */ new Set());
9775
+ const load = React2.useCallback(async () => {
9624
9776
  const [list, st] = await Promise.all([provider.getSurveys(), provider.getSurveyStats()]);
9625
9777
  setSurveys(list);
9626
9778
  setStats(Object.fromEntries(st.map((s) => [s.surveyId, s])));
9627
9779
  }, [provider]);
9628
- React.useEffect(() => {
9780
+ React2.useEffect(() => {
9629
9781
  void load();
9630
9782
  }, [load]);
9631
9783
  const askers = (surveys ?? []).filter((s) => s.isActive && s.askOnCheckout);
@@ -9905,12 +10057,12 @@ function DistributionView() {
9905
10057
  const t = useTranslation();
9906
10058
  const can = usePermissionOptional();
9907
10059
  const canDistribute = can("sales", "edit");
9908
- const [rota, setRota] = React.useState(void 0);
9909
- const [backlog, setBacklog] = React.useState(null);
9910
- const [offers, setOffers] = React.useState(null);
9911
- const [preview, setPreview] = React.useState(null);
9912
- const [busy, setBusy] = React.useState(false);
9913
- const load = React.useCallback(async () => {
10060
+ const [rota, setRota] = React2.useState(void 0);
10061
+ const [backlog, setBacklog] = React2.useState(null);
10062
+ const [offers, setOffers] = React2.useState(null);
10063
+ const [preview, setPreview] = React2.useState(null);
10064
+ const [busy, setBusy] = React2.useState(false);
10065
+ const load = React2.useCallback(async () => {
9914
10066
  const [r, b, o] = await Promise.all([
9915
10067
  provider.getRotaState().catch(() => null),
9916
10068
  provider.getLeadBacklog(500).catch(() => []),
@@ -9920,7 +10072,7 @@ function DistributionView() {
9920
10072
  setBacklog(b);
9921
10073
  setOffers(o);
9922
10074
  }, [provider]);
9923
- React.useEffect(() => {
10075
+ React2.useEffect(() => {
9924
10076
  void load();
9925
10077
  }, [load]);
9926
10078
  async function askPreview() {
@@ -9959,7 +10111,7 @@ function DistributionView() {
9959
10111
  setBusy(false);
9960
10112
  }
9961
10113
  }
9962
- const backlogColumns = React.useMemo(() => [
10114
+ const backlogColumns = React2.useMemo(() => [
9963
10115
  {
9964
10116
  id: "lead",
9965
10117
  header: () => /* @__PURE__ */ jsx("span", { className: "text-xs uppercase", children: t("crm.distribution.lead") }),
@@ -10046,11 +10198,11 @@ function DistributionView() {
10046
10198
  }
10047
10199
  function Countdown({ seconds }) {
10048
10200
  const t = useTranslation();
10049
- const [left, setLeft] = React.useState(seconds);
10050
- React.useEffect(() => {
10201
+ const [left, setLeft] = React2.useState(seconds);
10202
+ React2.useEffect(() => {
10051
10203
  setLeft(seconds);
10052
10204
  }, [seconds]);
10053
- React.useEffect(() => {
10205
+ React2.useEffect(() => {
10054
10206
  if (left <= 0) return;
10055
10207
  const id = setInterval(() => setLeft((s2) => Math.max(0, s2 - 1)), 1e3);
10056
10208
  return () => clearInterval(id);
@@ -10066,16 +10218,16 @@ function Countdown({ seconds }) {
10066
10218
  function MyOffersView() {
10067
10219
  const provider = useCrmProvider();
10068
10220
  const t = useTranslation();
10069
- const [offers, setOffers] = React.useState(null);
10070
- const [busy, setBusy] = React.useState(null);
10071
- const load = React.useCallback(async () => {
10221
+ const [offers, setOffers] = React2.useState(null);
10222
+ const [busy, setBusy] = React2.useState(null);
10223
+ const load = React2.useCallback(async () => {
10072
10224
  try {
10073
10225
  setOffers(await provider.getLeadOffers({ mine: true }));
10074
10226
  } catch {
10075
10227
  setOffers([]);
10076
10228
  }
10077
10229
  }, [provider]);
10078
- React.useEffect(() => {
10230
+ React2.useEffect(() => {
10079
10231
  void load();
10080
10232
  const id = setInterval(() => {
10081
10233
  void load();
@@ -10399,8 +10551,8 @@ function CrmPage({ config, provider, store, registries }) {
10399
10551
  { id: "goals-kpi", render: () => /* @__PURE__ */ jsx(KpiGoalsView, {}) },
10400
10552
  { id: "goals-professionals", render: () => /* @__PURE__ */ jsx(ProfessionalGoalsView, {}) },
10401
10553
  { id: "goals-franchisor", render: () => /* @__PURE__ */ jsx(FranchisorGoalsView, {}) },
10402
- { id: "operational-dashboard", render: () => /* @__PURE__ */ jsx(OperationalDashboardView, {}) },
10403
- { id: "maturity", render: () => /* @__PURE__ */ jsx(MaturityView, {}) },
10554
+ { id: "operational-dashboard", render: () => /* @__PURE__ */ jsx(OperationalPanelView, {}) },
10555
+ { id: "maturity", render: () => /* @__PURE__ */ jsx(MaturityPanelView, {}) },
10404
10556
  { id: "surveys", render: () => /* @__PURE__ */ jsx(SurveysView, {}) },
10405
10557
  { id: "network", render: () => /* @__PURE__ */ jsx(NetworkView, {}) },
10406
10558
  { id: "dashboard", render: () => /* @__PURE__ */ jsx(DashboardView, {}) }
@@ -10428,5 +10580,5 @@ function CrmPage({ config, provider, store, registries }) {
10428
10580
  }
10429
10581
 
10430
10582
  export { CrmPage };
10431
- //# sourceMappingURL=CrmPage-T2HQ67N2.js.map
10432
- //# sourceMappingURL=CrmPage-T2HQ67N2.js.map
10583
+ //# sourceMappingURL=CrmPage-EAJCZ47X.js.map
10584
+ //# sourceMappingURL=CrmPage-EAJCZ47X.js.map