@fayz-ai/plugin-crm 0.31.0 → 0.31.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/LinkCompanyPrompt.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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +760 -305
- package/dist/index.js.map +1 -1
- package/dist/lib/team.d.ts +6 -2
- package/dist/lib/team.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/store.d.ts.map +1 -1
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/views/CrmPage.d.ts.map +1 -1
- package/dist/views/DealCardModal.d.ts.map +1 -1
- package/dist/views/DealsView.d.ts +10 -1
- package/dist/views/DealsView.d.ts.map +1 -1
- package/dist/views/GapScreens.d.ts +26 -0
- package/dist/views/GapScreens.d.ts.map +1 -0
- package/dist/views/LeadFormView.d.ts +8 -1
- package/dist/views/LeadFormView.d.ts.map +1 -1
- package/dist/views/PipelineView.d.ts +4 -5
- package/dist/views/PipelineView.d.ts.map +1 -1
- package/dist/views/QuoteListView.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react';
|
|
2
|
-
import { tl, useTranslation, getSupabaseClientOptional,
|
|
3
|
-
import { createPluginContext, useUnitBootstrap, useUnitStore, createCrudPage, PluginSettingsPanel, registerTimelineSource, dedup, useModuleNavigation, usePluginOnboardingGate, PluginOnboardingGateSkeleton, createViewRouter, ModuleActionBar, usePermissionOptional, PageActions, useTenantPluginSettings, SettingsGroup, ToggleRow, adminNavigateTo, usePersistedState, useScrollMemory, useLimitGuard, useCatalogedItemTypes, OrderFormSkeleton, OrderFormBlock, OrderFormView, OrderFormItemsCard, OrderFormItemRow, OrderFormAddItemStep, formatCurrency, useRecordVisit, OrderDetailSkeleton, OrderDetailBlock, OrderDetailView, PersonLink, RightRailPage, AskAIButton, KanbanBoard, invalidateLimit, useAccessOptional, useOrganizationStore, getRailPage, ContactPicker, useAgentSurface } from '@fayz-ai/admin';
|
|
4
|
-
import { Archive, FileX2, FileCheck2, Send, FilePlus2, XCircle, Trophy, PhoneCall, MoveRight, Target, ArrowRightLeft, UserPlus, MapPin, MessageCircle, CheckSquare, FileText, Users, Mail, Phone, ArrowUp, ArrowDown, X, Plus, Filter, Lock, Pencil, Trash2, Globe, Check, ChevronRight, Settings, Tag, Building2, CircleDot, User, Download, Inbox, Play, Clock, Sparkles, Calendar, ArrowRight, MoreHorizontal, ChevronDown, Printer, CircleCheckBig, Ban, Receipt, Package, CalendarClock, Loader2, Network, Fingerprint, Link2, Star, MessageSquareQuote, UserRound, CalendarDays,
|
|
5
|
-
import { Badge, Checkbox, toast, defineKpiWidget, defineChartWidget, defineCustomWidget, defineTableWidget, PageTransition, ModulePage,
|
|
2
|
+
import { tl, useTranslation, getSupabaseClientOptional, getActiveUnitId, RECORD_GROUP, recordRailFields, activeFacet, registerTranslations, registerMessageDefaults, createSafeDataProvider, getActiveTenantId, countByTenant, usePluginRuntimeOptional, useActiveTenantId, exportCSV, getCurrentLocale, loadMessageOverrides, resolveMessages, useActiveUnitId } from '@fayz-ai/core';
|
|
3
|
+
import { createPluginContext, useUnitBootstrap, useUnitStore, createCrudPage, PluginSettingsPanel, registerTimelineSource, dedup, useModuleNavigation, usePluginOnboardingGate, PluginOnboardingGateSkeleton, createViewRouter, ModuleActionBar, usePermissionOptional, PageActions, useTenantPluginSettings, SettingsGroup, ToggleRow, adminNavigateTo, usePersistedState, useScrollMemory, useLimitGuard, useCatalogedItemTypes, OrderFormSkeleton, OrderFormBlock, OrderFormView, OrderFormItemsCard, OrderFormItemRow, OrderFormAddItemStep, createArchetypeLookup, formatCurrency, useRecordVisit, OrderDetailSkeleton, OrderDetailBlock, OrderDetailView, PersonLink, RightRailPage, AskAIButton, KanbanBoard, invalidateLimit, useAccessOptional, useOrganizationStore, getRailPage, ContactPicker, useAgentSurface } from '@fayz-ai/admin';
|
|
4
|
+
import { Archive, FileX2, FileCheck2, Send, FilePlus2, XCircle, Trophy, PhoneCall, MoveRight, Target, ArrowRightLeft, UserPlus, MapPin, MessageCircle, CheckSquare, FileText, Users, Mail, Phone, ArrowUp, ArrowDown, X, Plus, Filter, Lock, Pencil, Trash2, Globe, Check, ChevronRight, Settings, Tag, Building2, CircleDot, User, Download, CircleDashed, Search, Inbox, Play, Clock, Sparkles, Calendar, ArrowRight, MoreHorizontal, ChevronDown, Printer, CircleCheckBig, Ban, Receipt, Package, CalendarClock, Loader2, Network, Fingerprint, Link2, Star, MessageSquareQuote, UserRound, CalendarDays, ThumbsDown, SignalHigh, CalendarRange, ChevronLeft, TrendingDown, UserCheck, AlertTriangle, Settings2, Repeat, Zap, Snowflake, Sun, Flame, Merge, Paperclip, ImageOff, CircleAlert, CheckCircle2, SlidersHorizontal, ExternalLink, Clipboard, DollarSign, ThumbsUp, UserRoundPlus } from 'lucide-react';
|
|
5
|
+
import { Badge, Checkbox, toast, defineKpiWidget, defineChartWidget, defineCustomWidget, defineTableWidget, PageTransition, ModulePage, SubpageHeader, Button, TooltipProvider, Tooltip, TooltipTrigger, TooltipContent, Switch, ConfirmDialog, useIsWide, PageHeaderActions, FilterChip, MultiSelect, FilterMenu, FilterMenuRow, PersonAvatar, ListView, Modal, ModalContent, ModalHeader, ModalTitle, ModalBody, Input, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, ModalFooter, useSaveBar, SearchSelect, DatePicker, FilterPanel, FilterPanelField, RequiredFilter, Card, DataTable, Dropdown, DropdownTrigger, DropdownContent, DropdownItem, PhoneLink, SheetBody, SheetFooter, ComingSoon, DashboardCanvas, ModalDescription, PageViewBar, PersonPicker, CurrencyInput, HeaderTabs, Popover, PopoverTrigger, PopoverContent, getLucideIcon, DictateButton, DropdownLabel, DropdownSeparator, normalizePhone, KpiCard, ChartWidget, CardHeader, CardTitle, CardContent, TableWidget } from '@fayz-ai/ui';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
7
|
import { createPortal } from 'react-dom';
|
|
8
8
|
import { createStore as createStore$1 } from 'zustand/vanilla';
|
|
@@ -1073,13 +1073,19 @@ function useBoardFilterValue(myUserId) {
|
|
|
1073
1073
|
owner: owner === "__me__" ? myUserId ?? void 0 : owner
|
|
1074
1074
|
});
|
|
1075
1075
|
}
|
|
1076
|
-
async function loadTeam() {
|
|
1076
|
+
async function loadTeam(opts) {
|
|
1077
1077
|
const supabase = getSupabaseClientOptional();
|
|
1078
1078
|
if (!supabase) return [];
|
|
1079
1079
|
const { data: memberships, error } = await supabase.from("v_authz_memberships").select("user_id, person_id").eq("active", true);
|
|
1080
1080
|
if (error) throw new Error(error.message);
|
|
1081
|
-
|
|
1081
|
+
let rows = memberships ?? [];
|
|
1082
1082
|
if (rows.length === 0) return [];
|
|
1083
|
+
const unitId = opts?.unitId ?? getActiveUnitId();
|
|
1084
|
+
if (unitId) {
|
|
1085
|
+
const { data: reach } = await supabase.from("v_authz_user_unit_access").select("user_id").eq("unit_id", unitId);
|
|
1086
|
+
const allowed = new Set((reach ?? []).map((r) => r.user_id));
|
|
1087
|
+
if (allowed.size > 0) rows = rows.filter((r) => allowed.has(r.user_id));
|
|
1088
|
+
}
|
|
1083
1089
|
const { data: people } = await supabase.from("people").select("id, name").in("id", rows.map((r) => r.person_id));
|
|
1084
1090
|
const nameById = new Map(
|
|
1085
1091
|
(people ?? []).map((p) => [p.id, p.name ?? ""])
|
|
@@ -1091,9 +1097,9 @@ async function loadTeam() {
|
|
|
1091
1097
|
}
|
|
1092
1098
|
return [...porUsuario.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
1093
1099
|
}
|
|
1094
|
-
async function loadTeamOrNull() {
|
|
1100
|
+
async function loadTeamOrNull(opts) {
|
|
1095
1101
|
try {
|
|
1096
|
-
return await loadTeam();
|
|
1102
|
+
return await loadTeam(opts);
|
|
1097
1103
|
} catch {
|
|
1098
1104
|
return null;
|
|
1099
1105
|
}
|
|
@@ -1818,7 +1824,7 @@ function StageCards({ stageId, deals, total, onLoadMore, loadMoreLabel, savingDe
|
|
|
1818
1824
|
)
|
|
1819
1825
|
] });
|
|
1820
1826
|
}
|
|
1821
|
-
function PipelineView({ onDealClick, onAddLead, onOpenSettings, onStageIntent
|
|
1827
|
+
function PipelineView({ onDealClick, onAddLead, onOpenSettings, onStageIntent }) {
|
|
1822
1828
|
const { currency } = useCrmConfig();
|
|
1823
1829
|
const pipelines = useCrmStore((s) => s.pipelines);
|
|
1824
1830
|
const activePipelineId = useCrmStore((s) => s.activePipelineId);
|
|
@@ -2113,196 +2119,193 @@ function PipelineView({ onDealClick, onAddLead, onOpenSettings, onStageIntent, m
|
|
|
2113
2119
|
setMenu({ x: e.clientX, y: e.clientY, deal, mode });
|
|
2114
2120
|
}
|
|
2115
2121
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
2116
|
-
/* @__PURE__ */
|
|
2117
|
-
/* @__PURE__ */
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
t2("crm.leads.filters.mine"),
|
|
2134
|
-
effectiveOwner === myUserId && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
|
|
2135
|
-
] }),
|
|
2136
|
-
/* @__PURE__ */ jsxs("button", { className: CHIP_ROW, onClick: () => setOwnerFilter("none"), children: [
|
|
2137
|
-
/* @__PURE__ */ jsx(UserRound, { className: "h-3 w-3 text-muted-foreground" }),
|
|
2138
|
-
" ",
|
|
2139
|
-
t2("crm.leads.filters.unassigned"),
|
|
2140
|
-
effectiveOwner === "none" && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
|
|
2141
|
-
] }),
|
|
2142
|
-
(team ?? []).filter((m) => m.userId !== myUserId).map((m) => /* @__PURE__ */ jsxs("button", { className: CHIP_ROW, onClick: () => setOwnerFilter(m.userId), children: [
|
|
2143
|
-
/* @__PURE__ */ jsx(PersonAvatar, { name: m.name, size: "xs" }),
|
|
2144
|
-
" ",
|
|
2145
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: m.name }),
|
|
2146
|
-
effectiveOwner === m.userId && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
|
|
2147
|
-
] }, m.userId))
|
|
2148
|
-
]
|
|
2149
|
-
}
|
|
2150
|
-
),
|
|
2151
|
-
period !== "all" && /* @__PURE__ */ jsx(
|
|
2152
|
-
BoardFilterChip,
|
|
2153
|
-
{
|
|
2154
|
-
closeOnSelect: true,
|
|
2155
|
-
clearLabel: t2("crm.board.clearFilters"),
|
|
2156
|
-
onClear: () => setPeriod("all"),
|
|
2157
|
-
trigger: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2158
|
-
/* @__PURE__ */ jsx(CalendarDays, { className: "h-3 w-3" }),
|
|
2159
|
-
t2(`crm.filters.period${period === "custom" ? "Custom" : period}`)
|
|
2160
|
-
] }),
|
|
2161
|
-
children: ["24h", "7d", "custom"].map((p) => /* @__PURE__ */ jsxs("button", { className: CHIP_ROW, onClick: () => setPeriod(p), children: [
|
|
2162
|
-
t2(`crm.filters.period${p === "custom" ? "Custom" : p}`),
|
|
2163
|
-
period === p && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
|
|
2164
|
-
] }, p))
|
|
2165
|
-
}
|
|
2166
|
-
),
|
|
2167
|
-
selectedTags.length > 0 && /* @__PURE__ */ jsx(
|
|
2168
|
-
BoardFilterChip,
|
|
2169
|
-
{
|
|
2170
|
-
clearLabel: t2("crm.board.clearFilters"),
|
|
2171
|
-
onClear: () => setSelectedTags([]),
|
|
2172
|
-
trigger: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2173
|
-
/* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full", style: { backgroundColor: tagDefs.get(selectedTags[0])?.color ?? "#94A3B8" } }),
|
|
2174
|
-
/* @__PURE__ */ jsxs("span", { className: "max-w-[8rem] truncate", children: [
|
|
2175
|
-
tagDefs.get(selectedTags[0])?.name ?? humanizeTag(selectedTags[0]),
|
|
2176
|
-
selectedTags.length > 1 ? ` +${selectedTags.length - 1}` : ""
|
|
2177
|
-
] })
|
|
2122
|
+
/* @__PURE__ */ jsx(PageViewBar, { children: /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [
|
|
2123
|
+
effectiveOwner && /* @__PURE__ */ jsxs(
|
|
2124
|
+
BoardFilterChip,
|
|
2125
|
+
{
|
|
2126
|
+
closeOnSelect: true,
|
|
2127
|
+
clearLabel: t2("crm.board.clearFilters"),
|
|
2128
|
+
onClear: () => setOwnerFilter(void 0),
|
|
2129
|
+
trigger: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2130
|
+
effectiveOwner === "none" ? /* @__PURE__ */ jsx(UserRound, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(PersonAvatar, { name: (team ?? []).find((m) => m.userId === effectiveOwner)?.name ?? "Eu", size: "xs" }),
|
|
2131
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[8rem] truncate", children: effectiveOwner === "none" ? t2("crm.leads.filters.unassigned") : effectiveOwner === myUserId ? t2("crm.leads.filters.mine") : (team ?? []).find((m) => m.userId === effectiveOwner)?.name ?? t2("crm.leads.filters.owner") })
|
|
2132
|
+
] }),
|
|
2133
|
+
children: [
|
|
2134
|
+
myUserId && /* @__PURE__ */ jsxs("button", { className: CHIP_ROW, onClick: () => setOwnerFilter("__me__"), children: [
|
|
2135
|
+
/* @__PURE__ */ jsx(PersonAvatar, { name: (team ?? []).find((m) => m.userId === myUserId)?.name ?? "Eu", size: "xs" }),
|
|
2136
|
+
" ",
|
|
2137
|
+
t2("crm.leads.filters.mine"),
|
|
2138
|
+
effectiveOwner === myUserId && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
|
|
2178
2139
|
] }),
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
className: CHIP_ROW,
|
|
2185
|
-
onClick: () => setSelectedTags(on ? selectedTags.filter((s) => s !== slug) : [...selectedTags, slug]),
|
|
2186
|
-
children: [
|
|
2187
|
-
/* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full", style: { backgroundColor: tagDefs.get(slug)?.color ?? "#94A3B8" } }),
|
|
2188
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: tagDefs.get(slug)?.name ?? humanizeTag(slug) }),
|
|
2189
|
-
on && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
|
|
2190
|
-
]
|
|
2191
|
-
},
|
|
2192
|
-
slug
|
|
2193
|
-
);
|
|
2194
|
-
})
|
|
2195
|
-
}
|
|
2196
|
-
),
|
|
2197
|
-
/* @__PURE__ */ jsx(
|
|
2198
|
-
FilterMenu,
|
|
2199
|
-
{
|
|
2200
|
-
label: t2("crm.board.filters"),
|
|
2201
|
-
activeCount: (period !== "all" ? 1 : 0) + (selectedTags.length ? 1 : 0) + (search.trim() ? 1 : 0) + (effectiveOwner ? 1 : 0),
|
|
2202
|
-
onClear: () => {
|
|
2203
|
-
setSearch("");
|
|
2204
|
-
setPeriod("all");
|
|
2205
|
-
setSelectedTags([]);
|
|
2206
|
-
setOwnerFilter(void 0);
|
|
2207
|
-
},
|
|
2208
|
-
clearLabel: t2("crm.board.clearFilters"),
|
|
2209
|
-
header: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
2210
|
-
/* @__PURE__ */ jsx(Search, { className: "pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
|
|
2211
|
-
/* @__PURE__ */ jsx(
|
|
2212
|
-
"input",
|
|
2213
|
-
{
|
|
2214
|
-
type: "text",
|
|
2215
|
-
value: search,
|
|
2216
|
-
onChange: (e) => setSearch(e.target.value),
|
|
2217
|
-
placeholder: t2("crm.deals.searchPlaceholder"),
|
|
2218
|
-
className: "h-8 w-full rounded-input border bg-background pl-8 pr-3 text-xs outline-none placeholder:text-muted-foreground/70 focus:ring-2 focus:ring-ring"
|
|
2219
|
-
}
|
|
2220
|
-
)
|
|
2140
|
+
/* @__PURE__ */ jsxs("button", { className: CHIP_ROW, onClick: () => setOwnerFilter("none"), children: [
|
|
2141
|
+
/* @__PURE__ */ jsx(UserRound, { className: "h-3 w-3 text-muted-foreground" }),
|
|
2142
|
+
" ",
|
|
2143
|
+
t2("crm.leads.filters.unassigned"),
|
|
2144
|
+
effectiveOwner === "none" && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
|
|
2221
2145
|
] }),
|
|
2222
|
-
|
|
2223
|
-
{
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2146
|
+
(team ?? []).filter((m) => m.userId !== myUserId).map((m) => /* @__PURE__ */ jsxs("button", { className: CHIP_ROW, onClick: () => setOwnerFilter(m.userId), children: [
|
|
2147
|
+
/* @__PURE__ */ jsx(PersonAvatar, { name: m.name, size: "xs" }),
|
|
2148
|
+
" ",
|
|
2149
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: m.name }),
|
|
2150
|
+
effectiveOwner === m.userId && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
|
|
2151
|
+
] }, m.userId))
|
|
2152
|
+
]
|
|
2153
|
+
}
|
|
2154
|
+
),
|
|
2155
|
+
period !== "all" && /* @__PURE__ */ jsx(
|
|
2156
|
+
BoardFilterChip,
|
|
2157
|
+
{
|
|
2158
|
+
closeOnSelect: true,
|
|
2159
|
+
clearLabel: t2("crm.board.clearFilters"),
|
|
2160
|
+
onClear: () => setPeriod("all"),
|
|
2161
|
+
trigger: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2162
|
+
/* @__PURE__ */ jsx(CalendarDays, { className: "h-3 w-3" }),
|
|
2163
|
+
t2(`crm.filters.period${period === "custom" ? "Custom" : period}`)
|
|
2164
|
+
] }),
|
|
2165
|
+
children: ["24h", "7d", "custom"].map((p) => /* @__PURE__ */ jsxs("button", { className: CHIP_ROW, onClick: () => setPeriod(p), children: [
|
|
2166
|
+
t2(`crm.filters.period${p === "custom" ? "Custom" : p}`),
|
|
2167
|
+
period === p && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
|
|
2168
|
+
] }, p))
|
|
2169
|
+
}
|
|
2170
|
+
),
|
|
2171
|
+
selectedTags.length > 0 && /* @__PURE__ */ jsx(
|
|
2172
|
+
BoardFilterChip,
|
|
2173
|
+
{
|
|
2174
|
+
clearLabel: t2("crm.board.clearFilters"),
|
|
2175
|
+
onClear: () => setSelectedTags([]),
|
|
2176
|
+
trigger: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2177
|
+
/* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full", style: { backgroundColor: tagDefs.get(selectedTags[0])?.color ?? "#94A3B8" } }),
|
|
2178
|
+
/* @__PURE__ */ jsxs("span", { className: "max-w-[8rem] truncate", children: [
|
|
2179
|
+
tagDefs.get(selectedTags[0])?.name ?? humanizeTag(selectedTags[0]),
|
|
2180
|
+
selectedTags.length > 1 ? ` +${selectedTags.length - 1}` : ""
|
|
2181
|
+
] })
|
|
2182
|
+
] }),
|
|
2183
|
+
children: [.../* @__PURE__ */ new Set([...availableTags, ...selectedTags])].sort((a, b) => (tagDefs.get(a)?.name ?? humanizeTag(a)).localeCompare(tagDefs.get(b)?.name ?? humanizeTag(b))).map((slug) => {
|
|
2184
|
+
const on = selectedTags.includes(slug);
|
|
2185
|
+
return /* @__PURE__ */ jsxs(
|
|
2186
|
+
"button",
|
|
2262
2187
|
{
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
if (p !== "custom") close();
|
|
2271
|
-
}, children: t2(`crm.filters.period${p === "all" ? "All" : p === "custom" ? "Custom" : p}`) }, p)),
|
|
2272
|
-
period === "custom" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 p-1.5", children: [
|
|
2273
|
-
/* @__PURE__ */ jsx(DatePicker, { variant: "chip", format: "numeric", className: "w-full", value: customFrom, onChange: setCustomFrom }),
|
|
2274
|
-
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2013" }),
|
|
2275
|
-
/* @__PURE__ */ jsx(DatePicker, { variant: "chip", format: "numeric", className: "w-full", value: customTo, onChange: setCustomTo })
|
|
2276
|
-
] })
|
|
2277
|
-
] })
|
|
2188
|
+
className: CHIP_ROW,
|
|
2189
|
+
onClick: () => setSelectedTags(on ? selectedTags.filter((s) => s !== slug) : [...selectedTags, slug]),
|
|
2190
|
+
children: [
|
|
2191
|
+
/* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full", style: { backgroundColor: tagDefs.get(slug)?.color ?? "#94A3B8" } }),
|
|
2192
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: tagDefs.get(slug)?.name ?? humanizeTag(slug) }),
|
|
2193
|
+
on && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
|
|
2194
|
+
]
|
|
2278
2195
|
},
|
|
2196
|
+
slug
|
|
2197
|
+
);
|
|
2198
|
+
})
|
|
2199
|
+
}
|
|
2200
|
+
),
|
|
2201
|
+
/* @__PURE__ */ jsx(
|
|
2202
|
+
FilterMenu,
|
|
2203
|
+
{
|
|
2204
|
+
label: t2("crm.board.filters"),
|
|
2205
|
+
activeCount: (period !== "all" ? 1 : 0) + (selectedTags.length ? 1 : 0) + (search.trim() ? 1 : 0) + (effectiveOwner ? 1 : 0),
|
|
2206
|
+
onClear: () => {
|
|
2207
|
+
setSearch("");
|
|
2208
|
+
setPeriod("all");
|
|
2209
|
+
setSelectedTags([]);
|
|
2210
|
+
setOwnerFilter(void 0);
|
|
2211
|
+
},
|
|
2212
|
+
clearLabel: t2("crm.board.clearFilters"),
|
|
2213
|
+
header: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
2214
|
+
/* @__PURE__ */ jsx(Search, { className: "pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
|
|
2215
|
+
/* @__PURE__ */ jsx(
|
|
2216
|
+
"input",
|
|
2279
2217
|
{
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
const on = selectedTags.includes(slug);
|
|
2286
|
-
return /* @__PURE__ */ jsxs(
|
|
2287
|
-
FilterMenuRow,
|
|
2288
|
-
{
|
|
2289
|
-
active: on,
|
|
2290
|
-
onClick: () => setSelectedTags(on ? selectedTags.filter((s) => s !== slug) : [...selectedTags, slug]),
|
|
2291
|
-
children: [
|
|
2292
|
-
/* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full", style: { backgroundColor: tagDefs.get(slug)?.color ?? "#94A3B8" } }),
|
|
2293
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: tagDefs.get(slug)?.name ?? humanizeTag(slug) })
|
|
2294
|
-
]
|
|
2295
|
-
},
|
|
2296
|
-
slug
|
|
2297
|
-
);
|
|
2298
|
-
}) })
|
|
2218
|
+
type: "text",
|
|
2219
|
+
value: search,
|
|
2220
|
+
onChange: (e) => setSearch(e.target.value),
|
|
2221
|
+
placeholder: t2("crm.deals.searchPlaceholder"),
|
|
2222
|
+
className: "h-8 w-full rounded-input border bg-background pl-8 pr-3 text-xs outline-none placeholder:text-muted-foreground/70 focus:ring-2 focus:ring-ring"
|
|
2299
2223
|
}
|
|
2300
|
-
|
|
2301
|
-
}
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2224
|
+
)
|
|
2225
|
+
] }),
|
|
2226
|
+
fields: [
|
|
2227
|
+
{
|
|
2228
|
+
id: "owner",
|
|
2229
|
+
label: t2("crm.leads.filters.owner"),
|
|
2230
|
+
icon: UserRound,
|
|
2231
|
+
activeCount: effectiveOwner ? 1 : 0,
|
|
2232
|
+
searchable: true,
|
|
2233
|
+
render: (close, q) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2234
|
+
/* @__PURE__ */ jsxs(FilterMenuRow, { active: !effectiveOwner, onClick: () => {
|
|
2235
|
+
setOwnerFilter(void 0);
|
|
2236
|
+
close();
|
|
2237
|
+
}, children: [
|
|
2238
|
+
/* @__PURE__ */ jsx(UserRound, { className: "h-3.5 w-3.5 text-muted-foreground" }),
|
|
2239
|
+
" ",
|
|
2240
|
+
t2("crm.leads.filters.allOwners")
|
|
2241
|
+
] }),
|
|
2242
|
+
myUserId && /* @__PURE__ */ jsxs(FilterMenuRow, { active: effectiveOwner === myUserId, onClick: () => {
|
|
2243
|
+
setOwnerFilter("__me__");
|
|
2244
|
+
close();
|
|
2245
|
+
}, children: [
|
|
2246
|
+
/* @__PURE__ */ jsx(PersonAvatar, { name: (team ?? []).find((m) => m.userId === myUserId)?.name ?? "Eu", size: "xs" }),
|
|
2247
|
+
" ",
|
|
2248
|
+
t2("crm.leads.filters.mine")
|
|
2249
|
+
] }),
|
|
2250
|
+
/* @__PURE__ */ jsxs(FilterMenuRow, { active: effectiveOwner === "none", onClick: () => {
|
|
2251
|
+
setOwnerFilter("none");
|
|
2252
|
+
close();
|
|
2253
|
+
}, children: [
|
|
2254
|
+
/* @__PURE__ */ jsx("span", { className: "flex h-5 w-5 items-center justify-center rounded-full border border-dashed border-muted-foreground/50", children: /* @__PURE__ */ jsx(UserRound, { className: "h-2.5 w-2.5 text-muted-foreground" }) }),
|
|
2255
|
+
t2("crm.leads.filters.unassigned")
|
|
2256
|
+
] }),
|
|
2257
|
+
(team ?? []).filter((m) => m.userId !== myUserId && m.name.toLowerCase().includes(q.toLowerCase())).map((m) => /* @__PURE__ */ jsxs(FilterMenuRow, { active: effectiveOwner === m.userId, onClick: () => {
|
|
2258
|
+
setOwnerFilter(m.userId);
|
|
2259
|
+
close();
|
|
2260
|
+
}, children: [
|
|
2261
|
+
/* @__PURE__ */ jsx(PersonAvatar, { name: m.name, size: "xs" }),
|
|
2262
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: m.name })
|
|
2263
|
+
] }, m.userId))
|
|
2264
|
+
] })
|
|
2265
|
+
},
|
|
2266
|
+
{
|
|
2267
|
+
id: "period",
|
|
2268
|
+
label: t2("crm.filters.period"),
|
|
2269
|
+
icon: CalendarDays,
|
|
2270
|
+
activeCount: period !== "all" ? 1 : 0,
|
|
2271
|
+
render: (close) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2272
|
+
["all", "24h", "7d", "custom"].map((p) => /* @__PURE__ */ jsx(FilterMenuRow, { active: period === p, onClick: () => {
|
|
2273
|
+
setPeriod(p);
|
|
2274
|
+
if (p !== "custom") close();
|
|
2275
|
+
}, children: t2(`crm.filters.period${p === "all" ? "All" : p === "custom" ? "Custom" : p}`) }, p)),
|
|
2276
|
+
period === "custom" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 p-1.5", children: [
|
|
2277
|
+
/* @__PURE__ */ jsx(DatePicker, { variant: "chip", format: "numeric", className: "w-full", value: customFrom, onChange: setCustomFrom }),
|
|
2278
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2013" }),
|
|
2279
|
+
/* @__PURE__ */ jsx(DatePicker, { variant: "chip", format: "numeric", className: "w-full", value: customTo, onChange: setCustomTo })
|
|
2280
|
+
] })
|
|
2281
|
+
] })
|
|
2282
|
+
},
|
|
2283
|
+
{
|
|
2284
|
+
id: "tags",
|
|
2285
|
+
label: t2("crm.leads.filters.tag"),
|
|
2286
|
+
icon: Tag,
|
|
2287
|
+
activeCount: selectedTags.length,
|
|
2288
|
+
render: () => /* @__PURE__ */ jsx(Fragment, { children: [.../* @__PURE__ */ new Set([...availableTags, ...selectedTags])].sort((a, b) => (tagDefs.get(a)?.name ?? humanizeTag(a)).localeCompare(tagDefs.get(b)?.name ?? humanizeTag(b))).map((slug) => {
|
|
2289
|
+
const on = selectedTags.includes(slug);
|
|
2290
|
+
return /* @__PURE__ */ jsxs(
|
|
2291
|
+
FilterMenuRow,
|
|
2292
|
+
{
|
|
2293
|
+
active: on,
|
|
2294
|
+
onClick: () => setSelectedTags(on ? selectedTags.filter((s) => s !== slug) : [...selectedTags, slug]),
|
|
2295
|
+
children: [
|
|
2296
|
+
/* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full", style: { backgroundColor: tagDefs.get(slug)?.color ?? "#94A3B8" } }),
|
|
2297
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: tagDefs.get(slug)?.name ?? humanizeTag(slug) })
|
|
2298
|
+
]
|
|
2299
|
+
},
|
|
2300
|
+
slug
|
|
2301
|
+
);
|
|
2302
|
+
}) })
|
|
2303
|
+
}
|
|
2304
|
+
]
|
|
2305
|
+
}
|
|
2306
|
+
),
|
|
2307
|
+
/* @__PURE__ */ jsx(DisplayPopover, { display, onChange: setDisplay })
|
|
2308
|
+
] }) }),
|
|
2306
2309
|
boardPending ? /* @__PURE__ */ jsx(PipelineSkeleton, {}) : visibleStages.length === 0 ? (
|
|
2307
2310
|
/* Sem etapas não existe quadro: o `flex` abaixo renderizava uma faixa
|
|
2308
2311
|
em branco, que parece uma tela que não carregou. O funil é a única
|
|
@@ -2330,19 +2333,19 @@ function PipelineView({ onDealClick, onAddLead, onOpenSettings, onStageIntent, m
|
|
|
2330
2333
|
})),
|
|
2331
2334
|
count: (col) => query ? (displayBoard.get(col.id) ?? []).length : dealStageTotals.get(col.id) ?? (displayBoard.get(col.id) ?? []).length,
|
|
2332
2335
|
isOver: (col) => dragOverStageId === col.id,
|
|
2333
|
-
columnAction: onAddLead ? () => /* @__PURE__ */ jsx(
|
|
2336
|
+
columnAction: onAddLead ? (col) => /* @__PURE__ */ jsx(
|
|
2334
2337
|
"button",
|
|
2335
2338
|
{
|
|
2336
2339
|
onClick: (e) => {
|
|
2337
2340
|
e.stopPropagation();
|
|
2338
|
-
onAddLead();
|
|
2341
|
+
onAddLead(col.id);
|
|
2339
2342
|
},
|
|
2340
2343
|
title: t2("crm.pipeline.addLead"),
|
|
2341
2344
|
className: "flex h-5 w-5 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
2342
2345
|
children: /* @__PURE__ */ jsx(Plus, { className: "h-3.5 w-3.5" })
|
|
2343
2346
|
}
|
|
2344
2347
|
) : void 0,
|
|
2345
|
-
onAddCard: onAddLead ? () => onAddLead() : void 0,
|
|
2348
|
+
onAddCard: onAddLead ? (col) => onAddLead(col.id) : void 0,
|
|
2346
2349
|
addCardLabel: t2("crm.pipeline.addLead"),
|
|
2347
2350
|
dropProps: (col) => ({
|
|
2348
2351
|
onDragOver: (e) => handleDragOver(col.id, e),
|
|
@@ -4364,7 +4367,7 @@ function buildCrmRegistries(activityTypes) {
|
|
|
4364
4367
|
function LinkCompanyPrompt({ personId, companyText, onLinked }) {
|
|
4365
4368
|
const t2 = useTranslation();
|
|
4366
4369
|
const provider = useCrmProvider();
|
|
4367
|
-
const
|
|
4370
|
+
const refreshCompanies = useCrmStore((s) => s.refreshCompanies);
|
|
4368
4371
|
const [existente, setExistente] = useState(null);
|
|
4369
4372
|
const [ligando, setLigando] = useState(false);
|
|
4370
4373
|
const nome = companyText?.trim();
|
|
@@ -4390,8 +4393,9 @@ function LinkCompanyPrompt({ personId, companyText, onLinked }) {
|
|
|
4390
4393
|
if (!nome || ligando) return;
|
|
4391
4394
|
setLigando(true);
|
|
4392
4395
|
try {
|
|
4393
|
-
const companyId = existente?.id ?? (await saveCompany({ name: nome })).id;
|
|
4396
|
+
const companyId = existente?.id ?? (await provider.saveCompany({ name: nome })).id;
|
|
4394
4397
|
await provider.linkCompanyPerson({ companyId, personId, isPrimary: true });
|
|
4398
|
+
void refreshCompanies();
|
|
4395
4399
|
toast.success(t2("crm.linkCompany.done", { name: nome }));
|
|
4396
4400
|
onLinked?.(companyId);
|
|
4397
4401
|
} catch (err) {
|
|
@@ -4771,6 +4775,9 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
4771
4775
|
setLoading(false);
|
|
4772
4776
|
return;
|
|
4773
4777
|
}
|
|
4778
|
+
void loadTeamOrNull({ unitId: d.unitId }).then((team2) => {
|
|
4779
|
+
if (!cancelled) setTeam(team2);
|
|
4780
|
+
});
|
|
4774
4781
|
if (d.pipelineId) {
|
|
4775
4782
|
void provider.getPipelineStages(d.pipelineId).then((s) => {
|
|
4776
4783
|
if (!cancelled) setStages(s);
|
|
@@ -4821,9 +4828,6 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
4821
4828
|
void provider.getQuotesByDealId(dealId).then((q) => {
|
|
4822
4829
|
if (!cancelled) setQuotes(q);
|
|
4823
4830
|
});
|
|
4824
|
-
void loadTeamOrNull().then((t3) => {
|
|
4825
|
-
if (!cancelled) setTeam(t3);
|
|
4826
|
-
});
|
|
4827
4831
|
void loadMyUserId().then((u) => {
|
|
4828
4832
|
if (!cancelled) setMyUserId(u);
|
|
4829
4833
|
});
|
|
@@ -5322,7 +5326,11 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
5322
5326
|
{
|
|
5323
5327
|
personId: pessoaDoCard.id,
|
|
5324
5328
|
companyText: pessoaDoCard.company ?? draft.company,
|
|
5325
|
-
onLinked: () => {
|
|
5329
|
+
onLinked: (companyId) => {
|
|
5330
|
+
void provider.getCompanyById(companyId).then((c) => {
|
|
5331
|
+
if (c) setCompany(c);
|
|
5332
|
+
});
|
|
5333
|
+
void provider.getCompanyGroupPeople(companyId).catch(() => []).then((gente) => setPessoasDaCasa(gente));
|
|
5326
5334
|
void provider.getLiveDealById(dealId).then((d) => d && setDeal(d));
|
|
5327
5335
|
}
|
|
5328
5336
|
}
|
|
@@ -5414,8 +5422,9 @@ function instagramUrl(handle) {
|
|
|
5414
5422
|
if (!h || !/^[A-Za-z0-9._]{1,30}$/.test(h)) return void 0;
|
|
5415
5423
|
return `https://instagram.com/${h}`;
|
|
5416
5424
|
}
|
|
5417
|
-
function LeadFormView({ onSaved }) {
|
|
5425
|
+
function LeadFormView({ onSaved, initialStageId, initialPipelineId }) {
|
|
5418
5426
|
const t2 = useTranslation();
|
|
5427
|
+
const provider = useCrmProvider();
|
|
5419
5428
|
const createLead = useCrmStore((s) => s.createLead);
|
|
5420
5429
|
const guardLeads = useLimitGuard("leads");
|
|
5421
5430
|
const resolveEntryPipeline = useCrmStore((s) => s.resolveEntryPipeline);
|
|
@@ -5433,19 +5442,24 @@ function LeadFormView({ onSaved }) {
|
|
|
5433
5442
|
void fetchLeadSources();
|
|
5434
5443
|
}, []);
|
|
5435
5444
|
const [stages, setStages] = useState([]);
|
|
5436
|
-
const [stageId, setStageId] = useState("");
|
|
5445
|
+
const [stageId, setStageId] = useState(initialStageId ?? "");
|
|
5437
5446
|
useEffect(() => {
|
|
5438
5447
|
let cancelled = false;
|
|
5439
|
-
|
|
5448
|
+
const carrega = initialPipelineId ? provider.getPipelineStages(initialPipelineId).then((entry) => ({ stages: entry })) : resolveEntryPipeline();
|
|
5449
|
+
void carrega.then(({ stages: entry }) => {
|
|
5440
5450
|
if (cancelled) return;
|
|
5441
5451
|
const open = entry.filter((s) => !s.isWon && !s.isLost).sort((a, b) => a.order - b.order);
|
|
5442
5452
|
setStages(open);
|
|
5443
|
-
setStageId((current) =>
|
|
5453
|
+
setStageId((current) => {
|
|
5454
|
+
if (current && open.some((s) => s.id === current)) return current;
|
|
5455
|
+
if (initialStageId && open.some((s) => s.id === initialStageId)) return initialStageId;
|
|
5456
|
+
return open[0]?.id || "";
|
|
5457
|
+
});
|
|
5444
5458
|
});
|
|
5445
5459
|
return () => {
|
|
5446
5460
|
cancelled = true;
|
|
5447
5461
|
};
|
|
5448
|
-
}, []);
|
|
5462
|
+
}, [initialPipelineId, initialStageId]);
|
|
5449
5463
|
async function handleSave() {
|
|
5450
5464
|
if (!name.trim()) {
|
|
5451
5465
|
toast.error(t2("common.formIncomplete"));
|
|
@@ -5466,7 +5480,8 @@ function LeadFormView({ onSaved }) {
|
|
|
5466
5480
|
notes: notes || void 0,
|
|
5467
5481
|
sourceId: source?.id,
|
|
5468
5482
|
sourceName: source?.name,
|
|
5469
|
-
stageId: stageId || void 0
|
|
5483
|
+
stageId: stageId || void 0,
|
|
5484
|
+
pipelineId: initialPipelineId
|
|
5470
5485
|
});
|
|
5471
5486
|
invalidateLimit("leads");
|
|
5472
5487
|
invalidateLimit("deals");
|
|
@@ -5557,11 +5572,11 @@ function readMode() {
|
|
|
5557
5572
|
}
|
|
5558
5573
|
return "board";
|
|
5559
5574
|
}
|
|
5560
|
-
function DealsView({ openDealId, onOpenDeal, onCloseDeal, onViewLead, onViewQuote, onViewCompany, onCreateQuote, onAddLead, onOpenSettings }) {
|
|
5575
|
+
function DealsView({ mode, onChangeMode, openDealId, onOpenDeal, onCloseDeal, onViewLead, onViewQuote, onViewCompany, onCreateQuote, onAddLead, onOpenSettings }) {
|
|
5561
5576
|
const t2 = useTranslation();
|
|
5562
5577
|
const provider = useCrmProvider();
|
|
5563
5578
|
const isWide = useIsWide();
|
|
5564
|
-
const
|
|
5579
|
+
const modo = mode ?? readMode();
|
|
5565
5580
|
const pipelines = useCrmStore((s) => s.pipelines);
|
|
5566
5581
|
const [openId, setOpenId] = useState(openDealId ?? null);
|
|
5567
5582
|
useEffect(() => {
|
|
@@ -5582,9 +5597,9 @@ function DealsView({ openDealId, onOpenDeal, onCloseDeal, onViewLead, onViewQuot
|
|
|
5582
5597
|
}
|
|
5583
5598
|
};
|
|
5584
5599
|
const [pendingStage, setPendingStage] = useState(null);
|
|
5585
|
-
const [novoLead, setNovoLead] = useState(
|
|
5600
|
+
const [novoLead, setNovoLead] = useState(null);
|
|
5586
5601
|
const refreshBoard = useCrmStore((s) => s.refreshBoard);
|
|
5587
|
-
const addLead = onAddLead ? () => setNovoLead(
|
|
5602
|
+
const addLead = onAddLead ? (stageId) => setNovoLead({ stageId }) : void 0;
|
|
5588
5603
|
const dealsByStage = useCrmStore((s) => s.dealsByStage);
|
|
5589
5604
|
const seedDeal = React.useMemo(() => {
|
|
5590
5605
|
if (!openId) return null;
|
|
@@ -5603,23 +5618,10 @@ function DealsView({ openDealId, onOpenDeal, onCloseDeal, onViewLead, onViewQuot
|
|
|
5603
5618
|
const selectPipeline = useCrmStore((s) => s.selectPipeline);
|
|
5604
5619
|
useEffect(() => {
|
|
5605
5620
|
try {
|
|
5606
|
-
localStorage.setItem(STORAGE_KEY,
|
|
5621
|
+
localStorage.setItem(STORAGE_KEY, modo);
|
|
5607
5622
|
} catch {
|
|
5608
5623
|
}
|
|
5609
|
-
}, [
|
|
5610
|
-
const modeControl = /* @__PURE__ */ jsx(
|
|
5611
|
-
ViewTabs,
|
|
5612
|
-
{
|
|
5613
|
-
value: mode,
|
|
5614
|
-
onChange: setMode,
|
|
5615
|
-
"aria-label": t2("crm.deals.switchView"),
|
|
5616
|
-
options: [
|
|
5617
|
-
{ value: "board", label: t2("crm.deals.viewBoard") },
|
|
5618
|
-
{ value: "list", label: t2("crm.deals.viewList") },
|
|
5619
|
-
{ value: "funnel", label: t2("crm.deals.viewFunnel") }
|
|
5620
|
-
]
|
|
5621
|
-
}
|
|
5622
|
-
);
|
|
5624
|
+
}, [modo]);
|
|
5623
5625
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
5624
5626
|
!isWide && /* @__PURE__ */ jsx(PageHeaderActions, { children: /* @__PURE__ */ jsx(
|
|
5625
5627
|
PageActions,
|
|
@@ -5631,7 +5633,7 @@ function DealsView({ openDealId, onOpenDeal, onCloseDeal, onViewLead, onViewQuot
|
|
|
5631
5633
|
icon: Plus,
|
|
5632
5634
|
intent: "primary",
|
|
5633
5635
|
creates: true,
|
|
5634
|
-
onSelect: addLead ?? onAddLead
|
|
5636
|
+
onSelect: () => (addLead ?? onAddLead)?.()
|
|
5635
5637
|
}] : [],
|
|
5636
5638
|
...onOpenSettings ? [{
|
|
5637
5639
|
id: "pipeline-stages",
|
|
@@ -5660,7 +5662,7 @@ function DealsView({ openDealId, onOpenDeal, onCloseDeal, onViewLead, onViewQuot
|
|
|
5660
5662
|
p.id
|
|
5661
5663
|
);
|
|
5662
5664
|
}) }),
|
|
5663
|
-
|
|
5665
|
+
modo === "board" && /* @__PURE__ */ jsx(
|
|
5664
5666
|
PipelineView,
|
|
5665
5667
|
{
|
|
5666
5668
|
onDealClick: openCard,
|
|
@@ -5669,44 +5671,38 @@ function DealsView({ openDealId, onOpenDeal, onCloseDeal, onViewLead, onViewQuot
|
|
|
5669
5671
|
onStageIntent: (deal, stage) => {
|
|
5670
5672
|
setPendingStage(stage);
|
|
5671
5673
|
openCard(deal.id);
|
|
5672
|
-
}
|
|
5673
|
-
modeControl
|
|
5674
|
+
}
|
|
5674
5675
|
}
|
|
5675
5676
|
),
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
/* @__PURE__ */ jsxs(PageViewBar, { children: [
|
|
5685
|
-
/* @__PURE__ */ jsx("div", { className: "min-w-0", children: modeControl }),
|
|
5686
|
-
/* @__PURE__ */ jsx("span", {})
|
|
5687
|
-
] }),
|
|
5688
|
-
/* @__PURE__ */ jsx(
|
|
5689
|
-
DealFunnelView,
|
|
5690
|
-
{
|
|
5691
|
-
onStageClick: (stageId) => {
|
|
5692
|
-
try {
|
|
5693
|
-
sessionStorage.setItem("fayz.list.crm.deals.stage", JSON.stringify(stageId));
|
|
5694
|
-
} catch {
|
|
5695
|
-
}
|
|
5696
|
-
setMode("list");
|
|
5677
|
+
modo === "list" && /* @__PURE__ */ jsx(DealListView, { onOpenDeal: openCard }),
|
|
5678
|
+
modo === "funnel" && /* @__PURE__ */ jsx(
|
|
5679
|
+
DealFunnelView,
|
|
5680
|
+
{
|
|
5681
|
+
onStageClick: (stageId) => {
|
|
5682
|
+
try {
|
|
5683
|
+
sessionStorage.setItem("fayz.list.crm.deals.stage", JSON.stringify(stageId));
|
|
5684
|
+
} catch {
|
|
5697
5685
|
}
|
|
5686
|
+
onChangeMode?.("list");
|
|
5698
5687
|
}
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
novoLead && /* @__PURE__ */ jsx(
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5688
|
+
}
|
|
5689
|
+
),
|
|
5690
|
+
novoLead && /* @__PURE__ */ jsx(
|
|
5691
|
+
LeadFormView,
|
|
5692
|
+
{
|
|
5693
|
+
initialStageId: novoLead.stageId,
|
|
5694
|
+
initialPipelineId: novoLead.stageId ? activePipelineId ?? void 0 : void 0,
|
|
5695
|
+
onSaved: (id) => {
|
|
5696
|
+
setNovoLead(null);
|
|
5697
|
+
if (!id) return;
|
|
5698
|
+
void refreshBoard();
|
|
5699
|
+
void provider.getPipelineCardForLead(id).then((d) => {
|
|
5700
|
+
if (d) openCard(d.id);
|
|
5701
|
+
}).catch(() => {
|
|
5702
|
+
});
|
|
5703
|
+
}
|
|
5704
|
+
}
|
|
5705
|
+
),
|
|
5710
5706
|
/* @__PURE__ */ jsx(
|
|
5711
5707
|
DealCardModal,
|
|
5712
5708
|
{
|
|
@@ -5730,6 +5726,189 @@ function DealsView({ openDealId, onOpenDeal, onCloseDeal, onViewLead, onViewQuot
|
|
|
5730
5726
|
)
|
|
5731
5727
|
] });
|
|
5732
5728
|
}
|
|
5729
|
+
function UnitGoalsView() {
|
|
5730
|
+
return /* @__PURE__ */ jsx(
|
|
5731
|
+
ComingSoon,
|
|
5732
|
+
{
|
|
5733
|
+
title: "Metas das unidades",
|
|
5734
|
+
summary: "Quanto cada unidade precisa vender no m\xEAs, e quanto j\xE1 vendeu. \xC9 a r\xE9gua contra a qual o resto do m\xF3dulo \xE9 lido.",
|
|
5735
|
+
v1Path: "CRM \u2192 Metas \u2192 Metas das Unidades",
|
|
5736
|
+
measured: "11 metas de unidade no V1 inteiro, nenhuma da Artorius.",
|
|
5737
|
+
missing: [
|
|
5738
|
+
"A meta por unidade e por m\xEAs, com o realizado ao lado",
|
|
5739
|
+
"O Financeiro j\xE1 tem uma tela de Metas (desligada no aplicativo central) \u2014 decidir se s\xE3o a mesma coisa antes de construir duas"
|
|
5740
|
+
]
|
|
5741
|
+
}
|
|
5742
|
+
);
|
|
5743
|
+
}
|
|
5744
|
+
function KpiGoalsView() {
|
|
5745
|
+
return /* @__PURE__ */ jsx(
|
|
5746
|
+
ComingSoon,
|
|
5747
|
+
{
|
|
5748
|
+
title: "Metas por indicador",
|
|
5749
|
+
summary: "A meta que n\xE3o \xE9 de faturamento: ticket m\xE9dio, taxa de retorno, n\xFAmero de atendimentos.",
|
|
5750
|
+
v1Path: "CRM \u2192 Metas \u2192 Metas por Indicador",
|
|
5751
|
+
measured: "ZERO no V1 inteiro (`unit_kpi_goals` vazia). A tela existe l\xE1 e nunca foi usada \u2014 antes de construir, confirmar que algu\xE9m quer.",
|
|
5752
|
+
missing: [
|
|
5753
|
+
"O cat\xE1logo de indicadores, que \xE9 a parte dif\xEDcil: cada um tem uma conta pr\xF3pria",
|
|
5754
|
+
"Sem isso, a tela \xE9 um formul\xE1rio para um n\xFAmero que ningu\xE9m compara com nada"
|
|
5755
|
+
]
|
|
5756
|
+
}
|
|
5757
|
+
);
|
|
5758
|
+
}
|
|
5759
|
+
function ProfessionalGoalsView() {
|
|
5760
|
+
return /* @__PURE__ */ jsx(
|
|
5761
|
+
ComingSoon,
|
|
5762
|
+
{
|
|
5763
|
+
title: "Metas por profissional",
|
|
5764
|
+
summary: "Quanto cada pessoa da equipe precisa vender \u2014 e o que ela j\xE1 vendeu no per\xEDodo.",
|
|
5765
|
+
v1Path: "CRM \u2192 Metas \u2192 Metas Profissionais",
|
|
5766
|
+
measured: "4 metas no V1 inteiro, nenhuma da Artorius.",
|
|
5767
|
+
missing: [
|
|
5768
|
+
"A meta por pessoa e per\xEDodo, lendo o realizado das vendas",
|
|
5769
|
+
"Liga-se \xE0 comiss\xE3o: quem bate meta costuma ter regra diferente"
|
|
5770
|
+
]
|
|
5771
|
+
}
|
|
5772
|
+
);
|
|
5773
|
+
}
|
|
5774
|
+
function FranchisorGoalsView() {
|
|
5775
|
+
return /* @__PURE__ */ jsx(
|
|
5776
|
+
ComingSoon,
|
|
5777
|
+
{
|
|
5778
|
+
title: "Metas do franqueador",
|
|
5779
|
+
summary: "A meta que a rede define para as unidades, vista de cima: quem bateu, quem n\xE3o bateu, e o consolidado.",
|
|
5780
|
+
v1Path: "CRM \u2192 Metas \u2192 Metas do Franqueador",
|
|
5781
|
+
measured: "1 meta em todo o V1. \xC9 tela de rede, e a Artorius \xE9 uma casa s\xF3.",
|
|
5782
|
+
missing: [
|
|
5783
|
+
"S\xF3 faz sentido com o escopo de rede resolvido \u2014 a unidade \xE9 o alcance que a RLS usa",
|
|
5784
|
+
"Depende de Metas das unidades existir primeiro"
|
|
5785
|
+
]
|
|
5786
|
+
}
|
|
5787
|
+
);
|
|
5788
|
+
}
|
|
5789
|
+
function TasksView() {
|
|
5790
|
+
return /* @__PURE__ */ jsx(
|
|
5791
|
+
ComingSoon,
|
|
5792
|
+
{
|
|
5793
|
+
title: "Tarefas",
|
|
5794
|
+
summary: "O que algu\xE9m combinou de fazer com um lead: ligar na quinta, mandar a proposta, passar na loja. Com dono, prazo e o que aconteceu.",
|
|
5795
|
+
v1Path: "CRM \u2192 Engajamento \u2192 Tarefas",
|
|
5796
|
+
measured: "1 tarefa em todo o V1. A tela existe l\xE1 e praticamente n\xE3o foi usada.",
|
|
5797
|
+
missing: [
|
|
5798
|
+
"A tarefa ligada ao lead ou ao neg\xF3cio, n\xE3o solta \u2014 \xE9 isso que a torna \xFAtil",
|
|
5799
|
+
"Atividades (que j\xE1 existe aqui) REGISTRA o que aconteceu; a tarefa \xE9 o que ainda vai acontecer",
|
|
5800
|
+
"O atraso tem de aparecer sozinho, sen\xE3o a lista vira arquivo"
|
|
5801
|
+
]
|
|
5802
|
+
}
|
|
5803
|
+
);
|
|
5804
|
+
}
|
|
5805
|
+
function FollowUpsView() {
|
|
5806
|
+
return /* @__PURE__ */ jsx(
|
|
5807
|
+
ComingSoon,
|
|
5808
|
+
{
|
|
5809
|
+
title: "Follow-ups",
|
|
5810
|
+
summary: "Os retornos combinados que est\xE3o vencendo: quem prometeu voltar a falar com quem, e quando.",
|
|
5811
|
+
v1Path: "CRM \u2192 Engajamento \u2192 Follow-ups",
|
|
5812
|
+
measured: "Vista de leitura no V1 \u2014 recorta as mesmas tarefas por data. Sem tarefa, n\xE3o h\xE1 follow-up.",
|
|
5813
|
+
missing: [
|
|
5814
|
+
"Depende de Tarefas existir: \xE9 o mesmo dado visto pela data",
|
|
5815
|
+
"A pergunta aqui \xE9 \xABo que eu devia ter feito e n\xE3o fiz\xBB, e ela se responde com um recorte, n\xE3o com uma tabela nova"
|
|
5816
|
+
]
|
|
5817
|
+
}
|
|
5818
|
+
);
|
|
5819
|
+
}
|
|
5820
|
+
function LoyaltyView() {
|
|
5821
|
+
return /* @__PURE__ */ jsx(
|
|
5822
|
+
ComingSoon,
|
|
5823
|
+
{
|
|
5824
|
+
title: "Clube de fidelidade",
|
|
5825
|
+
summary: "As regras do clube \u2014 quanto vale cada real gasto, o que o ponto compra, quando expira \u2014 e quem est\xE1 dentro.",
|
|
5826
|
+
v1Path: "CRM \u2192 Fideliza\xE7\xE3o \u2192 Programa de Fidelidade",
|
|
5827
|
+
measured: "1 programa cadastrado no V1 e ZERO membros (`loyalty_members` vazia). O clube existe no papel e n\xE3o tem s\xF3cio.",
|
|
5828
|
+
missing: [
|
|
5829
|
+
"As regras de ac\xFAmulo e de resgate, que \xE9 onde o programa vira ou n\xE3o vira dinheiro",
|
|
5830
|
+
"O saldo por cliente e o extrato dele \u2014 sem extrato, ningu\xE9m confia no saldo",
|
|
5831
|
+
"Antes de construir: 1 programa e 0 membros diz que a vers\xE3o do V1 n\xE3o convenceu ningu\xE9m"
|
|
5832
|
+
]
|
|
5833
|
+
}
|
|
5834
|
+
);
|
|
5835
|
+
}
|
|
5836
|
+
function ReferralsView() {
|
|
5837
|
+
return /* @__PURE__ */ jsx(
|
|
5838
|
+
ComingSoon,
|
|
5839
|
+
{
|
|
5840
|
+
title: "Indica\xE7\xF5es",
|
|
5841
|
+
summary: "Quem trouxe quem \u2014 e o que o indicador ganha por isso.",
|
|
5842
|
+
v1Path: "CRM \u2192 Fideliza\xE7\xE3o \u2192 Indica\xE7\xF5es",
|
|
5843
|
+
measured: "No V1 a indica\xE7\xE3o \xE9 um campo na ficha do cliente, n\xE3o um m\xF3dulo: n\xE3o h\xE1 tabela pr\xF3pria nem recompensa autom\xE1tica.",
|
|
5844
|
+
missing: [
|
|
5845
|
+
"Registrar a indica\xE7\xE3o no cadastro \xE9 f\xE1cil; PAGAR por ela \xE9 o que falta",
|
|
5846
|
+
"A recompensa liga isto ao Financeiro (cr\xE9dito) ou ao clube (pontos) \u2014 decidir qual antes"
|
|
5847
|
+
]
|
|
5848
|
+
}
|
|
5849
|
+
);
|
|
5850
|
+
}
|
|
5851
|
+
function BirthdaysView() {
|
|
5852
|
+
return /* @__PURE__ */ jsx(
|
|
5853
|
+
ComingSoon,
|
|
5854
|
+
{
|
|
5855
|
+
title: "Aniversariantes",
|
|
5856
|
+
summary: "Quem faz anivers\xE1rio nos pr\xF3ximos dias, para a casa fazer alguma coisa a respeito.",
|
|
5857
|
+
v1Path: "CRM \u2192 Fideliza\xE7\xE3o \u2192 Aniversariantes",
|
|
5858
|
+
measured: "Vista de leitura no V1 \u2014 recorta a data de nascimento da ficha do cliente. O dado j\xE1 atravessou para c\xE1.",
|
|
5859
|
+
missing: [
|
|
5860
|
+
"\xC9 um recorte da base de clientes, n\xE3o um cadastro novo \u2014 a tela mais barata desta lista",
|
|
5861
|
+
"O valor est\xE1 em disparar a mensagem a partir dela; sozinha \xE9 uma lista que algu\xE9m tem de lembrar de abrir",
|
|
5862
|
+
"Com o Marketing ao lado no mesmo menu, virar campanha recorrente \xE9 o caminho natural"
|
|
5863
|
+
]
|
|
5864
|
+
}
|
|
5865
|
+
);
|
|
5866
|
+
}
|
|
5867
|
+
function PendingReturnsView() {
|
|
5868
|
+
return /* @__PURE__ */ jsx(
|
|
5869
|
+
ComingSoon,
|
|
5870
|
+
{
|
|
5871
|
+
title: "Retornos pendentes",
|
|
5872
|
+
summary: "O cliente que costumava vir e parou: quem est\xE1 atrasado em rela\xE7\xE3o ao pr\xF3prio h\xE1bito.",
|
|
5873
|
+
v1Path: "CRM \u2192 Retornos Pendentes",
|
|
5874
|
+
measured: "Vista de leitura no V1 \u2014 calcula o intervalo entre atendimentos e marca quem passou dele. A Artorius n\xE3o atende, ent\xE3o l\xE1 ela \xE9 vazia.",
|
|
5875
|
+
missing: [
|
|
5876
|
+
"O c\xE1lculo do intervalo esperado POR CLIENTE \u2014 a m\xE9dia da casa acusa todo mundo ou ningu\xE9m",
|
|
5877
|
+
"\xC9 a tela que mais gera receita desta lista numa casa de servi\xE7o, e a que menos serve numa de compras"
|
|
5878
|
+
]
|
|
5879
|
+
}
|
|
5880
|
+
);
|
|
5881
|
+
}
|
|
5882
|
+
function OperationalDashboardView() {
|
|
5883
|
+
return /* @__PURE__ */ jsx(
|
|
5884
|
+
ComingSoon,
|
|
5885
|
+
{
|
|
5886
|
+
title: "Painel operacional",
|
|
5887
|
+
summary: "O dia da opera\xE7\xE3o num quadro: agenda ocupada, atendimentos, ticket, o que est\xE1 atrasado.",
|
|
5888
|
+
v1Path: "CRM \u2192 Dashboard Operacional",
|
|
5889
|
+
measured: "Vista de leitura no V1, montada sobre agendamentos e faturas. Sem venda pelo sistema n\xE3o tem o que mostrar.",
|
|
5890
|
+
missing: [
|
|
5891
|
+
"Definir os cinco n\xFAmeros que importam antes de desenhar \u2014 um painel com vinte cart\xF5es n\xE3o \xE9 lido",
|
|
5892
|
+
"O Resumo do CRM j\xE1 responde parte disto; decidir se s\xE3o duas telas ou uma"
|
|
5893
|
+
]
|
|
5894
|
+
}
|
|
5895
|
+
);
|
|
5896
|
+
}
|
|
5897
|
+
function MaturityView() {
|
|
5898
|
+
return /* @__PURE__ */ jsx(
|
|
5899
|
+
ComingSoon,
|
|
5900
|
+
{
|
|
5901
|
+
title: "Maturidade operacional",
|
|
5902
|
+
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.",
|
|
5903
|
+
v1Path: "CRM \u2192 Maturidade Operacional",
|
|
5904
|
+
measured: "Vista de leitura no V1 \u2014 pontua a conta contra uma lista de checagens.",
|
|
5905
|
+
missing: [
|
|
5906
|
+
"A lista de checagens \xE9 a tela: sem ela combinada, a nota n\xE3o quer dizer nada",
|
|
5907
|
+
"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"
|
|
5908
|
+
]
|
|
5909
|
+
}
|
|
5910
|
+
);
|
|
5911
|
+
}
|
|
5733
5912
|
var LEAD_STATUS_OPTIONS = [
|
|
5734
5913
|
{ value: "new", labelKey: "crm.leads.statusNew", dot: "#3B82F6" },
|
|
5735
5914
|
{ value: "contacted", labelKey: "crm.leads.statusContacted", dot: "#8B5CF6" },
|
|
@@ -6498,6 +6677,7 @@ function LeadListView({ onNew, onEdit }) {
|
|
|
6498
6677
|
)
|
|
6499
6678
|
] });
|
|
6500
6679
|
}
|
|
6680
|
+
var QUOTE_STATUSES = ["draft", "sent", "approved", "rejected", "expired", "archived"];
|
|
6501
6681
|
var STATUS_COLORS = {
|
|
6502
6682
|
draft: "bg-muted text-muted-foreground",
|
|
6503
6683
|
sent: "bg-info-soft text-info-soft-foreground",
|
|
@@ -6526,7 +6706,7 @@ function useQuoteColumns(currency, onEditQuote, onArchive) {
|
|
|
6526
6706
|
header: t2("crm.quotes.status"),
|
|
6527
6707
|
cell: ({ getValue }) => {
|
|
6528
6708
|
const status = getValue();
|
|
6529
|
-
return /* @__PURE__ */ jsx("span", { className: `inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium
|
|
6709
|
+
return /* @__PURE__ */ jsx("span", { className: `inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium ${STATUS_COLORS[status] ?? "bg-muted text-muted-foreground"}`, children: t2(`crm.quotes.status.${status}`) });
|
|
6530
6710
|
}
|
|
6531
6711
|
}
|
|
6532
6712
|
];
|
|
@@ -6576,9 +6756,50 @@ function QuoteListView({ onNew, onEdit, onEditQuote }) {
|
|
|
6576
6756
|
const fetchQuotes = useCrmStore((s) => s.fetchQuotes);
|
|
6577
6757
|
const archiveQuote = useCrmStore((s) => s.archiveQuote);
|
|
6578
6758
|
const canArchive = useCanArchive();
|
|
6579
|
-
|
|
6580
|
-
|
|
6759
|
+
const hoje = () => {
|
|
6760
|
+
const d = /* @__PURE__ */ new Date();
|
|
6761
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
6762
|
+
};
|
|
6763
|
+
const noventaDiasAtras = useMemo(() => {
|
|
6764
|
+
const d = /* @__PURE__ */ new Date();
|
|
6765
|
+
d.setDate(d.getDate() - 89);
|
|
6766
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
6581
6767
|
}, []);
|
|
6768
|
+
const [dateFrom, setDateFrom] = useState(noventaDiasAtras);
|
|
6769
|
+
const [dateTo, setDateTo] = useState(hoje);
|
|
6770
|
+
const [statusFilter, setStatusFilter] = useState([]);
|
|
6771
|
+
const [contactId, setContactId] = useState("");
|
|
6772
|
+
const [contactName, setContactName] = useState("");
|
|
6773
|
+
const [search, setSearch] = useState("");
|
|
6774
|
+
const contactLookup = useMemo(
|
|
6775
|
+
() => createArchetypeLookup({ archetype: "person", kind: ["customer", "lead"] }),
|
|
6776
|
+
[]
|
|
6777
|
+
);
|
|
6778
|
+
const rascunho = useMemo(
|
|
6779
|
+
() => ({ from: dateFrom, to: dateTo, status: statusFilter, contactId, search: search.trim() }),
|
|
6780
|
+
[dateFrom, dateTo, statusFilter, contactId, search]
|
|
6781
|
+
);
|
|
6782
|
+
const [emVigor, setEmVigor] = useState(rascunho);
|
|
6783
|
+
const filtrosPendentes = useMemo(
|
|
6784
|
+
() => JSON.stringify(rascunho) !== JSON.stringify(emVigor),
|
|
6785
|
+
[rascunho, emVigor]
|
|
6786
|
+
);
|
|
6787
|
+
const aplicarFiltros = useCallback(() => setEmVigor(() => rascunho), [rascunho]);
|
|
6788
|
+
const limparFiltros = () => {
|
|
6789
|
+
setStatusFilter([]);
|
|
6790
|
+
setContactId("");
|
|
6791
|
+
setContactName("");
|
|
6792
|
+
setSearch("");
|
|
6793
|
+
};
|
|
6794
|
+
const filtrosAtivos = (statusFilter.length > 0 ? 1 : 0) + (contactId ? 1 : 0) + (search.trim() ? 1 : 0);
|
|
6795
|
+
useEffect(() => {
|
|
6796
|
+
fetchQuotes({
|
|
6797
|
+
dateRange: { from: emVigor.from, to: emVigor.to },
|
|
6798
|
+
status: emVigor.status.length > 0 ? emVigor.status : void 0,
|
|
6799
|
+
contactId: emVigor.contactId || void 0,
|
|
6800
|
+
search: emVigor.search || void 0
|
|
6801
|
+
});
|
|
6802
|
+
}, [emVigor]);
|
|
6582
6803
|
const [alvoArquivo, setAlvoArquivo] = useState(null);
|
|
6583
6804
|
const columns = useQuoteColumns(currency, onEditQuote, canArchive ? setAlvoArquivo : void 0);
|
|
6584
6805
|
const exportRows = useCallback(() => {
|
|
@@ -6615,6 +6836,89 @@ function QuoteListView({ onNew, onEdit, onEditQuote }) {
|
|
|
6615
6836
|
) })
|
|
6616
6837
|
}
|
|
6617
6838
|
),
|
|
6839
|
+
/* @__PURE__ */ jsxs(
|
|
6840
|
+
FilterPanel,
|
|
6841
|
+
{
|
|
6842
|
+
title: t2("crm.quotes.filtersTitle"),
|
|
6843
|
+
dirty: filtrosPendentes,
|
|
6844
|
+
onApply: aplicarFiltros,
|
|
6845
|
+
applyLabel: t2("crm.quotes.filterApply"),
|
|
6846
|
+
pendingTitle: t2("crm.quotes.filterPending"),
|
|
6847
|
+
pendingHint: t2("crm.quotes.filterPendingHint"),
|
|
6848
|
+
onClear: filtrosAtivos > 0 ? limparFiltros : void 0,
|
|
6849
|
+
clearLabel: t2("crm.quotes.filterClear"),
|
|
6850
|
+
busy: quotesLoading,
|
|
6851
|
+
children: [
|
|
6852
|
+
/* @__PURE__ */ jsx(FilterPanelField, { label: t2("crm.quotes.filterFrom"), children: /* @__PURE__ */ jsx(DatePicker, { variant: "input", format: "numeric", className: "w-full", value: dateFrom, onChange: (v) => v && setDateFrom(v) }) }),
|
|
6853
|
+
/* @__PURE__ */ jsx(FilterPanelField, { label: t2("crm.quotes.filterTo"), children: /* @__PURE__ */ jsx(DatePicker, { variant: "input", format: "numeric", className: "w-full", value: dateTo, onChange: (v) => v && setDateTo(v) }) }),
|
|
6854
|
+
/* @__PURE__ */ jsx(FilterPanelField, { label: t2("crm.quotes.status"), children: /* @__PURE__ */ jsx(
|
|
6855
|
+
RequiredFilter,
|
|
6856
|
+
{
|
|
6857
|
+
label: t2("crm.quotes.status"),
|
|
6858
|
+
value: statusFilter.length === 0 ? t2("crm.quotes.filterAllStatuses") : statusFilter.length === 1 ? t2(`crm.quotes.status.${statusFilter[0]}`) : t2("crud.list.selectedMany", { count: statusFilter.length }),
|
|
6859
|
+
icon: CircleDashed,
|
|
6860
|
+
className: "h-9 w-full justify-start",
|
|
6861
|
+
align: "start",
|
|
6862
|
+
children: /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
|
|
6863
|
+
/* @__PURE__ */ jsx(FilterMenuRow, { active: statusFilter.length === 0, onClick: () => setStatusFilter([]), children: t2("crm.quotes.filterAllStatuses") }),
|
|
6864
|
+
QUOTE_STATUSES.map((st) => {
|
|
6865
|
+
const on = statusFilter.includes(st);
|
|
6866
|
+
return /* @__PURE__ */ jsx(
|
|
6867
|
+
FilterMenuRow,
|
|
6868
|
+
{
|
|
6869
|
+
active: on,
|
|
6870
|
+
onClick: () => setStatusFilter(on ? statusFilter.filter((v) => v !== st) : [...statusFilter, st]),
|
|
6871
|
+
children: /* @__PURE__ */ jsx("span", { className: "truncate", children: t2(`crm.quotes.status.${st}`) })
|
|
6872
|
+
},
|
|
6873
|
+
st
|
|
6874
|
+
);
|
|
6875
|
+
})
|
|
6876
|
+
] })
|
|
6877
|
+
}
|
|
6878
|
+
) }),
|
|
6879
|
+
/* @__PURE__ */ jsx(FilterPanelField, { label: t2("crm.quotes.contact"), compact: true, children: /* @__PURE__ */ jsx(
|
|
6880
|
+
SearchSelect,
|
|
6881
|
+
{
|
|
6882
|
+
className: "w-full",
|
|
6883
|
+
value: contactId,
|
|
6884
|
+
displayValue: contactName,
|
|
6885
|
+
placeholder: t2("crm.quotes.filterContactPlaceholder"),
|
|
6886
|
+
minChars: 2,
|
|
6887
|
+
minCharsLabel: t2("crm.quotes.filterMinChars"),
|
|
6888
|
+
noResultsLabel: t2("crm.quotes.filterNoContact"),
|
|
6889
|
+
searchingLabel: t2("crm.quotes.filterSearching"),
|
|
6890
|
+
loadOnOpen: false,
|
|
6891
|
+
clearLabel: t2("crm.quotes.filterAllContacts"),
|
|
6892
|
+
onChange: (id, option) => {
|
|
6893
|
+
setContactId(id);
|
|
6894
|
+
setContactName(option?.label ?? "");
|
|
6895
|
+
},
|
|
6896
|
+
onSearch: async (termo) => {
|
|
6897
|
+
const results = await contactLookup.search(termo);
|
|
6898
|
+
return results.map((r) => ({ id: r.id, label: r.label, subtitle: r.subtitle, group: r.group, data: r }));
|
|
6899
|
+
}
|
|
6900
|
+
}
|
|
6901
|
+
) })
|
|
6902
|
+
]
|
|
6903
|
+
}
|
|
6904
|
+
),
|
|
6905
|
+
/* @__PURE__ */ jsxs(Card, { className: "relative px-3 py-1.5", children: [
|
|
6906
|
+
/* @__PURE__ */ jsx(Search, { className: "pointer-events-none absolute left-5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
|
|
6907
|
+
/* @__PURE__ */ jsx(
|
|
6908
|
+
"input",
|
|
6909
|
+
{
|
|
6910
|
+
type: "text",
|
|
6911
|
+
value: search,
|
|
6912
|
+
onChange: (e) => setSearch(e.target.value),
|
|
6913
|
+
onKeyDown: (e) => {
|
|
6914
|
+
if (e.key === "Enter") aplicarFiltros();
|
|
6915
|
+
},
|
|
6916
|
+
placeholder: t2("crm.quotes.searchPlaceholder"),
|
|
6917
|
+
"aria-label": t2("crm.quotes.searchPlaceholder"),
|
|
6918
|
+
className: "w-full bg-transparent py-1.5 pl-8 pr-3 text-sm placeholder:text-muted-foreground focus:outline-none"
|
|
6919
|
+
}
|
|
6920
|
+
)
|
|
6921
|
+
] }),
|
|
6618
6922
|
/* @__PURE__ */ jsx(
|
|
6619
6923
|
DataTable,
|
|
6620
6924
|
{
|
|
@@ -10793,10 +11097,32 @@ function buildNav(config, view, navigate, hasAutomations, surveysLabel, networkL
|
|
|
10793
11097
|
{ id: "dashboard", label: config.labels.dashboard ?? t2("crm.nav.dashboard"), icon: "BarChart3", active: view === "dashboard", onClick: () => navigate("dashboard") }
|
|
10794
11098
|
];
|
|
10795
11099
|
if (config.modules.pipeline) {
|
|
10796
|
-
items.push({
|
|
11100
|
+
items.push({
|
|
11101
|
+
id: "pipeline",
|
|
11102
|
+
label: config.labels.pipeline ?? t2("crm.deals.title"),
|
|
11103
|
+
icon: "Filter",
|
|
11104
|
+
active: view.startsWith("pipeline"),
|
|
11105
|
+
children: [
|
|
11106
|
+
{ id: "pipeline", label: t2("crm.deals.viewBoard"), defaultChild: true, active: view === "pipeline" || view.startsWith("pipeline-detail"), onClick: () => navigate("pipeline") },
|
|
11107
|
+
{ id: "pipeline-list", label: t2("crm.deals.viewList"), active: view === "pipeline-list", onClick: () => navigate("pipeline-list") },
|
|
11108
|
+
{ id: "pipeline-funnel", label: t2("crm.deals.viewFunnel"), active: view === "pipeline-funnel", onClick: () => navigate("pipeline-funnel") }
|
|
11109
|
+
]
|
|
11110
|
+
});
|
|
10797
11111
|
}
|
|
10798
11112
|
if (flat) {
|
|
10799
|
-
items.push({
|
|
11113
|
+
items.push({
|
|
11114
|
+
id: "leads",
|
|
11115
|
+
label: config.labels.leads ?? t2("crm.leads.title"),
|
|
11116
|
+
icon: "UserPlus",
|
|
11117
|
+
active: view.startsWith("leads-") || view.startsWith("companies-") || view === "company-groups",
|
|
11118
|
+
children: [
|
|
11119
|
+
{ id: "leads-list", label: config.labels.leads ?? t2("crm.leads.title"), defaultChild: true, active: view === "leads-list" || view === "leads-new" || view.startsWith("leads-detail:"), onClick: () => navigate("leads-list") },
|
|
11120
|
+
...config.modules.companies ? [
|
|
11121
|
+
{ id: "companies-list", label: config.labels.companies ?? t2("crm.companies.title"), active: view === "companies-list" || view === "companies-new" || view.startsWith("companies-detail:") || view.startsWith("companies-edit:"), onClick: () => navigate("companies-list") },
|
|
11122
|
+
{ id: "company-groups", label: config.labels.groups ?? t2("crm.groups.title"), active: view === "company-groups", onClick: () => navigate("company-groups") }
|
|
11123
|
+
] : []
|
|
11124
|
+
]
|
|
11125
|
+
});
|
|
10800
11126
|
} else {
|
|
10801
11127
|
items.push({
|
|
10802
11128
|
id: "leads",
|
|
@@ -10850,9 +11176,50 @@ function buildNav(config, view, navigate, hasAutomations, surveysLabel, networkL
|
|
|
10850
11176
|
]
|
|
10851
11177
|
});
|
|
10852
11178
|
}
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
11179
|
+
items.push({
|
|
11180
|
+
id: "engagement",
|
|
11181
|
+
label: t2("crm.engagement.title"),
|
|
11182
|
+
icon: "Clock",
|
|
11183
|
+
active: view === "tasks" || view === "follow-ups",
|
|
11184
|
+
children: [
|
|
11185
|
+
{ id: "tasks", label: t2("crm.engagement.tasks"), defaultChild: true, active: view === "tasks", onClick: () => navigate("tasks") },
|
|
11186
|
+
{ id: "follow-ups", label: t2("crm.engagement.followUps"), active: view === "follow-ups", onClick: () => navigate("follow-ups") }
|
|
11187
|
+
]
|
|
11188
|
+
});
|
|
11189
|
+
items.push({
|
|
11190
|
+
id: "retention",
|
|
11191
|
+
label: t2("crm.retention.title"),
|
|
11192
|
+
icon: "Gift",
|
|
11193
|
+
active: ["loyalty", "referrals", "birthdays", "pending-returns"].includes(view),
|
|
11194
|
+
children: [
|
|
11195
|
+
{ id: "loyalty", label: t2("crm.retention.loyalty"), defaultChild: true, active: view === "loyalty", onClick: () => navigate("loyalty") },
|
|
11196
|
+
{ id: "referrals", label: t2("crm.retention.referrals"), active: view === "referrals", onClick: () => navigate("referrals") },
|
|
11197
|
+
{ id: "birthdays", label: t2("crm.retention.birthdays"), active: view === "birthdays", onClick: () => navigate("birthdays") },
|
|
11198
|
+
{ id: "pending-returns", label: t2("crm.retention.pendingReturns"), active: view === "pending-returns", onClick: () => navigate("pending-returns") }
|
|
11199
|
+
]
|
|
11200
|
+
});
|
|
11201
|
+
items.push({
|
|
11202
|
+
id: "goals",
|
|
11203
|
+
label: t2("crm.goals.title"),
|
|
11204
|
+
icon: "Target",
|
|
11205
|
+
active: ["goals-units", "goals-kpi", "goals-professionals", "goals-franchisor"].includes(view),
|
|
11206
|
+
children: [
|
|
11207
|
+
{ id: "goals-units", label: t2("crm.goals.units"), defaultChild: true, active: view === "goals-units", onClick: () => navigate("goals-units") },
|
|
11208
|
+
{ id: "goals-kpi", label: t2("crm.goals.kpi"), active: view === "goals-kpi", onClick: () => navigate("goals-kpi") },
|
|
11209
|
+
{ id: "goals-professionals", label: t2("crm.goals.professionals"), active: view === "goals-professionals", onClick: () => navigate("goals-professionals") },
|
|
11210
|
+
{ id: "goals-franchisor", label: t2("crm.goals.franchisor"), active: view === "goals-franchisor", onClick: () => navigate("goals-franchisor") }
|
|
11211
|
+
]
|
|
11212
|
+
});
|
|
11213
|
+
items.push({
|
|
11214
|
+
id: "panels",
|
|
11215
|
+
label: t2("crm.panels.title"),
|
|
11216
|
+
icon: "LayoutDashboard",
|
|
11217
|
+
active: view === "operational-dashboard" || view === "maturity",
|
|
11218
|
+
children: [
|
|
11219
|
+
{ id: "operational-dashboard", label: t2("crm.panels.operational"), defaultChild: true, active: view === "operational-dashboard", onClick: () => navigate("operational-dashboard") },
|
|
11220
|
+
{ id: "maturity", label: t2("crm.panels.maturity"), active: view === "maturity", onClick: () => navigate("maturity") }
|
|
11221
|
+
]
|
|
11222
|
+
});
|
|
10856
11223
|
if (config.modules.surveys) {
|
|
10857
11224
|
items.push({ id: "surveys", label: surveysLabel, icon: "Star", active: view === "surveys", onClick: () => navigate("surveys") });
|
|
10858
11225
|
}
|
|
@@ -10897,7 +11264,6 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
10897
11264
|
const onboarding = usePluginOnboardingGate("saas-core:crm-onboarded", checkExistingData);
|
|
10898
11265
|
const isSettings = view === "settings";
|
|
10899
11266
|
const isSummary = view === "dashboard";
|
|
10900
|
-
const leadsFamilyTab = view === "leads-list" || view === "leads-new" ? "leads" : view === "companies-list" || view === "companies-new" ? "companies" : view === "company-groups" ? "groups" : null;
|
|
10901
11267
|
const openStageSettings = () => adminNavigateTo("/settings/crm/_properties/stages");
|
|
10902
11268
|
const runtime = usePluginRuntimeOptional();
|
|
10903
11269
|
const hasAutomations = Boolean(runtime?.activePlugins.some((p) => p.id === "automations"));
|
|
@@ -10907,8 +11273,7 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
10907
11273
|
const quickActions = useMemo(() => [
|
|
10908
11274
|
{ id: "new-lead", label: t2("crm.quickActions.newLead"), icon: "UserPlus", description: t2("crm.quickActions.newLeadDesc"), action: () => navigate("leads-new") },
|
|
10909
11275
|
{ id: "new-deal", label: t2("crm.quickActions.newDeal"), icon: "Target", description: t2("crm.quickActions.newDealDesc"), action: () => navigate("pipeline") },
|
|
10910
|
-
...config.modules.quotes ? [{ id: "new-quote", label: t2("crm.quickActions.newQuote"), icon: "FileText", description: t2("crm.quickActions.newQuoteDesc"), action: () => navigate("quotes-new") }] : []
|
|
10911
|
-
...config.modules.activities ? [{ id: "log-activity", label: t2("crm.quickActions.logActivity"), icon: "MessageCircle", description: t2("crm.quickActions.logActivityDesc"), action: () => navigate("activities") }] : []
|
|
11276
|
+
...config.modules.quotes ? [{ id: "new-quote", label: t2("crm.quickActions.newQuote"), icon: "FileText", description: t2("crm.quickActions.newQuoteDesc"), action: () => navigate("quotes-new") }] : []
|
|
10912
11277
|
], [config.modules]);
|
|
10913
11278
|
if (isSummary && onboarding.status === "checking") {
|
|
10914
11279
|
return /* @__PURE__ */ jsx(CrmContextProvider, { config, provider, store, children: /* @__PURE__ */ jsx(PluginOnboardingGateSkeleton, {}) });
|
|
@@ -10929,11 +11294,13 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
10929
11294
|
// O funil e o funil COM UM CARD ABERTO são a mesma view: só muda a prop.
|
|
10930
11295
|
// Assim a URL carrega o id (`/sales/pipeline/<id>` — um link que o colega
|
|
10931
11296
|
// abre no card certo) sem que o quadro desmonte a cada card aberto.
|
|
10932
|
-
...["pipeline", "pipeline-detail"].map((id) => ({
|
|
11297
|
+
...["pipeline", "pipeline-detail", "pipeline-list", "pipeline-funnel"].map((id) => ({
|
|
10933
11298
|
id,
|
|
10934
11299
|
render: ({ id: dealId }) => /* @__PURE__ */ jsx(
|
|
10935
11300
|
DealsView,
|
|
10936
11301
|
{
|
|
11302
|
+
mode: id === "pipeline-list" ? "list" : id === "pipeline-funnel" ? "funnel" : "board",
|
|
11303
|
+
onChangeMode: (m) => navigate(m === "list" ? "pipeline-list" : m === "funnel" ? "pipeline-funnel" : "pipeline"),
|
|
10937
11304
|
openDealId: dealId,
|
|
10938
11305
|
onOpenDeal: (did) => navigate(`pipeline-detail:${did}`),
|
|
10939
11306
|
onCloseDeal: () => navigate("pipeline"),
|
|
@@ -10985,11 +11352,24 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
10985
11352
|
onOpenDeal: (did) => navigate(`pipeline-detail:${did}`, `/sales/pipeline/${did}`)
|
|
10986
11353
|
}
|
|
10987
11354
|
) },
|
|
11355
|
+
// As telas que ainda não existem — ver ./GapScreens.
|
|
11356
|
+
{ id: "tasks", render: () => /* @__PURE__ */ jsx(TasksView, {}) },
|
|
11357
|
+
{ id: "follow-ups", render: () => /* @__PURE__ */ jsx(FollowUpsView, {}) },
|
|
11358
|
+
{ id: "loyalty", render: () => /* @__PURE__ */ jsx(LoyaltyView, {}) },
|
|
11359
|
+
{ id: "referrals", render: () => /* @__PURE__ */ jsx(ReferralsView, {}) },
|
|
11360
|
+
{ id: "birthdays", render: () => /* @__PURE__ */ jsx(BirthdaysView, {}) },
|
|
11361
|
+
{ id: "pending-returns", render: () => /* @__PURE__ */ jsx(PendingReturnsView, {}) },
|
|
11362
|
+
{ id: "goals-units", render: () => /* @__PURE__ */ jsx(UnitGoalsView, {}) },
|
|
11363
|
+
{ id: "goals-kpi", render: () => /* @__PURE__ */ jsx(KpiGoalsView, {}) },
|
|
11364
|
+
{ id: "goals-professionals", render: () => /* @__PURE__ */ jsx(ProfessionalGoalsView, {}) },
|
|
11365
|
+
{ id: "goals-franchisor", render: () => /* @__PURE__ */ jsx(FranchisorGoalsView, {}) },
|
|
11366
|
+
{ id: "operational-dashboard", render: () => /* @__PURE__ */ jsx(OperationalDashboardView, {}) },
|
|
11367
|
+
{ id: "maturity", render: () => /* @__PURE__ */ jsx(MaturityView, {}) },
|
|
10988
11368
|
{ id: "surveys", render: () => /* @__PURE__ */ jsx(SurveysView, {}) },
|
|
10989
11369
|
{ id: "network", render: () => /* @__PURE__ */ jsx(NetworkView, {}) },
|
|
10990
11370
|
{ id: "dashboard", render: () => /* @__PURE__ */ jsx(DashboardView, {}) }
|
|
10991
11371
|
], "dashboard");
|
|
10992
|
-
return /* @__PURE__ */ jsx(CrmContextProvider, { config, provider, store, children: /* @__PURE__ */
|
|
11372
|
+
return /* @__PURE__ */ jsx(CrmContextProvider, { config, provider, store, children: /* @__PURE__ */ jsx(
|
|
10993
11373
|
ModulePage,
|
|
10994
11374
|
{
|
|
10995
11375
|
title: config.labels.pageTitle,
|
|
@@ -11006,24 +11386,7 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
11006
11386
|
settingsPath: registries && registries.length > 0 ? "/settings/crm" : void 0
|
|
11007
11387
|
}
|
|
11008
11388
|
),
|
|
11009
|
-
children:
|
|
11010
|
-
config.navStyle === "flat" && leadsFamilyTab && /* @__PURE__ */ jsxs(PageViewBar, { children: [
|
|
11011
|
-
/* @__PURE__ */ jsx(
|
|
11012
|
-
ViewTabs,
|
|
11013
|
-
{
|
|
11014
|
-
value: leadsFamilyTab,
|
|
11015
|
-
onChange: (v) => navigate(v === "leads" ? "leads-list" : v === "companies" ? "companies-list" : "company-groups"),
|
|
11016
|
-
options: [
|
|
11017
|
-
{ value: "leads", label: config.labels.leads ?? t2("crm.leads.title") },
|
|
11018
|
-
{ value: "companies", label: config.labels.companies ?? t2("crm.companies.title") },
|
|
11019
|
-
{ value: "groups", label: config.labels.groups ?? t2("crm.groups.title") }
|
|
11020
|
-
]
|
|
11021
|
-
}
|
|
11022
|
-
),
|
|
11023
|
-
/* @__PURE__ */ jsx("span", {})
|
|
11024
|
-
] }),
|
|
11025
|
-
renderView(view)
|
|
11026
|
-
]
|
|
11389
|
+
children: renderView(view)
|
|
11027
11390
|
}
|
|
11028
11391
|
) });
|
|
11029
11392
|
}
|
|
@@ -12014,6 +12377,9 @@ function createMockCrmProvider(options) {
|
|
|
12014
12377
|
results = results.filter((q) => statuses.includes(q.status));
|
|
12015
12378
|
}
|
|
12016
12379
|
if (query.contactId) results = results.filter((q) => q.contactId === query.contactId);
|
|
12380
|
+
if (query.dateRange) {
|
|
12381
|
+
results = results.filter((q) => q.quoteDate >= query.dateRange.from && q.quoteDate <= query.dateRange.to);
|
|
12382
|
+
}
|
|
12017
12383
|
if (query.search) {
|
|
12018
12384
|
const s = query.search.toLowerCase();
|
|
12019
12385
|
results = results.filter((q) => q.quoteNumber.includes(s) || q.contactName?.toLowerCase().includes(s));
|
|
@@ -13502,6 +13868,7 @@ function createSupabaseCrmProvider(options) {
|
|
|
13502
13868
|
probability: stageRow?.probability ?? 0,
|
|
13503
13869
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
13504
13870
|
};
|
|
13871
|
+
if (stageRow?.pipeline_id) patch.pipeline_id = stageRow.pipeline_id;
|
|
13505
13872
|
if (stageRow?.is_won) {
|
|
13506
13873
|
patch.status = "won";
|
|
13507
13874
|
patch.lost_at = null;
|
|
@@ -13690,6 +14057,10 @@ function createSupabaseCrmProvider(options) {
|
|
|
13690
14057
|
qb = qb.neq("status", "archived");
|
|
13691
14058
|
}
|
|
13692
14059
|
if (query.search) qb = qb.or(`number.ilike.%${query.search}%,notes.ilike.%${query.search}%`);
|
|
14060
|
+
if (query.contactId) qb = qb.eq("party_id", query.contactId);
|
|
14061
|
+
if (query.dateRange) {
|
|
14062
|
+
qb = qb.gte("created_at", query.dateRange.from).lte("created_at", `${query.dateRange.to}T23:59:59.999`);
|
|
14063
|
+
}
|
|
13693
14064
|
const page = query.page ?? 1;
|
|
13694
14065
|
const pageSize = query.pageSize ?? 50;
|
|
13695
14066
|
qb = qb.range((page - 1) * pageSize, page * pageSize - 1).order("created_at", { ascending: false });
|
|
@@ -15319,19 +15690,31 @@ function createCrmStore(provider) {
|
|
|
15319
15690
|
async createLead(input) {
|
|
15320
15691
|
try {
|
|
15321
15692
|
const lead = await provider.createLead(input);
|
|
15322
|
-
|
|
15693
|
+
let { pipeline: pipeline2, stages: entryStages } = await get().resolveEntryPipeline();
|
|
15694
|
+
if (input.pipelineId && input.pipelineId !== pipeline2?.id) {
|
|
15695
|
+
const alvo = get().pipelines.find((p) => p.id === input.pipelineId);
|
|
15696
|
+
if (alvo) {
|
|
15697
|
+
pipeline2 = alvo;
|
|
15698
|
+
entryStages = get().activePipelineId === alvo.id && get().stages.length > 0 ? get().stages : await provider.getPipelineStages(alvo.id);
|
|
15699
|
+
}
|
|
15700
|
+
}
|
|
15323
15701
|
const chosen = input.stageId ? entryStages.find((s) => s.id === input.stageId) : void 0;
|
|
15324
15702
|
const stage = chosen ?? entryStage(entryStages);
|
|
15325
15703
|
if (pipeline2 && stage) {
|
|
15704
|
+
const existing = await Promise.resolve(provider.getPipelineCardForLead?.(lead.id)).catch(() => null);
|
|
15326
15705
|
try {
|
|
15327
|
-
|
|
15328
|
-
|
|
15329
|
-
|
|
15330
|
-
|
|
15331
|
-
|
|
15332
|
-
|
|
15333
|
-
|
|
15334
|
-
|
|
15706
|
+
if (existing) {
|
|
15707
|
+
if (existing.stageId !== stage.id) await provider.moveDealToStage(existing.id, stage.id);
|
|
15708
|
+
} else {
|
|
15709
|
+
await provider.createDeal({
|
|
15710
|
+
leadId: lead.id,
|
|
15711
|
+
title: lead.name,
|
|
15712
|
+
value: input.value ?? 0,
|
|
15713
|
+
pipelineId: pipeline2.id,
|
|
15714
|
+
stageId: stage.id,
|
|
15715
|
+
contactName: lead.name
|
|
15716
|
+
});
|
|
15717
|
+
}
|
|
15335
15718
|
} catch {
|
|
15336
15719
|
}
|
|
15337
15720
|
}
|
|
@@ -30214,6 +30597,22 @@ var en = {
|
|
|
30214
30597
|
"crm.board.prop.value": "Value",
|
|
30215
30598
|
"crm.board.prop.age": "Age",
|
|
30216
30599
|
"crm.deals.switchView": "Switch deals view",
|
|
30600
|
+
"crm.engagement.title": "Engagement",
|
|
30601
|
+
"crm.engagement.tasks": "Tasks",
|
|
30602
|
+
"crm.engagement.followUps": "Follow-ups",
|
|
30603
|
+
"crm.retention.title": "Retention",
|
|
30604
|
+
"crm.retention.loyalty": "Loyalty Club",
|
|
30605
|
+
"crm.retention.referrals": "Referrals",
|
|
30606
|
+
"crm.retention.birthdays": "Birthdays",
|
|
30607
|
+
"crm.retention.pendingReturns": "Pending Returns",
|
|
30608
|
+
"crm.goals.title": "Goals",
|
|
30609
|
+
"crm.goals.units": "Units",
|
|
30610
|
+
"crm.goals.kpi": "Indicators",
|
|
30611
|
+
"crm.goals.professionals": "Professionals",
|
|
30612
|
+
"crm.goals.franchisor": "Franchisor",
|
|
30613
|
+
"crm.panels.title": "Panels",
|
|
30614
|
+
"crm.panels.operational": "Operational",
|
|
30615
|
+
"crm.panels.maturity": "Maturity",
|
|
30217
30616
|
"crm.deals.viewBoard": "Board",
|
|
30218
30617
|
"crm.deals.viewList": "List",
|
|
30219
30618
|
"crm.deals.viewFunnel": "Conversion",
|
|
@@ -30416,6 +30815,26 @@ var en = {
|
|
|
30416
30815
|
"crm.quoteForm.validOneWeek": "1 week",
|
|
30417
30816
|
"crm.quoteForm.validThirtyDays": "30 days",
|
|
30418
30817
|
"crm.quoteForm.validUntil": "Valid Until",
|
|
30818
|
+
"crm.quotes.filtersTitle": "Filters",
|
|
30819
|
+
"crm.quotes.filterApply": "Search",
|
|
30820
|
+
"crm.quotes.filterClear": "Clear",
|
|
30821
|
+
"crm.quotes.filterPending": "Filters changed",
|
|
30822
|
+
"crm.quotes.filterPendingHint": "The list still shows the previous selection. Click Search to apply.",
|
|
30823
|
+
"crm.quotes.filterFrom": "From",
|
|
30824
|
+
"crm.quotes.filterTo": "To",
|
|
30825
|
+
"crm.quotes.filterAllStatuses": "All",
|
|
30826
|
+
"crm.quotes.filterAllContacts": "All",
|
|
30827
|
+
"crm.quotes.filterContactPlaceholder": "Type...",
|
|
30828
|
+
"crm.quotes.filterMinChars": "Type at least 2 characters to search.",
|
|
30829
|
+
"crm.quotes.filterNoContact": "No record found.",
|
|
30830
|
+
"crm.quotes.filterSearching": "Searching records...",
|
|
30831
|
+
"crm.quotes.searchPlaceholder": "Search by number or notes...",
|
|
30832
|
+
"crm.quotes.status.draft": "Draft",
|
|
30833
|
+
"crm.quotes.status.sent": "Sent",
|
|
30834
|
+
"crm.quotes.status.approved": "Approved",
|
|
30835
|
+
"crm.quotes.status.rejected": "Rejected",
|
|
30836
|
+
"crm.quotes.status.expired": "Expired",
|
|
30837
|
+
"crm.quotes.status.archived": "Archived",
|
|
30419
30838
|
"crm.quotes.amount": "Amount",
|
|
30420
30839
|
"crm.quotes.archive": "Archive",
|
|
30421
30840
|
"crm.quotes.archiveTitle": "Archive this quote?",
|
|
@@ -31119,7 +31538,23 @@ var ptBR = {
|
|
|
31119
31538
|
"crm.board.prop.value": "Valor",
|
|
31120
31539
|
"crm.board.prop.age": "Idade",
|
|
31121
31540
|
"crm.deals.switchView": "Trocar a vis\xE3o dos neg\xF3cios",
|
|
31122
|
-
"crm.
|
|
31541
|
+
"crm.engagement.title": "Engajamento",
|
|
31542
|
+
"crm.engagement.tasks": "Tarefas",
|
|
31543
|
+
"crm.engagement.followUps": "Follow-ups",
|
|
31544
|
+
"crm.retention.title": "Fideliza\xE7\xE3o",
|
|
31545
|
+
"crm.retention.loyalty": "Clube de Fidelidade",
|
|
31546
|
+
"crm.retention.referrals": "Indica\xE7\xF5es",
|
|
31547
|
+
"crm.retention.birthdays": "Aniversariantes",
|
|
31548
|
+
"crm.retention.pendingReturns": "Retornos Pendentes",
|
|
31549
|
+
"crm.goals.title": "Metas",
|
|
31550
|
+
"crm.goals.units": "Unidades",
|
|
31551
|
+
"crm.goals.kpi": "Indicadores",
|
|
31552
|
+
"crm.goals.professionals": "Profissionais",
|
|
31553
|
+
"crm.goals.franchisor": "Franqueador",
|
|
31554
|
+
"crm.panels.title": "Pain\xE9is",
|
|
31555
|
+
"crm.panels.operational": "Operacional",
|
|
31556
|
+
"crm.panels.maturity": "Maturidade",
|
|
31557
|
+
"crm.deals.viewBoard": "Quadro",
|
|
31123
31558
|
"crm.deals.viewList": "Lista",
|
|
31124
31559
|
"crm.deals.viewFunnel": "Convers\xE3o",
|
|
31125
31560
|
"crm.deals.colDeal": "Neg\xF3cio",
|
|
@@ -31321,6 +31756,26 @@ var ptBR = {
|
|
|
31321
31756
|
"crm.quoteForm.validOneWeek": "1 semana",
|
|
31322
31757
|
"crm.quoteForm.validThirtyDays": "30 dias",
|
|
31323
31758
|
"crm.quoteForm.validUntil": "V\xE1lido At\xE9",
|
|
31759
|
+
"crm.quotes.filtersTitle": "Filtros",
|
|
31760
|
+
"crm.quotes.filterApply": "Buscar",
|
|
31761
|
+
"crm.quotes.filterClear": "Limpar",
|
|
31762
|
+
"crm.quotes.filterPending": "Filtros alterados",
|
|
31763
|
+
"crm.quotes.filterPendingHint": "A lista ainda mostra o recorte anterior. Clique em Buscar para aplicar.",
|
|
31764
|
+
"crm.quotes.filterFrom": "De",
|
|
31765
|
+
"crm.quotes.filterTo": "At\xE9",
|
|
31766
|
+
"crm.quotes.filterAllStatuses": "Todos",
|
|
31767
|
+
"crm.quotes.filterAllContacts": "Todos",
|
|
31768
|
+
"crm.quotes.filterContactPlaceholder": "Digite...",
|
|
31769
|
+
"crm.quotes.filterMinChars": "Digite pelo menos 2 caracteres para buscar.",
|
|
31770
|
+
"crm.quotes.filterNoContact": "Nenhum cadastro encontrado.",
|
|
31771
|
+
"crm.quotes.filterSearching": "Buscando cadastros...",
|
|
31772
|
+
"crm.quotes.searchPlaceholder": "Buscar por n\xFAmero ou observa\xE7\xE3o...",
|
|
31773
|
+
"crm.quotes.status.draft": "Rascunho",
|
|
31774
|
+
"crm.quotes.status.sent": "Enviado",
|
|
31775
|
+
"crm.quotes.status.approved": "Aprovado",
|
|
31776
|
+
"crm.quotes.status.rejected": "Recusado",
|
|
31777
|
+
"crm.quotes.status.expired": "Expirado",
|
|
31778
|
+
"crm.quotes.status.archived": "Arquivado",
|
|
31324
31779
|
"crm.quotes.amount": "Valor",
|
|
31325
31780
|
"crm.quotes.archive": "Arquivar",
|
|
31326
31781
|
"crm.quotes.archiveTitle": "Arquivar este or\xE7amento?",
|
|
@@ -32945,6 +33400,6 @@ function createCrmPlugin(options) {
|
|
|
32945
33400
|
};
|
|
32946
33401
|
}
|
|
32947
33402
|
|
|
32948
|
-
export { TagChips, buildCrmDomainEvents, buildCrmMessageDefaults, createCrmPlugin, humanizeTag };
|
|
33403
|
+
export { TagChips, buildCrmCustomerEntity, buildCrmDomainEvents, buildCrmMessageDefaults, createCrmPlugin, customerVocabulary, humanizeTag };
|
|
32949
33404
|
//# sourceMappingURL=index.js.map
|
|
32950
33405
|
//# sourceMappingURL=index.js.map
|