@fayz-ai/plugin-crm 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CrmPage-ZOHVY2FA.js → CrmPage-T2HQ67N2.js} +93 -127
- package/dist/CrmPage-T2HQ67N2.js.map +1 -0
- package/dist/SegmentsView-52KIU7NZ.js +489 -0
- package/dist/SegmentsView-52KIU7NZ.js.map +1 -0
- package/dist/chunk-EHGAPCZF.js +264 -0
- package/dist/chunk-EHGAPCZF.js.map +1 -0
- package/dist/{chunk-LDBCC67C.js → chunk-J6LYFSFJ.js} +24 -130
- package/dist/chunk-J6LYFSFJ.js.map +1 -0
- package/dist/chunk-VFLS65NL.js +51 -0
- package/dist/chunk-VFLS65NL.js.map +1 -0
- package/dist/components/SegmentEditorDialog.d.ts.map +1 -1
- package/dist/data/mock.d.ts.map +1 -1
- package/dist/data/supabase.d.ts.map +1 -1
- package/dist/data/types.d.ts +5 -1
- package/dist/data/types.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +154 -20
- package/dist/index.js.map +1 -1
- package/dist/lib/segments.d.ts +13 -6
- package/dist/lib/segments.d.ts.map +1 -1
- package/dist/locales/en.d.ts.map +1 -1
- package/dist/locales/pt-BR.d.ts.map +1 -1
- package/dist/migrations/index.d.ts +2 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/main.browser.js +3 -1
- package/dist/migrations/main.browser.js.map +1 -1
- package/dist/migrations/main.js +390 -2
- package/dist/migrations/main.js.map +1 -1
- package/dist/types.d.ts +20 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/views/DealListView.d.ts.map +1 -1
- package/dist/views/PipelineView.d.ts.map +1 -1
- package/dist/views/SegmentsView.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/CrmPage-ZOHVY2FA.js.map +0 -1
- package/dist/SegmentsView-PHLN2MOW.js +0 -385
- package/dist/SegmentsView-PHLN2MOW.js.map +0 -1
- package/dist/chunk-LDBCC67C.js.map +0 -1
- package/dist/chunk-QJOLAGGN.js +0 -129
- package/dist/chunk-QJOLAGGN.js.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AssigneeName, formatDocument, DEFAULT_ACTIVITY_TYPES, localPhoneKey, normalizeDocument, isValidDocument } from './chunk-J6LYFSFJ.js';
|
|
2
2
|
import { CrmGeneralSettings } from './chunk-CA24LK57.js';
|
|
3
|
-
import {
|
|
3
|
+
import { useCrmUnitFilter, UnitPicker } from './chunk-VFLS65NL.js';
|
|
4
|
+
import { loadTeamOrNull, loadMyUserId, DotChip, humanizeTag, TagChips, resolveSourceView } from './chunk-EHGAPCZF.js';
|
|
4
5
|
import { CrmContextProvider, useCrmProvider, useCrmStore, useCrmConfig, formatCurrency } from './chunk-7V46TYYX.js';
|
|
5
|
-
import
|
|
6
|
-
import React__default, { useCallback, useMemo, useState, useEffect, useRef } from 'react';
|
|
6
|
+
import React, { useCallback, useMemo, useState, useEffect, useRef } from 'react';
|
|
7
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
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
9
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
10
10
|
import { usePluginRuntimeOptional, useTranslation, currentAppPath, navigateApp, useActiveTenantId, exportCSV, getCurrentLocale, appHref, getSupabaseClientOptional, loadMessageOverrides, resolveMessages, useActiveUnitId } from '@fayz-ai/core';
|
|
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,
|
|
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
|
|
|
@@ -29,13 +29,13 @@ var KINDS = [
|
|
|
29
29
|
];
|
|
30
30
|
function GroupRow({ g, onOpen, open, members, roll, onEdit, onAdd, onRemove, onDelete, search }) {
|
|
31
31
|
const { currency } = useCrmConfig();
|
|
32
|
-
const [editing, setEditing] =
|
|
33
|
-
const [draftName, setDraftName] =
|
|
34
|
-
const [draftKind, setDraftKind] =
|
|
35
|
-
const [term, setTerm] =
|
|
36
|
-
const [hits, setHits] =
|
|
37
|
-
const [busy, setBusy] =
|
|
38
|
-
|
|
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(() => {
|
|
39
39
|
if (term.trim().length < 2) {
|
|
40
40
|
setHits([]);
|
|
41
41
|
return;
|
|
@@ -229,16 +229,16 @@ function GroupRow({ g, onOpen, open, members, roll, onEdit, onAdd, onRemove, onD
|
|
|
229
229
|
}
|
|
230
230
|
function CompanyGroupsView() {
|
|
231
231
|
const provider = useCrmProvider();
|
|
232
|
-
const [groups, setGroups] =
|
|
233
|
-
const [candidates, setCandidates] =
|
|
234
|
-
const [openId, setOpenId] =
|
|
235
|
-
const [members, setMembers] =
|
|
236
|
-
const [rollups, setRollups] =
|
|
237
|
-
const [names, setNames] =
|
|
238
|
-
const [busy, setBusy] =
|
|
239
|
-
const [novoAberto, setNovoAberto] =
|
|
240
|
-
const [novoNome, setNovoNome] =
|
|
241
|
-
const [criando, setCriando] =
|
|
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);
|
|
242
242
|
async function criarGrupo() {
|
|
243
243
|
const nome = novoNome.trim();
|
|
244
244
|
if (!nome || criando) return;
|
|
@@ -255,7 +255,7 @@ function CompanyGroupsView() {
|
|
|
255
255
|
setCriando(false);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
const load =
|
|
258
|
+
const load = React.useCallback(async () => {
|
|
259
259
|
try {
|
|
260
260
|
const [g, c, r] = await Promise.all([
|
|
261
261
|
provider.getCompanyGroups(),
|
|
@@ -270,7 +270,7 @@ function CompanyGroupsView() {
|
|
|
270
270
|
setGroups([]);
|
|
271
271
|
}
|
|
272
272
|
}, [provider]);
|
|
273
|
-
|
|
273
|
+
React.useEffect(() => {
|
|
274
274
|
void load();
|
|
275
275
|
}, [load]);
|
|
276
276
|
async function toggle(id) {
|
|
@@ -557,46 +557,6 @@ function LostReasonDialog({
|
|
|
557
557
|
] })
|
|
558
558
|
] }) });
|
|
559
559
|
}
|
|
560
|
-
function useCrmUnitFilter() {
|
|
561
|
-
return useUnitFilter({ scope: "global" });
|
|
562
|
-
}
|
|
563
|
-
var ROW = "gap-2 text-xs hover:bg-muted";
|
|
564
|
-
function UnitPicker({ filter: f }) {
|
|
565
|
-
const [open, setOpen] = React.useState(false);
|
|
566
|
-
if (!f.visible) return null;
|
|
567
|
-
const current = f.value ? f.options.find((u) => u.id === f.value)?.name ?? f.allLabel : f.allLabel;
|
|
568
|
-
const pick = (id) => {
|
|
569
|
-
f.setValue(id);
|
|
570
|
-
setOpen(false);
|
|
571
|
-
};
|
|
572
|
-
return /* @__PURE__ */ jsxs(Dropdown, { open, onOpenChange: setOpen, children: [
|
|
573
|
-
/* @__PURE__ */ jsx(DropdownTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
574
|
-
Button,
|
|
575
|
-
{
|
|
576
|
-
type: "button",
|
|
577
|
-
variant: "outline",
|
|
578
|
-
title: f.label,
|
|
579
|
-
className: "h-8 shrink-0 gap-1.5 rounded-full px-3 text-xs font-medium",
|
|
580
|
-
children: [
|
|
581
|
-
/* @__PURE__ */ jsx(Building2, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
582
|
-
/* @__PURE__ */ jsx("span", { className: "max-w-[10rem] truncate", children: current }),
|
|
583
|
-
/* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3 shrink-0 opacity-60" })
|
|
584
|
-
]
|
|
585
|
-
}
|
|
586
|
-
) }),
|
|
587
|
-
/* @__PURE__ */ jsxs(DropdownContent, { align: "end", className: "w-56 p-1", children: [
|
|
588
|
-
/* @__PURE__ */ jsxs(DropdownItem, { className: ROW, onSelect: () => pick(void 0), children: [
|
|
589
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: f.allLabel }),
|
|
590
|
-
!f.value && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
|
|
591
|
-
] }),
|
|
592
|
-
/* @__PURE__ */ jsx("div", { className: "my-1 border-t" }),
|
|
593
|
-
/* @__PURE__ */ jsx("div", { className: "max-h-64 overflow-y-auto", children: f.options.map((u) => /* @__PURE__ */ jsxs(DropdownItem, { className: ROW, onSelect: () => pick(u.id), children: [
|
|
594
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: u.name }),
|
|
595
|
-
f.value === u.id && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
|
|
596
|
-
] }, u.id)) })
|
|
597
|
-
] })
|
|
598
|
-
] });
|
|
599
|
-
}
|
|
600
560
|
function DisplayPopover({ config }) {
|
|
601
561
|
const t = useTranslation();
|
|
602
562
|
const [page, setPage] = useState("root");
|
|
@@ -1136,7 +1096,7 @@ function usePipelineAgentSurface(deps) {
|
|
|
1136
1096
|
}
|
|
1137
1097
|
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";
|
|
1138
1098
|
function BoardFilterChip({ trigger, onClear, clearLabel, closeOnSelect, children }) {
|
|
1139
|
-
const [open, setOpen] =
|
|
1099
|
+
const [open, setOpen] = React.useState(false);
|
|
1140
1100
|
return /* @__PURE__ */ jsxs(Dropdown, { open, onOpenChange: setOpen, children: [
|
|
1141
1101
|
/* @__PURE__ */ jsx(DropdownTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
1142
1102
|
Button,
|
|
@@ -1994,6 +1954,7 @@ function PipelineView({ onDealClick, onAddLead, onOpenSettings, onStageIntent })
|
|
|
1994
1954
|
{
|
|
1995
1955
|
layout: "scroll",
|
|
1996
1956
|
fitViewport: true,
|
|
1957
|
+
fitViewportOffset: "12.75rem",
|
|
1997
1958
|
columns: visibleStages.map((stage) => ({
|
|
1998
1959
|
id: stage.id,
|
|
1999
1960
|
label: stage.name,
|
|
@@ -2317,19 +2278,24 @@ function DealListView({ onOpenDeal }) {
|
|
|
2317
2278
|
[rows, page]
|
|
2318
2279
|
);
|
|
2319
2280
|
const capped = deals.length >= LOAD_CAP;
|
|
2281
|
+
const unitFilter = useCrmUnitFilter();
|
|
2320
2282
|
const segmentRules = useMemo(() => {
|
|
2321
2283
|
const out = [];
|
|
2322
|
-
|
|
2323
|
-
|
|
2284
|
+
const stageName = stage ? stages.find((s) => s.id === stage)?.name : void 0;
|
|
2285
|
+
if (stageName) out.push({ column: "stage_name", op: "in", value: [stageName] });
|
|
2286
|
+
if (outcome !== "all") out.push({ column: "deal_status", op: "in", value: [outcome] });
|
|
2287
|
+
if (unitFilter.value) out.push({ column: "unit_id", op: "in", value: [unitFilter.value] });
|
|
2288
|
+
if (owner === "none") out.push({ column: "owner_id", op: "is_null" });
|
|
2289
|
+
else if (owner) out.push({ column: "owner_id", op: "in", value: [owner] });
|
|
2290
|
+
if (tags.length) out.push({ column: "tags", op: "has_any_tag", value: tags });
|
|
2324
2291
|
return out;
|
|
2325
|
-
}, [
|
|
2292
|
+
}, [stage, stages, outcome, unitFilter.value, owner, tags]);
|
|
2326
2293
|
const droppedFilters = [
|
|
2327
|
-
stage && t("crm.dealSidebar.stage"),
|
|
2328
2294
|
status && t("crm.deals.colStatus"),
|
|
2329
2295
|
cohort && t("crm.deals.cohort"),
|
|
2330
|
-
companyName && t("crm.card.companyTitle")
|
|
2296
|
+
companyName && t("crm.card.companyTitle"),
|
|
2297
|
+
city && t("crm.deals.colCity")
|
|
2331
2298
|
].filter(Boolean);
|
|
2332
|
-
const unitFilter = useCrmUnitFilter();
|
|
2333
2299
|
const filtrosAtivos = (stage ? 1 : 0) + (status ? 1 : 0) + (cohort ? 1 : 0) + (outcome !== "open" ? 1 : 0) + (city ? 1 : 0) + (companyName ? 1 : 0) + (tags.length ? 1 : 0) + (owner ? 1 : 0);
|
|
2334
2300
|
const limparFiltros = () => {
|
|
2335
2301
|
setStage(void 0);
|
|
@@ -2609,7 +2575,7 @@ function DealListView({ onOpenDeal }) {
|
|
|
2609
2575
|
onClose: () => setSegmentOpen(false),
|
|
2610
2576
|
rules: segmentRules,
|
|
2611
2577
|
dropped: droppedFilters,
|
|
2612
|
-
suggestedName: [
|
|
2578
|
+
suggestedName: [stages.find((s) => s.id === stage)?.name, ...tags.map((x) => tagDefs.get(x)?.name ?? humanizeTag(x))].filter(Boolean).join(" \xB7 ")
|
|
2613
2579
|
}
|
|
2614
2580
|
)
|
|
2615
2581
|
] });
|
|
@@ -2629,7 +2595,7 @@ function SaveSegmentDialog({ open, onClose, rules, dropped, suggestedName }) {
|
|
|
2629
2595
|
await provider.saveSegment({
|
|
2630
2596
|
name: name.trim(),
|
|
2631
2597
|
rules: { where: rules },
|
|
2632
|
-
sourceView: resolveSourceView({ where: rules }),
|
|
2598
|
+
sourceView: resolveSourceView({ where: rules }, "deals"),
|
|
2633
2599
|
isActive: true
|
|
2634
2600
|
});
|
|
2635
2601
|
toast.success(t("crm.deals.segmentSaved"));
|
|
@@ -3570,7 +3536,7 @@ function formatDocument2(doc) {
|
|
|
3570
3536
|
return doc;
|
|
3571
3537
|
}
|
|
3572
3538
|
function CopyDocument({ document: doc, label: label2 }) {
|
|
3573
|
-
const [copied, setCopied] =
|
|
3539
|
+
const [copied, setCopied] = React.useState(false);
|
|
3574
3540
|
return /* @__PURE__ */ jsx(
|
|
3575
3541
|
Button,
|
|
3576
3542
|
{
|
|
@@ -4723,7 +4689,7 @@ function DealsView({ mode, onChangeMode, openDealId, onOpenDeal, onCloseDeal, on
|
|
|
4723
4689
|
const refreshBoard = useCrmStore((s) => s.refreshBoard);
|
|
4724
4690
|
const addLead = onAddLead ? (stageId) => setNovoLead({ stageId }) : void 0;
|
|
4725
4691
|
const dealsByStage = useCrmStore((s) => s.dealsByStage);
|
|
4726
|
-
const seedDeal =
|
|
4692
|
+
const seedDeal = React.useMemo(() => {
|
|
4727
4693
|
if (!openId) return null;
|
|
4728
4694
|
for (const lista of dealsByStage.values()) {
|
|
4729
4695
|
const d = lista.find((x) => x.id === openId);
|
|
@@ -6101,7 +6067,7 @@ function QuoteFormView({ quoteId, leadId, onSaved }) {
|
|
|
6101
6067
|
const config = useCrmConfig();
|
|
6102
6068
|
const provider = useCrmProvider();
|
|
6103
6069
|
const { currency, itemTypes: declaredItemTypes } = config;
|
|
6104
|
-
const translatedItemTypes =
|
|
6070
|
+
const translatedItemTypes = React.useMemo(
|
|
6105
6071
|
() => declaredItemTypes.map((tp) => {
|
|
6106
6072
|
const traduzido = t(`crm.itemType.${tp.value}`);
|
|
6107
6073
|
return traduzido === `crm.itemType.${tp.value}` ? tp : { ...tp, label: traduzido };
|
|
@@ -6176,7 +6142,7 @@ function QuoteFormView({ quoteId, leadId, onSaved }) {
|
|
|
6176
6142
|
setQuoteDate(iso);
|
|
6177
6143
|
if (validityDays !== null) setValidUntil(addDays(iso, validityDays));
|
|
6178
6144
|
}
|
|
6179
|
-
const openCustomOnMount =
|
|
6145
|
+
const openCustomOnMount = React.useRef(false);
|
|
6180
6146
|
function pickValidity(days) {
|
|
6181
6147
|
openCustomOnMount.current = days === null && validityDays !== null;
|
|
6182
6148
|
setValidityDays(days);
|
|
@@ -6253,7 +6219,7 @@ function QuoteFormView({ quoteId, leadId, onSaved }) {
|
|
|
6253
6219
|
observations,
|
|
6254
6220
|
items: items.map((it) => ({ itemKind: it.itemKind, description: it.description, quantity: it.quantity, unitPrice: it.unitPrice, discount: it.discount }))
|
|
6255
6221
|
};
|
|
6256
|
-
const snapshot =
|
|
6222
|
+
const snapshot = React.useRef(null);
|
|
6257
6223
|
useEffect(() => {
|
|
6258
6224
|
if (!loadingExisting && snapshot.current === null) snapshot.current = JSON.stringify(currentFields);
|
|
6259
6225
|
}, [loadingExisting]);
|
|
@@ -8054,8 +8020,8 @@ var INLINE_LINK = "text-xs font-normal text-primary hover:underline";
|
|
|
8054
8020
|
function CompanyGroupBadge({ companyId, onOpenCompany }) {
|
|
8055
8021
|
const provider = useCrmProvider();
|
|
8056
8022
|
const { currency } = useCrmConfig();
|
|
8057
|
-
const [data, setData] =
|
|
8058
|
-
|
|
8023
|
+
const [data, setData] = React.useState(null);
|
|
8024
|
+
React.useEffect(() => {
|
|
8059
8025
|
let alive = true;
|
|
8060
8026
|
provider.getGroupOfCompany(companyId).then((d) => {
|
|
8061
8027
|
if (alive) setData(d);
|
|
@@ -9061,10 +9027,10 @@ function NetworkView() {
|
|
|
9061
9027
|
const t = useTranslation();
|
|
9062
9028
|
const provider = useCrmProvider();
|
|
9063
9029
|
const { currency } = useCrmConfig();
|
|
9064
|
-
const [days, setDays] =
|
|
9065
|
-
const [rows, setRows] =
|
|
9066
|
-
const [weights, setWeights] =
|
|
9067
|
-
|
|
9030
|
+
const [days, setDays] = React.useState("90");
|
|
9031
|
+
const [rows, setRows] = React.useState(null);
|
|
9032
|
+
const [weights, setWeights] = React.useState({});
|
|
9033
|
+
React.useEffect(() => {
|
|
9068
9034
|
let alive = true;
|
|
9069
9035
|
const to = (/* @__PURE__ */ new Date()).toISOString();
|
|
9070
9036
|
const from = new Date(Date.now() - Number(days) * 864e5).toISOString();
|
|
@@ -9081,10 +9047,10 @@ function NetworkView() {
|
|
|
9081
9047
|
alive = false;
|
|
9082
9048
|
};
|
|
9083
9049
|
}, [provider, days]);
|
|
9084
|
-
const scored =
|
|
9050
|
+
const scored = React.useMemo(() => scoreUnits(rows ?? [], weights), [rows, weights]);
|
|
9085
9051
|
const avg = networkScore(scored);
|
|
9086
|
-
const ranked =
|
|
9087
|
-
const columns =
|
|
9052
|
+
const ranked = React.useMemo(() => [...scored].sort((a, b) => b.revenue - a.revenue), [scored]);
|
|
9053
|
+
const columns = React.useMemo(() => {
|
|
9088
9054
|
const NUM = { className: "text-right" };
|
|
9089
9055
|
return [
|
|
9090
9056
|
{
|
|
@@ -9282,11 +9248,11 @@ function SurveyScale({ type, value, onChange, readOnly, compact }) {
|
|
|
9282
9248
|
] });
|
|
9283
9249
|
}
|
|
9284
9250
|
function SurveyEditorDialog({ survey, provider, answeredQuestionIds, onClose, onSaved }) {
|
|
9285
|
-
const [name, setName] =
|
|
9286
|
-
const [isActive, setIsActive] =
|
|
9287
|
-
const [askOnCheckout, setAskOnCheckout] =
|
|
9288
|
-
const [thanks, setThanks] =
|
|
9289
|
-
const [questions, setQuestions] =
|
|
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(
|
|
9290
9256
|
(survey?.questions ?? []).map((q) => ({
|
|
9291
9257
|
id: q.id,
|
|
9292
9258
|
text: q.text,
|
|
@@ -9296,8 +9262,8 @@ function SurveyEditorDialog({ survey, provider, answeredQuestionIds, onClose, on
|
|
|
9296
9262
|
answered: answeredQuestionIds?.has(q.id)
|
|
9297
9263
|
}))
|
|
9298
9264
|
);
|
|
9299
|
-
const [saving, setSaving] =
|
|
9300
|
-
const [error, setError] =
|
|
9265
|
+
const [saving, setSaving] = React.useState(false);
|
|
9266
|
+
const [error, setError] = React.useState(null);
|
|
9301
9267
|
function patch(i, changes) {
|
|
9302
9268
|
setQuestions((qs) => qs.map((q, j) => j === i ? { ...q, ...changes } : q));
|
|
9303
9269
|
}
|
|
@@ -9482,13 +9448,13 @@ function SurveyEditorDialog({ survey, provider, answeredQuestionIds, onClose, on
|
|
|
9482
9448
|
}
|
|
9483
9449
|
function SurveyCollectDialog({ survey, provider, contactLookup, onClose, onSaved }) {
|
|
9484
9450
|
const unitId = useActiveUnitId();
|
|
9485
|
-
const [contact, setContact] =
|
|
9486
|
-
const [answers, setAnswers] =
|
|
9451
|
+
const [contact, setContact] = React.useState(null);
|
|
9452
|
+
const [answers, setAnswers] = React.useState(
|
|
9487
9453
|
Object.fromEntries(survey.questions.map((q) => [q.id, { rating: null, comment: "" }]))
|
|
9488
9454
|
);
|
|
9489
|
-
const [saving, setSaving] =
|
|
9490
|
-
const [done, setDone] =
|
|
9491
|
-
const [error, setError] =
|
|
9455
|
+
const [saving, setSaving] = React.useState(false);
|
|
9456
|
+
const [done, setDone] = React.useState(false);
|
|
9457
|
+
const [error, setError] = React.useState(null);
|
|
9492
9458
|
function patch(id, changes) {
|
|
9493
9459
|
setAnswers((a) => ({ ...a, [id]: { ...a[id], ...changes } }));
|
|
9494
9460
|
}
|
|
@@ -9586,8 +9552,8 @@ function ResponseSkeleton() {
|
|
|
9586
9552
|
] }, i)) });
|
|
9587
9553
|
}
|
|
9588
9554
|
function SurveyResponsesRail({ survey, provider, onClose }) {
|
|
9589
|
-
const [responses, setResponses] =
|
|
9590
|
-
|
|
9555
|
+
const [responses, setResponses] = React.useState(null);
|
|
9556
|
+
React.useEffect(() => {
|
|
9591
9557
|
let cancelled = false;
|
|
9592
9558
|
setResponses(null);
|
|
9593
9559
|
void provider.getSurveyResponses(survey.id).then((r) => {
|
|
@@ -9647,19 +9613,19 @@ function SurveysView() {
|
|
|
9647
9613
|
const can = usePermissionOptional();
|
|
9648
9614
|
const canEdit = can("sales", "edit");
|
|
9649
9615
|
const canDelete = can("sales", "delete");
|
|
9650
|
-
const [surveys, setSurveys] =
|
|
9651
|
-
const [stats, setStats] =
|
|
9652
|
-
const [editing, setEditing] =
|
|
9653
|
-
const [collecting, setCollecting] =
|
|
9654
|
-
const [viewing, setViewing] =
|
|
9655
|
-
const [removing, setRemoving] =
|
|
9656
|
-
const [answeredIds, setAnsweredIds] =
|
|
9657
|
-
const load =
|
|
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 () => {
|
|
9658
9624
|
const [list, st] = await Promise.all([provider.getSurveys(), provider.getSurveyStats()]);
|
|
9659
9625
|
setSurveys(list);
|
|
9660
9626
|
setStats(Object.fromEntries(st.map((s) => [s.surveyId, s])));
|
|
9661
9627
|
}, [provider]);
|
|
9662
|
-
|
|
9628
|
+
React.useEffect(() => {
|
|
9663
9629
|
void load();
|
|
9664
9630
|
}, [load]);
|
|
9665
9631
|
const askers = (surveys ?? []).filter((s) => s.isActive && s.askOnCheckout);
|
|
@@ -9939,12 +9905,12 @@ function DistributionView() {
|
|
|
9939
9905
|
const t = useTranslation();
|
|
9940
9906
|
const can = usePermissionOptional();
|
|
9941
9907
|
const canDistribute = can("sales", "edit");
|
|
9942
|
-
const [rota, setRota] =
|
|
9943
|
-
const [backlog, setBacklog] =
|
|
9944
|
-
const [offers, setOffers] =
|
|
9945
|
-
const [preview, setPreview] =
|
|
9946
|
-
const [busy, setBusy] =
|
|
9947
|
-
const load =
|
|
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 () => {
|
|
9948
9914
|
const [r, b, o] = await Promise.all([
|
|
9949
9915
|
provider.getRotaState().catch(() => null),
|
|
9950
9916
|
provider.getLeadBacklog(500).catch(() => []),
|
|
@@ -9954,7 +9920,7 @@ function DistributionView() {
|
|
|
9954
9920
|
setBacklog(b);
|
|
9955
9921
|
setOffers(o);
|
|
9956
9922
|
}, [provider]);
|
|
9957
|
-
|
|
9923
|
+
React.useEffect(() => {
|
|
9958
9924
|
void load();
|
|
9959
9925
|
}, [load]);
|
|
9960
9926
|
async function askPreview() {
|
|
@@ -9993,7 +9959,7 @@ function DistributionView() {
|
|
|
9993
9959
|
setBusy(false);
|
|
9994
9960
|
}
|
|
9995
9961
|
}
|
|
9996
|
-
const backlogColumns =
|
|
9962
|
+
const backlogColumns = React.useMemo(() => [
|
|
9997
9963
|
{
|
|
9998
9964
|
id: "lead",
|
|
9999
9965
|
header: () => /* @__PURE__ */ jsx("span", { className: "text-xs uppercase", children: t("crm.distribution.lead") }),
|
|
@@ -10080,11 +10046,11 @@ function DistributionView() {
|
|
|
10080
10046
|
}
|
|
10081
10047
|
function Countdown({ seconds }) {
|
|
10082
10048
|
const t = useTranslation();
|
|
10083
|
-
const [left, setLeft] =
|
|
10084
|
-
|
|
10049
|
+
const [left, setLeft] = React.useState(seconds);
|
|
10050
|
+
React.useEffect(() => {
|
|
10085
10051
|
setLeft(seconds);
|
|
10086
10052
|
}, [seconds]);
|
|
10087
|
-
|
|
10053
|
+
React.useEffect(() => {
|
|
10088
10054
|
if (left <= 0) return;
|
|
10089
10055
|
const id = setInterval(() => setLeft((s2) => Math.max(0, s2 - 1)), 1e3);
|
|
10090
10056
|
return () => clearInterval(id);
|
|
@@ -10100,16 +10066,16 @@ function Countdown({ seconds }) {
|
|
|
10100
10066
|
function MyOffersView() {
|
|
10101
10067
|
const provider = useCrmProvider();
|
|
10102
10068
|
const t = useTranslation();
|
|
10103
|
-
const [offers, setOffers] =
|
|
10104
|
-
const [busy, setBusy] =
|
|
10105
|
-
const load =
|
|
10069
|
+
const [offers, setOffers] = React.useState(null);
|
|
10070
|
+
const [busy, setBusy] = React.useState(null);
|
|
10071
|
+
const load = React.useCallback(async () => {
|
|
10106
10072
|
try {
|
|
10107
10073
|
setOffers(await provider.getLeadOffers({ mine: true }));
|
|
10108
10074
|
} catch {
|
|
10109
10075
|
setOffers([]);
|
|
10110
10076
|
}
|
|
10111
10077
|
}, [provider]);
|
|
10112
|
-
|
|
10078
|
+
React.useEffect(() => {
|
|
10113
10079
|
void load();
|
|
10114
10080
|
const id = setInterval(() => {
|
|
10115
10081
|
void load();
|
|
@@ -10462,5 +10428,5 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
10462
10428
|
}
|
|
10463
10429
|
|
|
10464
10430
|
export { CrmPage };
|
|
10465
|
-
//# sourceMappingURL=CrmPage-
|
|
10466
|
-
//# sourceMappingURL=CrmPage-
|
|
10431
|
+
//# sourceMappingURL=CrmPage-T2HQ67N2.js.map
|
|
10432
|
+
//# sourceMappingURL=CrmPage-T2HQ67N2.js.map
|