@fayz-ai/plugin-crm 0.31.0 → 0.31.1

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/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react';
2
2
  import { tl, useTranslation, getSupabaseClientOptional, registerTranslations, registerMessageDefaults, createSafeDataProvider, getActiveTenantId, RECORD_GROUP, recordRailFields, activeFacet, countByTenant, usePluginRuntimeOptional, getActiveUnitId, 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, 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, Search, ThumbsDown, SignalHigh, CalendarRange, ChevronLeft, TrendingDown, UserCheck, AlertTriangle, Settings2, Repeat, Zap, Snowflake, Sun, Flame, Merge, Paperclip, ImageOff, CircleAlert, CircleDashed, CheckCircle2, SlidersHorizontal, ExternalLink, Clipboard, DollarSign, ThumbsUp, UserRoundPlus } from 'lucide-react';
5
- import { Badge, Checkbox, toast, defineKpiWidget, defineChartWidget, defineCustomWidget, defineTableWidget, PageTransition, ModulePage, PageViewBar, ViewTabs, 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, DataTable, Dropdown, DropdownTrigger, DropdownContent, DropdownItem, PhoneLink, SheetBody, SheetFooter, DashboardCanvas, ModalDescription, Card, PersonPicker, CurrencyInput, HeaderTabs, Popover, PopoverTrigger, PopoverContent, getLucideIcon, DictateButton, DropdownLabel, DropdownSeparator, normalizePhone, KpiCard, ChartWidget, CardHeader, CardTitle, CardContent, TableWidget } from '@fayz-ai/ui';
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';
@@ -1818,7 +1818,7 @@ function StageCards({ stageId, deals, total, onLoadMore, loadMoreLabel, savingDe
1818
1818
  )
1819
1819
  ] });
1820
1820
  }
1821
- function PipelineView({ onDealClick, onAddLead, onOpenSettings, onStageIntent, modeControl }) {
1821
+ function PipelineView({ onDealClick, onAddLead, onOpenSettings, onStageIntent }) {
1822
1822
  const { currency } = useCrmConfig();
1823
1823
  const pipelines = useCrmStore((s) => s.pipelines);
1824
1824
  const activePipelineId = useCrmStore((s) => s.activePipelineId);
@@ -2113,196 +2113,193 @@ function PipelineView({ onDealClick, onAddLead, onOpenSettings, onStageIntent, m
2113
2113
  setMenu({ x: e.clientX, y: e.clientY, deal, mode });
2114
2114
  }
2115
2115
  return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
2116
- /* @__PURE__ */ jsxs(PageViewBar, { children: [
2117
- /* @__PURE__ */ jsx("div", { className: "min-w-0", children: modeControl }),
2118
- /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [
2119
- effectiveOwner && /* @__PURE__ */ jsxs(
2120
- BoardFilterChip,
2121
- {
2122
- closeOnSelect: true,
2123
- clearLabel: t2("crm.board.clearFilters"),
2124
- onClear: () => setOwnerFilter(void 0),
2125
- trigger: /* @__PURE__ */ jsxs(Fragment, { children: [
2126
- effectiveOwner === "none" ? /* @__PURE__ */ jsx(UserRound, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(PersonAvatar, { name: (team ?? []).find((m) => m.userId === effectiveOwner)?.name ?? "Eu", size: "xs" }),
2127
- /* @__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") })
2128
- ] }),
2129
- children: [
2130
- myUserId && /* @__PURE__ */ jsxs("button", { className: CHIP_ROW, onClick: () => setOwnerFilter("__me__"), children: [
2131
- /* @__PURE__ */ jsx(PersonAvatar, { name: (team ?? []).find((m) => m.userId === myUserId)?.name ?? "Eu", size: "xs" }),
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
- ] })
2116
+ /* @__PURE__ */ jsx(PageViewBar, { children: /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [
2117
+ effectiveOwner && /* @__PURE__ */ jsxs(
2118
+ BoardFilterChip,
2119
+ {
2120
+ closeOnSelect: true,
2121
+ clearLabel: t2("crm.board.clearFilters"),
2122
+ onClear: () => setOwnerFilter(void 0),
2123
+ trigger: /* @__PURE__ */ jsxs(Fragment, { children: [
2124
+ effectiveOwner === "none" ? /* @__PURE__ */ jsx(UserRound, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(PersonAvatar, { name: (team ?? []).find((m) => m.userId === effectiveOwner)?.name ?? "Eu", size: "xs" }),
2125
+ /* @__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") })
2126
+ ] }),
2127
+ children: [
2128
+ myUserId && /* @__PURE__ */ jsxs("button", { className: CHIP_ROW, onClick: () => setOwnerFilter("__me__"), children: [
2129
+ /* @__PURE__ */ jsx(PersonAvatar, { name: (team ?? []).find((m) => m.userId === myUserId)?.name ?? "Eu", size: "xs" }),
2130
+ " ",
2131
+ t2("crm.leads.filters.mine"),
2132
+ effectiveOwner === myUserId && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
2178
2133
  ] }),
2179
- children: [.../* @__PURE__ */ new Set([...availableTags, ...selectedTags])].sort((a, b) => (tagDefs.get(a)?.name ?? humanizeTag(a)).localeCompare(tagDefs.get(b)?.name ?? humanizeTag(b))).map((slug) => {
2180
- const on = selectedTags.includes(slug);
2181
- return /* @__PURE__ */ jsxs(
2182
- "button",
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
- )
2134
+ /* @__PURE__ */ jsxs("button", { className: CHIP_ROW, onClick: () => setOwnerFilter("none"), children: [
2135
+ /* @__PURE__ */ jsx(UserRound, { className: "h-3 w-3 text-muted-foreground" }),
2136
+ " ",
2137
+ t2("crm.leads.filters.unassigned"),
2138
+ effectiveOwner === "none" && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
2221
2139
  ] }),
2222
- fields: [
2223
- {
2224
- id: "owner",
2225
- label: t2("crm.leads.filters.owner"),
2226
- icon: UserRound,
2227
- activeCount: effectiveOwner ? 1 : 0,
2228
- searchable: true,
2229
- render: (close, q) => /* @__PURE__ */ jsxs(Fragment, { children: [
2230
- /* @__PURE__ */ jsxs(FilterMenuRow, { active: !effectiveOwner, onClick: () => {
2231
- setOwnerFilter(void 0);
2232
- close();
2233
- }, children: [
2234
- /* @__PURE__ */ jsx(UserRound, { className: "h-3.5 w-3.5 text-muted-foreground" }),
2235
- " ",
2236
- t2("crm.leads.filters.allOwners")
2237
- ] }),
2238
- myUserId && /* @__PURE__ */ jsxs(FilterMenuRow, { active: effectiveOwner === myUserId, onClick: () => {
2239
- setOwnerFilter("__me__");
2240
- close();
2241
- }, children: [
2242
- /* @__PURE__ */ jsx(PersonAvatar, { name: (team ?? []).find((m) => m.userId === myUserId)?.name ?? "Eu", size: "xs" }),
2243
- " ",
2244
- t2("crm.leads.filters.mine")
2245
- ] }),
2246
- /* @__PURE__ */ jsxs(FilterMenuRow, { active: effectiveOwner === "none", onClick: () => {
2247
- setOwnerFilter("none");
2248
- close();
2249
- }, children: [
2250
- /* @__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" }) }),
2251
- t2("crm.leads.filters.unassigned")
2252
- ] }),
2253
- (team ?? []).filter((m) => m.userId !== myUserId && m.name.toLowerCase().includes(q.toLowerCase())).map((m) => /* @__PURE__ */ jsxs(FilterMenuRow, { active: effectiveOwner === m.userId, onClick: () => {
2254
- setOwnerFilter(m.userId);
2255
- close();
2256
- }, children: [
2257
- /* @__PURE__ */ jsx(PersonAvatar, { name: m.name, size: "xs" }),
2258
- /* @__PURE__ */ jsx("span", { className: "truncate", children: m.name })
2259
- ] }, m.userId))
2260
- ] })
2261
- },
2140
+ (team ?? []).filter((m) => m.userId !== myUserId).map((m) => /* @__PURE__ */ jsxs("button", { className: CHIP_ROW, onClick: () => setOwnerFilter(m.userId), children: [
2141
+ /* @__PURE__ */ jsx(PersonAvatar, { name: m.name, size: "xs" }),
2142
+ " ",
2143
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: m.name }),
2144
+ effectiveOwner === m.userId && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
2145
+ ] }, m.userId))
2146
+ ]
2147
+ }
2148
+ ),
2149
+ period !== "all" && /* @__PURE__ */ jsx(
2150
+ BoardFilterChip,
2151
+ {
2152
+ closeOnSelect: true,
2153
+ clearLabel: t2("crm.board.clearFilters"),
2154
+ onClear: () => setPeriod("all"),
2155
+ trigger: /* @__PURE__ */ jsxs(Fragment, { children: [
2156
+ /* @__PURE__ */ jsx(CalendarDays, { className: "h-3 w-3" }),
2157
+ t2(`crm.filters.period${period === "custom" ? "Custom" : period}`)
2158
+ ] }),
2159
+ children: ["24h", "7d", "custom"].map((p) => /* @__PURE__ */ jsxs("button", { className: CHIP_ROW, onClick: () => setPeriod(p), children: [
2160
+ t2(`crm.filters.period${p === "custom" ? "Custom" : p}`),
2161
+ period === p && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
2162
+ ] }, p))
2163
+ }
2164
+ ),
2165
+ selectedTags.length > 0 && /* @__PURE__ */ jsx(
2166
+ BoardFilterChip,
2167
+ {
2168
+ clearLabel: t2("crm.board.clearFilters"),
2169
+ onClear: () => setSelectedTags([]),
2170
+ trigger: /* @__PURE__ */ jsxs(Fragment, { children: [
2171
+ /* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full", style: { backgroundColor: tagDefs.get(selectedTags[0])?.color ?? "#94A3B8" } }),
2172
+ /* @__PURE__ */ jsxs("span", { className: "max-w-[8rem] truncate", children: [
2173
+ tagDefs.get(selectedTags[0])?.name ?? humanizeTag(selectedTags[0]),
2174
+ selectedTags.length > 1 ? ` +${selectedTags.length - 1}` : ""
2175
+ ] })
2176
+ ] }),
2177
+ children: [.../* @__PURE__ */ new Set([...availableTags, ...selectedTags])].sort((a, b) => (tagDefs.get(a)?.name ?? humanizeTag(a)).localeCompare(tagDefs.get(b)?.name ?? humanizeTag(b))).map((slug) => {
2178
+ const on = selectedTags.includes(slug);
2179
+ return /* @__PURE__ */ jsxs(
2180
+ "button",
2262
2181
  {
2263
- id: "period",
2264
- label: t2("crm.filters.period"),
2265
- icon: CalendarDays,
2266
- activeCount: period !== "all" ? 1 : 0,
2267
- render: (close) => /* @__PURE__ */ jsxs(Fragment, { children: [
2268
- ["all", "24h", "7d", "custom"].map((p) => /* @__PURE__ */ jsx(FilterMenuRow, { active: period === p, onClick: () => {
2269
- setPeriod(p);
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
- ] })
2182
+ className: CHIP_ROW,
2183
+ onClick: () => setSelectedTags(on ? selectedTags.filter((s) => s !== slug) : [...selectedTags, slug]),
2184
+ children: [
2185
+ /* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full", style: { backgroundColor: tagDefs.get(slug)?.color ?? "#94A3B8" } }),
2186
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: tagDefs.get(slug)?.name ?? humanizeTag(slug) }),
2187
+ on && /* @__PURE__ */ jsx(Check, { className: "ml-auto h-3 w-3 shrink-0" })
2188
+ ]
2278
2189
  },
2190
+ slug
2191
+ );
2192
+ })
2193
+ }
2194
+ ),
2195
+ /* @__PURE__ */ jsx(
2196
+ FilterMenu,
2197
+ {
2198
+ label: t2("crm.board.filters"),
2199
+ activeCount: (period !== "all" ? 1 : 0) + (selectedTags.length ? 1 : 0) + (search.trim() ? 1 : 0) + (effectiveOwner ? 1 : 0),
2200
+ onClear: () => {
2201
+ setSearch("");
2202
+ setPeriod("all");
2203
+ setSelectedTags([]);
2204
+ setOwnerFilter(void 0);
2205
+ },
2206
+ clearLabel: t2("crm.board.clearFilters"),
2207
+ header: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
2208
+ /* @__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" }),
2209
+ /* @__PURE__ */ jsx(
2210
+ "input",
2279
2211
  {
2280
- id: "tags",
2281
- label: t2("crm.leads.filters.tag"),
2282
- icon: Tag,
2283
- activeCount: selectedTags.length,
2284
- 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) => {
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
- }) })
2212
+ type: "text",
2213
+ value: search,
2214
+ onChange: (e) => setSearch(e.target.value),
2215
+ placeholder: t2("crm.deals.searchPlaceholder"),
2216
+ 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
2217
  }
2300
- ]
2301
- }
2302
- ),
2303
- /* @__PURE__ */ jsx(DisplayPopover, { display, onChange: setDisplay })
2304
- ] })
2305
- ] }),
2218
+ )
2219
+ ] }),
2220
+ fields: [
2221
+ {
2222
+ id: "owner",
2223
+ label: t2("crm.leads.filters.owner"),
2224
+ icon: UserRound,
2225
+ activeCount: effectiveOwner ? 1 : 0,
2226
+ searchable: true,
2227
+ render: (close, q) => /* @__PURE__ */ jsxs(Fragment, { children: [
2228
+ /* @__PURE__ */ jsxs(FilterMenuRow, { active: !effectiveOwner, onClick: () => {
2229
+ setOwnerFilter(void 0);
2230
+ close();
2231
+ }, children: [
2232
+ /* @__PURE__ */ jsx(UserRound, { className: "h-3.5 w-3.5 text-muted-foreground" }),
2233
+ " ",
2234
+ t2("crm.leads.filters.allOwners")
2235
+ ] }),
2236
+ myUserId && /* @__PURE__ */ jsxs(FilterMenuRow, { active: effectiveOwner === myUserId, onClick: () => {
2237
+ setOwnerFilter("__me__");
2238
+ close();
2239
+ }, children: [
2240
+ /* @__PURE__ */ jsx(PersonAvatar, { name: (team ?? []).find((m) => m.userId === myUserId)?.name ?? "Eu", size: "xs" }),
2241
+ " ",
2242
+ t2("crm.leads.filters.mine")
2243
+ ] }),
2244
+ /* @__PURE__ */ jsxs(FilterMenuRow, { active: effectiveOwner === "none", onClick: () => {
2245
+ setOwnerFilter("none");
2246
+ close();
2247
+ }, children: [
2248
+ /* @__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" }) }),
2249
+ t2("crm.leads.filters.unassigned")
2250
+ ] }),
2251
+ (team ?? []).filter((m) => m.userId !== myUserId && m.name.toLowerCase().includes(q.toLowerCase())).map((m) => /* @__PURE__ */ jsxs(FilterMenuRow, { active: effectiveOwner === m.userId, onClick: () => {
2252
+ setOwnerFilter(m.userId);
2253
+ close();
2254
+ }, children: [
2255
+ /* @__PURE__ */ jsx(PersonAvatar, { name: m.name, size: "xs" }),
2256
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: m.name })
2257
+ ] }, m.userId))
2258
+ ] })
2259
+ },
2260
+ {
2261
+ id: "period",
2262
+ label: t2("crm.filters.period"),
2263
+ icon: CalendarDays,
2264
+ activeCount: period !== "all" ? 1 : 0,
2265
+ render: (close) => /* @__PURE__ */ jsxs(Fragment, { children: [
2266
+ ["all", "24h", "7d", "custom"].map((p) => /* @__PURE__ */ jsx(FilterMenuRow, { active: period === p, onClick: () => {
2267
+ setPeriod(p);
2268
+ if (p !== "custom") close();
2269
+ }, children: t2(`crm.filters.period${p === "all" ? "All" : p === "custom" ? "Custom" : p}`) }, p)),
2270
+ period === "custom" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 p-1.5", children: [
2271
+ /* @__PURE__ */ jsx(DatePicker, { variant: "chip", format: "numeric", className: "w-full", value: customFrom, onChange: setCustomFrom }),
2272
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "\u2013" }),
2273
+ /* @__PURE__ */ jsx(DatePicker, { variant: "chip", format: "numeric", className: "w-full", value: customTo, onChange: setCustomTo })
2274
+ ] })
2275
+ ] })
2276
+ },
2277
+ {
2278
+ id: "tags",
2279
+ label: t2("crm.leads.filters.tag"),
2280
+ icon: Tag,
2281
+ activeCount: selectedTags.length,
2282
+ 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) => {
2283
+ const on = selectedTags.includes(slug);
2284
+ return /* @__PURE__ */ jsxs(
2285
+ FilterMenuRow,
2286
+ {
2287
+ active: on,
2288
+ onClick: () => setSelectedTags(on ? selectedTags.filter((s) => s !== slug) : [...selectedTags, slug]),
2289
+ children: [
2290
+ /* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full", style: { backgroundColor: tagDefs.get(slug)?.color ?? "#94A3B8" } }),
2291
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: tagDefs.get(slug)?.name ?? humanizeTag(slug) })
2292
+ ]
2293
+ },
2294
+ slug
2295
+ );
2296
+ }) })
2297
+ }
2298
+ ]
2299
+ }
2300
+ ),
2301
+ /* @__PURE__ */ jsx(DisplayPopover, { display, onChange: setDisplay })
2302
+ ] }) }),
2306
2303
  boardPending ? /* @__PURE__ */ jsx(PipelineSkeleton, {}) : visibleStages.length === 0 ? (
2307
2304
  /* Sem etapas não existe quadro: o `flex` abaixo renderizava uma faixa
2308
2305
  em branco, que parece uma tela que não carregou. O funil é a única
@@ -5557,11 +5554,11 @@ function readMode() {
5557
5554
  }
5558
5555
  return "board";
5559
5556
  }
5560
- function DealsView({ openDealId, onOpenDeal, onCloseDeal, onViewLead, onViewQuote, onViewCompany, onCreateQuote, onAddLead, onOpenSettings }) {
5557
+ function DealsView({ mode, onChangeMode, openDealId, onOpenDeal, onCloseDeal, onViewLead, onViewQuote, onViewCompany, onCreateQuote, onAddLead, onOpenSettings }) {
5561
5558
  const t2 = useTranslation();
5562
5559
  const provider = useCrmProvider();
5563
5560
  const isWide = useIsWide();
5564
- const [mode, setMode] = useState(readMode);
5561
+ const modo = mode ?? readMode();
5565
5562
  const pipelines = useCrmStore((s) => s.pipelines);
5566
5563
  const [openId, setOpenId] = useState(openDealId ?? null);
5567
5564
  useEffect(() => {
@@ -5603,23 +5600,10 @@ function DealsView({ openDealId, onOpenDeal, onCloseDeal, onViewLead, onViewQuot
5603
5600
  const selectPipeline = useCrmStore((s) => s.selectPipeline);
5604
5601
  useEffect(() => {
5605
5602
  try {
5606
- localStorage.setItem(STORAGE_KEY, mode);
5603
+ localStorage.setItem(STORAGE_KEY, modo);
5607
5604
  } catch {
5608
5605
  }
5609
- }, [mode]);
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
- );
5606
+ }, [modo]);
5623
5607
  return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
5624
5608
  !isWide && /* @__PURE__ */ jsx(PageHeaderActions, { children: /* @__PURE__ */ jsx(
5625
5609
  PageActions,
@@ -5660,7 +5644,7 @@ function DealsView({ openDealId, onOpenDeal, onCloseDeal, onViewLead, onViewQuot
5660
5644
  p.id
5661
5645
  );
5662
5646
  }) }),
5663
- mode === "board" && /* @__PURE__ */ jsx(
5647
+ modo === "board" && /* @__PURE__ */ jsx(
5664
5648
  PipelineView,
5665
5649
  {
5666
5650
  onDealClick: openCard,
@@ -5669,35 +5653,22 @@ function DealsView({ openDealId, onOpenDeal, onCloseDeal, onViewLead, onViewQuot
5669
5653
  onStageIntent: (deal, stage) => {
5670
5654
  setPendingStage(stage);
5671
5655
  openCard(deal.id);
5672
- },
5673
- modeControl
5656
+ }
5674
5657
  }
5675
5658
  ),
5676
- mode === "list" && /* @__PURE__ */ jsxs(Fragment, { children: [
5677
- /* @__PURE__ */ jsxs(PageViewBar, { children: [
5678
- /* @__PURE__ */ jsx("div", { className: "min-w-0", children: modeControl }),
5679
- /* @__PURE__ */ jsx("span", {})
5680
- ] }),
5681
- /* @__PURE__ */ jsx(DealListView, { onOpenDeal: openCard })
5682
- ] }),
5683
- mode === "funnel" && /* @__PURE__ */ jsxs(Fragment, { children: [
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");
5659
+ modo === "list" && /* @__PURE__ */ jsx(DealListView, { onOpenDeal: openCard }),
5660
+ modo === "funnel" && /* @__PURE__ */ jsx(
5661
+ DealFunnelView,
5662
+ {
5663
+ onStageClick: (stageId) => {
5664
+ try {
5665
+ sessionStorage.setItem("fayz.list.crm.deals.stage", JSON.stringify(stageId));
5666
+ } catch {
5697
5667
  }
5668
+ onChangeMode?.("list");
5698
5669
  }
5699
- )
5700
- ] }),
5670
+ }
5671
+ ),
5701
5672
  novoLead && /* @__PURE__ */ jsx(LeadFormView, { onSaved: (id) => {
5702
5673
  setNovoLead(false);
5703
5674
  if (!id) return;
@@ -5730,6 +5701,189 @@ function DealsView({ openDealId, onOpenDeal, onCloseDeal, onViewLead, onViewQuot
5730
5701
  )
5731
5702
  ] });
5732
5703
  }
5704
+ function UnitGoalsView() {
5705
+ return /* @__PURE__ */ jsx(
5706
+ ComingSoon,
5707
+ {
5708
+ title: "Metas das unidades",
5709
+ 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.",
5710
+ v1Path: "CRM \u2192 Metas \u2192 Metas das Unidades",
5711
+ measured: "11 metas de unidade no V1 inteiro, nenhuma da Artorius.",
5712
+ missing: [
5713
+ "A meta por unidade e por m\xEAs, com o realizado ao lado",
5714
+ "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"
5715
+ ]
5716
+ }
5717
+ );
5718
+ }
5719
+ function KpiGoalsView() {
5720
+ return /* @__PURE__ */ jsx(
5721
+ ComingSoon,
5722
+ {
5723
+ title: "Metas por indicador",
5724
+ summary: "A meta que n\xE3o \xE9 de faturamento: ticket m\xE9dio, taxa de retorno, n\xFAmero de atendimentos.",
5725
+ v1Path: "CRM \u2192 Metas \u2192 Metas por Indicador",
5726
+ 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.",
5727
+ missing: [
5728
+ "O cat\xE1logo de indicadores, que \xE9 a parte dif\xEDcil: cada um tem uma conta pr\xF3pria",
5729
+ "Sem isso, a tela \xE9 um formul\xE1rio para um n\xFAmero que ningu\xE9m compara com nada"
5730
+ ]
5731
+ }
5732
+ );
5733
+ }
5734
+ function ProfessionalGoalsView() {
5735
+ return /* @__PURE__ */ jsx(
5736
+ ComingSoon,
5737
+ {
5738
+ title: "Metas por profissional",
5739
+ summary: "Quanto cada pessoa da equipe precisa vender \u2014 e o que ela j\xE1 vendeu no per\xEDodo.",
5740
+ v1Path: "CRM \u2192 Metas \u2192 Metas Profissionais",
5741
+ measured: "4 metas no V1 inteiro, nenhuma da Artorius.",
5742
+ missing: [
5743
+ "A meta por pessoa e per\xEDodo, lendo o realizado das vendas",
5744
+ "Liga-se \xE0 comiss\xE3o: quem bate meta costuma ter regra diferente"
5745
+ ]
5746
+ }
5747
+ );
5748
+ }
5749
+ function FranchisorGoalsView() {
5750
+ return /* @__PURE__ */ jsx(
5751
+ ComingSoon,
5752
+ {
5753
+ title: "Metas do franqueador",
5754
+ summary: "A meta que a rede define para as unidades, vista de cima: quem bateu, quem n\xE3o bateu, e o consolidado.",
5755
+ v1Path: "CRM \u2192 Metas \u2192 Metas do Franqueador",
5756
+ measured: "1 meta em todo o V1. \xC9 tela de rede, e a Artorius \xE9 uma casa s\xF3.",
5757
+ missing: [
5758
+ "S\xF3 faz sentido com o escopo de rede resolvido \u2014 a unidade \xE9 o alcance que a RLS usa",
5759
+ "Depende de Metas das unidades existir primeiro"
5760
+ ]
5761
+ }
5762
+ );
5763
+ }
5764
+ function TasksView() {
5765
+ return /* @__PURE__ */ jsx(
5766
+ ComingSoon,
5767
+ {
5768
+ title: "Tarefas",
5769
+ 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.",
5770
+ v1Path: "CRM \u2192 Engajamento \u2192 Tarefas",
5771
+ measured: "1 tarefa em todo o V1. A tela existe l\xE1 e praticamente n\xE3o foi usada.",
5772
+ missing: [
5773
+ "A tarefa ligada ao lead ou ao neg\xF3cio, n\xE3o solta \u2014 \xE9 isso que a torna \xFAtil",
5774
+ "Atividades (que j\xE1 existe aqui) REGISTRA o que aconteceu; a tarefa \xE9 o que ainda vai acontecer",
5775
+ "O atraso tem de aparecer sozinho, sen\xE3o a lista vira arquivo"
5776
+ ]
5777
+ }
5778
+ );
5779
+ }
5780
+ function FollowUpsView() {
5781
+ return /* @__PURE__ */ jsx(
5782
+ ComingSoon,
5783
+ {
5784
+ title: "Follow-ups",
5785
+ summary: "Os retornos combinados que est\xE3o vencendo: quem prometeu voltar a falar com quem, e quando.",
5786
+ v1Path: "CRM \u2192 Engajamento \u2192 Follow-ups",
5787
+ measured: "Vista de leitura no V1 \u2014 recorta as mesmas tarefas por data. Sem tarefa, n\xE3o h\xE1 follow-up.",
5788
+ missing: [
5789
+ "Depende de Tarefas existir: \xE9 o mesmo dado visto pela data",
5790
+ "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"
5791
+ ]
5792
+ }
5793
+ );
5794
+ }
5795
+ function LoyaltyView() {
5796
+ return /* @__PURE__ */ jsx(
5797
+ ComingSoon,
5798
+ {
5799
+ title: "Clube de fidelidade",
5800
+ summary: "As regras do clube \u2014 quanto vale cada real gasto, o que o ponto compra, quando expira \u2014 e quem est\xE1 dentro.",
5801
+ v1Path: "CRM \u2192 Fideliza\xE7\xE3o \u2192 Programa de Fidelidade",
5802
+ measured: "1 programa cadastrado no V1 e ZERO membros (`loyalty_members` vazia). O clube existe no papel e n\xE3o tem s\xF3cio.",
5803
+ missing: [
5804
+ "As regras de ac\xFAmulo e de resgate, que \xE9 onde o programa vira ou n\xE3o vira dinheiro",
5805
+ "O saldo por cliente e o extrato dele \u2014 sem extrato, ningu\xE9m confia no saldo",
5806
+ "Antes de construir: 1 programa e 0 membros diz que a vers\xE3o do V1 n\xE3o convenceu ningu\xE9m"
5807
+ ]
5808
+ }
5809
+ );
5810
+ }
5811
+ function ReferralsView() {
5812
+ return /* @__PURE__ */ jsx(
5813
+ ComingSoon,
5814
+ {
5815
+ title: "Indica\xE7\xF5es",
5816
+ summary: "Quem trouxe quem \u2014 e o que o indicador ganha por isso.",
5817
+ v1Path: "CRM \u2192 Fideliza\xE7\xE3o \u2192 Indica\xE7\xF5es",
5818
+ 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.",
5819
+ missing: [
5820
+ "Registrar a indica\xE7\xE3o no cadastro \xE9 f\xE1cil; PAGAR por ela \xE9 o que falta",
5821
+ "A recompensa liga isto ao Financeiro (cr\xE9dito) ou ao clube (pontos) \u2014 decidir qual antes"
5822
+ ]
5823
+ }
5824
+ );
5825
+ }
5826
+ function BirthdaysView() {
5827
+ return /* @__PURE__ */ jsx(
5828
+ ComingSoon,
5829
+ {
5830
+ title: "Aniversariantes",
5831
+ summary: "Quem faz anivers\xE1rio nos pr\xF3ximos dias, para a casa fazer alguma coisa a respeito.",
5832
+ v1Path: "CRM \u2192 Fideliza\xE7\xE3o \u2192 Aniversariantes",
5833
+ measured: "Vista de leitura no V1 \u2014 recorta a data de nascimento da ficha do cliente. O dado j\xE1 atravessou para c\xE1.",
5834
+ missing: [
5835
+ "\xC9 um recorte da base de clientes, n\xE3o um cadastro novo \u2014 a tela mais barata desta lista",
5836
+ "O valor est\xE1 em disparar a mensagem a partir dela; sozinha \xE9 uma lista que algu\xE9m tem de lembrar de abrir",
5837
+ "Com o Marketing ao lado no mesmo menu, virar campanha recorrente \xE9 o caminho natural"
5838
+ ]
5839
+ }
5840
+ );
5841
+ }
5842
+ function PendingReturnsView() {
5843
+ return /* @__PURE__ */ jsx(
5844
+ ComingSoon,
5845
+ {
5846
+ title: "Retornos pendentes",
5847
+ summary: "O cliente que costumava vir e parou: quem est\xE1 atrasado em rela\xE7\xE3o ao pr\xF3prio h\xE1bito.",
5848
+ v1Path: "CRM \u2192 Retornos Pendentes",
5849
+ 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.",
5850
+ missing: [
5851
+ "O c\xE1lculo do intervalo esperado POR CLIENTE \u2014 a m\xE9dia da casa acusa todo mundo ou ningu\xE9m",
5852
+ "\xC9 a tela que mais gera receita desta lista numa casa de servi\xE7o, e a que menos serve numa de compras"
5853
+ ]
5854
+ }
5855
+ );
5856
+ }
5857
+ function OperationalDashboardView() {
5858
+ return /* @__PURE__ */ jsx(
5859
+ ComingSoon,
5860
+ {
5861
+ title: "Painel operacional",
5862
+ summary: "O dia da opera\xE7\xE3o num quadro: agenda ocupada, atendimentos, ticket, o que est\xE1 atrasado.",
5863
+ v1Path: "CRM \u2192 Dashboard Operacional",
5864
+ measured: "Vista de leitura no V1, montada sobre agendamentos e faturas. Sem venda pelo sistema n\xE3o tem o que mostrar.",
5865
+ missing: [
5866
+ "Definir os cinco n\xFAmeros que importam antes de desenhar \u2014 um painel com vinte cart\xF5es n\xE3o \xE9 lido",
5867
+ "O Resumo do CRM j\xE1 responde parte disto; decidir se s\xE3o duas telas ou uma"
5868
+ ]
5869
+ }
5870
+ );
5871
+ }
5872
+ function MaturityView() {
5873
+ return /* @__PURE__ */ jsx(
5874
+ ComingSoon,
5875
+ {
5876
+ title: "Maturidade operacional",
5877
+ 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.",
5878
+ v1Path: "CRM \u2192 Maturidade Operacional",
5879
+ measured: "Vista de leitura no V1 \u2014 pontua a conta contra uma lista de checagens.",
5880
+ missing: [
5881
+ "A lista de checagens \xE9 a tela: sem ela combinada, a nota n\xE3o quer dizer nada",
5882
+ "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"
5883
+ ]
5884
+ }
5885
+ );
5886
+ }
5733
5887
  var LEAD_STATUS_OPTIONS = [
5734
5888
  { value: "new", labelKey: "crm.leads.statusNew", dot: "#3B82F6" },
5735
5889
  { value: "contacted", labelKey: "crm.leads.statusContacted", dot: "#8B5CF6" },
@@ -6498,6 +6652,7 @@ function LeadListView({ onNew, onEdit }) {
6498
6652
  )
6499
6653
  ] });
6500
6654
  }
6655
+ var QUOTE_STATUSES = ["draft", "sent", "approved", "rejected", "expired", "archived"];
6501
6656
  var STATUS_COLORS = {
6502
6657
  draft: "bg-muted text-muted-foreground",
6503
6658
  sent: "bg-info-soft text-info-soft-foreground",
@@ -6526,7 +6681,7 @@ function useQuoteColumns(currency, onEditQuote, onArchive) {
6526
6681
  header: t2("crm.quotes.status"),
6527
6682
  cell: ({ getValue }) => {
6528
6683
  const status = getValue();
6529
- return /* @__PURE__ */ jsx("span", { className: `inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium capitalize ${STATUS_COLORS[status] ?? "bg-muted text-muted-foreground"}`, children: status });
6684
+ 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
6685
  }
6531
6686
  }
6532
6687
  ];
@@ -6576,9 +6731,50 @@ function QuoteListView({ onNew, onEdit, onEditQuote }) {
6576
6731
  const fetchQuotes = useCrmStore((s) => s.fetchQuotes);
6577
6732
  const archiveQuote = useCrmStore((s) => s.archiveQuote);
6578
6733
  const canArchive = useCanArchive();
6579
- useEffect(() => {
6580
- fetchQuotes({});
6734
+ const hoje = () => {
6735
+ const d = /* @__PURE__ */ new Date();
6736
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
6737
+ };
6738
+ const noventaDiasAtras = useMemo(() => {
6739
+ const d = /* @__PURE__ */ new Date();
6740
+ d.setDate(d.getDate() - 89);
6741
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
6581
6742
  }, []);
6743
+ const [dateFrom, setDateFrom] = useState(noventaDiasAtras);
6744
+ const [dateTo, setDateTo] = useState(hoje);
6745
+ const [statusFilter, setStatusFilter] = useState([]);
6746
+ const [contactId, setContactId] = useState("");
6747
+ const [contactName, setContactName] = useState("");
6748
+ const [search, setSearch] = useState("");
6749
+ const contactLookup = useMemo(
6750
+ () => createArchetypeLookup({ archetype: "person", kind: ["customer", "lead"] }),
6751
+ []
6752
+ );
6753
+ const rascunho = useMemo(
6754
+ () => ({ from: dateFrom, to: dateTo, status: statusFilter, contactId, search: search.trim() }),
6755
+ [dateFrom, dateTo, statusFilter, contactId, search]
6756
+ );
6757
+ const [emVigor, setEmVigor] = useState(rascunho);
6758
+ const filtrosPendentes = useMemo(
6759
+ () => JSON.stringify(rascunho) !== JSON.stringify(emVigor),
6760
+ [rascunho, emVigor]
6761
+ );
6762
+ const aplicarFiltros = useCallback(() => setEmVigor(() => rascunho), [rascunho]);
6763
+ const limparFiltros = () => {
6764
+ setStatusFilter([]);
6765
+ setContactId("");
6766
+ setContactName("");
6767
+ setSearch("");
6768
+ };
6769
+ const filtrosAtivos = (statusFilter.length > 0 ? 1 : 0) + (contactId ? 1 : 0) + (search.trim() ? 1 : 0);
6770
+ useEffect(() => {
6771
+ fetchQuotes({
6772
+ dateRange: { from: emVigor.from, to: emVigor.to },
6773
+ status: emVigor.status.length > 0 ? emVigor.status : void 0,
6774
+ contactId: emVigor.contactId || void 0,
6775
+ search: emVigor.search || void 0
6776
+ });
6777
+ }, [emVigor]);
6582
6778
  const [alvoArquivo, setAlvoArquivo] = useState(null);
6583
6779
  const columns = useQuoteColumns(currency, onEditQuote, canArchive ? setAlvoArquivo : void 0);
6584
6780
  const exportRows = useCallback(() => {
@@ -6615,6 +6811,89 @@ function QuoteListView({ onNew, onEdit, onEditQuote }) {
6615
6811
  ) })
6616
6812
  }
6617
6813
  ),
6814
+ /* @__PURE__ */ jsxs(
6815
+ FilterPanel,
6816
+ {
6817
+ title: t2("crm.quotes.filtersTitle"),
6818
+ dirty: filtrosPendentes,
6819
+ onApply: aplicarFiltros,
6820
+ applyLabel: t2("crm.quotes.filterApply"),
6821
+ pendingTitle: t2("crm.quotes.filterPending"),
6822
+ pendingHint: t2("crm.quotes.filterPendingHint"),
6823
+ onClear: filtrosAtivos > 0 ? limparFiltros : void 0,
6824
+ clearLabel: t2("crm.quotes.filterClear"),
6825
+ busy: quotesLoading,
6826
+ children: [
6827
+ /* @__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) }) }),
6828
+ /* @__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) }) }),
6829
+ /* @__PURE__ */ jsx(FilterPanelField, { label: t2("crm.quotes.status"), children: /* @__PURE__ */ jsx(
6830
+ RequiredFilter,
6831
+ {
6832
+ label: t2("crm.quotes.status"),
6833
+ value: statusFilter.length === 0 ? t2("crm.quotes.filterAllStatuses") : statusFilter.length === 1 ? t2(`crm.quotes.status.${statusFilter[0]}`) : t2("crud.list.selectedMany", { count: statusFilter.length }),
6834
+ icon: CircleDashed,
6835
+ className: "h-9 w-full justify-start",
6836
+ align: "start",
6837
+ children: /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
6838
+ /* @__PURE__ */ jsx(FilterMenuRow, { active: statusFilter.length === 0, onClick: () => setStatusFilter([]), children: t2("crm.quotes.filterAllStatuses") }),
6839
+ QUOTE_STATUSES.map((st) => {
6840
+ const on = statusFilter.includes(st);
6841
+ return /* @__PURE__ */ jsx(
6842
+ FilterMenuRow,
6843
+ {
6844
+ active: on,
6845
+ onClick: () => setStatusFilter(on ? statusFilter.filter((v) => v !== st) : [...statusFilter, st]),
6846
+ children: /* @__PURE__ */ jsx("span", { className: "truncate", children: t2(`crm.quotes.status.${st}`) })
6847
+ },
6848
+ st
6849
+ );
6850
+ })
6851
+ ] })
6852
+ }
6853
+ ) }),
6854
+ /* @__PURE__ */ jsx(FilterPanelField, { label: t2("crm.quotes.contact"), compact: true, children: /* @__PURE__ */ jsx(
6855
+ SearchSelect,
6856
+ {
6857
+ className: "w-full",
6858
+ value: contactId,
6859
+ displayValue: contactName,
6860
+ placeholder: t2("crm.quotes.filterContactPlaceholder"),
6861
+ minChars: 2,
6862
+ minCharsLabel: t2("crm.quotes.filterMinChars"),
6863
+ noResultsLabel: t2("crm.quotes.filterNoContact"),
6864
+ searchingLabel: t2("crm.quotes.filterSearching"),
6865
+ loadOnOpen: false,
6866
+ clearLabel: t2("crm.quotes.filterAllContacts"),
6867
+ onChange: (id, option) => {
6868
+ setContactId(id);
6869
+ setContactName(option?.label ?? "");
6870
+ },
6871
+ onSearch: async (termo) => {
6872
+ const results = await contactLookup.search(termo);
6873
+ return results.map((r) => ({ id: r.id, label: r.label, subtitle: r.subtitle, group: r.group, data: r }));
6874
+ }
6875
+ }
6876
+ ) })
6877
+ ]
6878
+ }
6879
+ ),
6880
+ /* @__PURE__ */ jsxs(Card, { className: "relative px-3 py-1.5", children: [
6881
+ /* @__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" }),
6882
+ /* @__PURE__ */ jsx(
6883
+ "input",
6884
+ {
6885
+ type: "text",
6886
+ value: search,
6887
+ onChange: (e) => setSearch(e.target.value),
6888
+ onKeyDown: (e) => {
6889
+ if (e.key === "Enter") aplicarFiltros();
6890
+ },
6891
+ placeholder: t2("crm.quotes.searchPlaceholder"),
6892
+ "aria-label": t2("crm.quotes.searchPlaceholder"),
6893
+ className: "w-full bg-transparent py-1.5 pl-8 pr-3 text-sm placeholder:text-muted-foreground focus:outline-none"
6894
+ }
6895
+ )
6896
+ ] }),
6618
6897
  /* @__PURE__ */ jsx(
6619
6898
  DataTable,
6620
6899
  {
@@ -10793,10 +11072,32 @@ function buildNav(config, view, navigate, hasAutomations, surveysLabel, networkL
10793
11072
  { id: "dashboard", label: config.labels.dashboard ?? t2("crm.nav.dashboard"), icon: "BarChart3", active: view === "dashboard", onClick: () => navigate("dashboard") }
10794
11073
  ];
10795
11074
  if (config.modules.pipeline) {
10796
- items.push({ id: "pipeline", label: config.labels.pipeline ?? t2("crm.deals.title"), icon: "Filter", active: view === "pipeline" || view.startsWith("pipeline-detail"), onClick: () => navigate("pipeline") });
11075
+ items.push({
11076
+ id: "pipeline",
11077
+ label: config.labels.pipeline ?? t2("crm.deals.title"),
11078
+ icon: "Filter",
11079
+ active: view.startsWith("pipeline"),
11080
+ children: [
11081
+ { id: "pipeline", label: t2("crm.deals.viewBoard"), defaultChild: true, active: view === "pipeline" || view.startsWith("pipeline-detail"), onClick: () => navigate("pipeline") },
11082
+ { id: "pipeline-list", label: t2("crm.deals.viewList"), active: view === "pipeline-list", onClick: () => navigate("pipeline-list") },
11083
+ { id: "pipeline-funnel", label: t2("crm.deals.viewFunnel"), active: view === "pipeline-funnel", onClick: () => navigate("pipeline-funnel") }
11084
+ ]
11085
+ });
10797
11086
  }
10798
11087
  if (flat) {
10799
- items.push({ id: "leads", label: config.labels.leads ?? t2("crm.leads.title"), icon: "UserPlus", active: view.startsWith("leads-") || view.startsWith("companies-") || view === "company-groups", onClick: () => navigate("leads-list") });
11088
+ items.push({
11089
+ id: "leads",
11090
+ label: config.labels.leads ?? t2("crm.leads.title"),
11091
+ icon: "UserPlus",
11092
+ active: view.startsWith("leads-") || view.startsWith("companies-") || view === "company-groups",
11093
+ children: [
11094
+ { 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") },
11095
+ ...config.modules.companies ? [
11096
+ { 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") },
11097
+ { id: "company-groups", label: config.labels.groups ?? t2("crm.groups.title"), active: view === "company-groups", onClick: () => navigate("company-groups") }
11098
+ ] : []
11099
+ ]
11100
+ });
10800
11101
  } else {
10801
11102
  items.push({
10802
11103
  id: "leads",
@@ -10850,9 +11151,50 @@ function buildNav(config, view, navigate, hasAutomations, surveysLabel, networkL
10850
11151
  ]
10851
11152
  });
10852
11153
  }
10853
- if (config.modules.activities) {
10854
- items.push({ id: "activities", label: config.labels.activities ?? t2("crm.activities.title"), icon: "MessageCircle", active: view === "activities", onClick: () => navigate("activities") });
10855
- }
11154
+ items.push({
11155
+ id: "engagement",
11156
+ label: t2("crm.engagement.title"),
11157
+ icon: "Clock",
11158
+ active: view === "tasks" || view === "follow-ups",
11159
+ children: [
11160
+ { id: "tasks", label: t2("crm.engagement.tasks"), defaultChild: true, active: view === "tasks", onClick: () => navigate("tasks") },
11161
+ { id: "follow-ups", label: t2("crm.engagement.followUps"), active: view === "follow-ups", onClick: () => navigate("follow-ups") }
11162
+ ]
11163
+ });
11164
+ items.push({
11165
+ id: "retention",
11166
+ label: t2("crm.retention.title"),
11167
+ icon: "Gift",
11168
+ active: ["loyalty", "referrals", "birthdays", "pending-returns"].includes(view),
11169
+ children: [
11170
+ { id: "loyalty", label: t2("crm.retention.loyalty"), defaultChild: true, active: view === "loyalty", onClick: () => navigate("loyalty") },
11171
+ { id: "referrals", label: t2("crm.retention.referrals"), active: view === "referrals", onClick: () => navigate("referrals") },
11172
+ { id: "birthdays", label: t2("crm.retention.birthdays"), active: view === "birthdays", onClick: () => navigate("birthdays") },
11173
+ { id: "pending-returns", label: t2("crm.retention.pendingReturns"), active: view === "pending-returns", onClick: () => navigate("pending-returns") }
11174
+ ]
11175
+ });
11176
+ items.push({
11177
+ id: "goals",
11178
+ label: t2("crm.goals.title"),
11179
+ icon: "Target",
11180
+ active: ["goals-units", "goals-kpi", "goals-professionals", "goals-franchisor"].includes(view),
11181
+ children: [
11182
+ { id: "goals-units", label: t2("crm.goals.units"), defaultChild: true, active: view === "goals-units", onClick: () => navigate("goals-units") },
11183
+ { id: "goals-kpi", label: t2("crm.goals.kpi"), active: view === "goals-kpi", onClick: () => navigate("goals-kpi") },
11184
+ { id: "goals-professionals", label: t2("crm.goals.professionals"), active: view === "goals-professionals", onClick: () => navigate("goals-professionals") },
11185
+ { id: "goals-franchisor", label: t2("crm.goals.franchisor"), active: view === "goals-franchisor", onClick: () => navigate("goals-franchisor") }
11186
+ ]
11187
+ });
11188
+ items.push({
11189
+ id: "panels",
11190
+ label: t2("crm.panels.title"),
11191
+ icon: "LayoutDashboard",
11192
+ active: view === "operational-dashboard" || view === "maturity",
11193
+ children: [
11194
+ { id: "operational-dashboard", label: t2("crm.panels.operational"), defaultChild: true, active: view === "operational-dashboard", onClick: () => navigate("operational-dashboard") },
11195
+ { id: "maturity", label: t2("crm.panels.maturity"), active: view === "maturity", onClick: () => navigate("maturity") }
11196
+ ]
11197
+ });
10856
11198
  if (config.modules.surveys) {
10857
11199
  items.push({ id: "surveys", label: surveysLabel, icon: "Star", active: view === "surveys", onClick: () => navigate("surveys") });
10858
11200
  }
@@ -10897,7 +11239,6 @@ function CrmPage({ config, provider, store, registries }) {
10897
11239
  const onboarding = usePluginOnboardingGate("saas-core:crm-onboarded", checkExistingData);
10898
11240
  const isSettings = view === "settings";
10899
11241
  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
11242
  const openStageSettings = () => adminNavigateTo("/settings/crm/_properties/stages");
10902
11243
  const runtime = usePluginRuntimeOptional();
10903
11244
  const hasAutomations = Boolean(runtime?.activePlugins.some((p) => p.id === "automations"));
@@ -10907,8 +11248,7 @@ function CrmPage({ config, provider, store, registries }) {
10907
11248
  const quickActions = useMemo(() => [
10908
11249
  { id: "new-lead", label: t2("crm.quickActions.newLead"), icon: "UserPlus", description: t2("crm.quickActions.newLeadDesc"), action: () => navigate("leads-new") },
10909
11250
  { 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") }] : []
11251
+ ...config.modules.quotes ? [{ id: "new-quote", label: t2("crm.quickActions.newQuote"), icon: "FileText", description: t2("crm.quickActions.newQuoteDesc"), action: () => navigate("quotes-new") }] : []
10912
11252
  ], [config.modules]);
10913
11253
  if (isSummary && onboarding.status === "checking") {
10914
11254
  return /* @__PURE__ */ jsx(CrmContextProvider, { config, provider, store, children: /* @__PURE__ */ jsx(PluginOnboardingGateSkeleton, {}) });
@@ -10929,11 +11269,13 @@ function CrmPage({ config, provider, store, registries }) {
10929
11269
  // O funil e o funil COM UM CARD ABERTO são a mesma view: só muda a prop.
10930
11270
  // Assim a URL carrega o id (`/sales/pipeline/<id>` — um link que o colega
10931
11271
  // abre no card certo) sem que o quadro desmonte a cada card aberto.
10932
- ...["pipeline", "pipeline-detail"].map((id) => ({
11272
+ ...["pipeline", "pipeline-detail", "pipeline-list", "pipeline-funnel"].map((id) => ({
10933
11273
  id,
10934
11274
  render: ({ id: dealId }) => /* @__PURE__ */ jsx(
10935
11275
  DealsView,
10936
11276
  {
11277
+ mode: id === "pipeline-list" ? "list" : id === "pipeline-funnel" ? "funnel" : "board",
11278
+ onChangeMode: (m) => navigate(m === "list" ? "pipeline-list" : m === "funnel" ? "pipeline-funnel" : "pipeline"),
10937
11279
  openDealId: dealId,
10938
11280
  onOpenDeal: (did) => navigate(`pipeline-detail:${did}`),
10939
11281
  onCloseDeal: () => navigate("pipeline"),
@@ -10985,11 +11327,24 @@ function CrmPage({ config, provider, store, registries }) {
10985
11327
  onOpenDeal: (did) => navigate(`pipeline-detail:${did}`, `/sales/pipeline/${did}`)
10986
11328
  }
10987
11329
  ) },
11330
+ // As telas que ainda não existem — ver ./GapScreens.
11331
+ { id: "tasks", render: () => /* @__PURE__ */ jsx(TasksView, {}) },
11332
+ { id: "follow-ups", render: () => /* @__PURE__ */ jsx(FollowUpsView, {}) },
11333
+ { id: "loyalty", render: () => /* @__PURE__ */ jsx(LoyaltyView, {}) },
11334
+ { id: "referrals", render: () => /* @__PURE__ */ jsx(ReferralsView, {}) },
11335
+ { id: "birthdays", render: () => /* @__PURE__ */ jsx(BirthdaysView, {}) },
11336
+ { id: "pending-returns", render: () => /* @__PURE__ */ jsx(PendingReturnsView, {}) },
11337
+ { id: "goals-units", render: () => /* @__PURE__ */ jsx(UnitGoalsView, {}) },
11338
+ { id: "goals-kpi", render: () => /* @__PURE__ */ jsx(KpiGoalsView, {}) },
11339
+ { id: "goals-professionals", render: () => /* @__PURE__ */ jsx(ProfessionalGoalsView, {}) },
11340
+ { id: "goals-franchisor", render: () => /* @__PURE__ */ jsx(FranchisorGoalsView, {}) },
11341
+ { id: "operational-dashboard", render: () => /* @__PURE__ */ jsx(OperationalDashboardView, {}) },
11342
+ { id: "maturity", render: () => /* @__PURE__ */ jsx(MaturityView, {}) },
10988
11343
  { id: "surveys", render: () => /* @__PURE__ */ jsx(SurveysView, {}) },
10989
11344
  { id: "network", render: () => /* @__PURE__ */ jsx(NetworkView, {}) },
10990
11345
  { id: "dashboard", render: () => /* @__PURE__ */ jsx(DashboardView, {}) }
10991
11346
  ], "dashboard");
10992
- return /* @__PURE__ */ jsx(CrmContextProvider, { config, provider, store, children: /* @__PURE__ */ jsxs(
11347
+ return /* @__PURE__ */ jsx(CrmContextProvider, { config, provider, store, children: /* @__PURE__ */ jsx(
10993
11348
  ModulePage,
10994
11349
  {
10995
11350
  title: config.labels.pageTitle,
@@ -11006,24 +11361,7 @@ function CrmPage({ config, provider, store, registries }) {
11006
11361
  settingsPath: registries && registries.length > 0 ? "/settings/crm" : void 0
11007
11362
  }
11008
11363
  ),
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
- ]
11364
+ children: renderView(view)
11027
11365
  }
11028
11366
  ) });
11029
11367
  }
@@ -12014,6 +12352,9 @@ function createMockCrmProvider(options) {
12014
12352
  results = results.filter((q) => statuses.includes(q.status));
12015
12353
  }
12016
12354
  if (query.contactId) results = results.filter((q) => q.contactId === query.contactId);
12355
+ if (query.dateRange) {
12356
+ results = results.filter((q) => q.quoteDate >= query.dateRange.from && q.quoteDate <= query.dateRange.to);
12357
+ }
12017
12358
  if (query.search) {
12018
12359
  const s = query.search.toLowerCase();
12019
12360
  results = results.filter((q) => q.quoteNumber.includes(s) || q.contactName?.toLowerCase().includes(s));
@@ -13690,6 +14031,10 @@ function createSupabaseCrmProvider(options) {
13690
14031
  qb = qb.neq("status", "archived");
13691
14032
  }
13692
14033
  if (query.search) qb = qb.or(`number.ilike.%${query.search}%,notes.ilike.%${query.search}%`);
14034
+ if (query.contactId) qb = qb.eq("party_id", query.contactId);
14035
+ if (query.dateRange) {
14036
+ qb = qb.gte("created_at", query.dateRange.from).lte("created_at", `${query.dateRange.to}T23:59:59.999`);
14037
+ }
13693
14038
  const page = query.page ?? 1;
13694
14039
  const pageSize = query.pageSize ?? 50;
13695
14040
  qb = qb.range((page - 1) * pageSize, page * pageSize - 1).order("created_at", { ascending: false });
@@ -30214,6 +30559,22 @@ var en = {
30214
30559
  "crm.board.prop.value": "Value",
30215
30560
  "crm.board.prop.age": "Age",
30216
30561
  "crm.deals.switchView": "Switch deals view",
30562
+ "crm.engagement.title": "Engagement",
30563
+ "crm.engagement.tasks": "Tasks",
30564
+ "crm.engagement.followUps": "Follow-ups",
30565
+ "crm.retention.title": "Retention",
30566
+ "crm.retention.loyalty": "Loyalty Club",
30567
+ "crm.retention.referrals": "Referrals",
30568
+ "crm.retention.birthdays": "Birthdays",
30569
+ "crm.retention.pendingReturns": "Pending Returns",
30570
+ "crm.goals.title": "Goals",
30571
+ "crm.goals.units": "Units",
30572
+ "crm.goals.kpi": "Indicators",
30573
+ "crm.goals.professionals": "Professionals",
30574
+ "crm.goals.franchisor": "Franchisor",
30575
+ "crm.panels.title": "Panels",
30576
+ "crm.panels.operational": "Operational",
30577
+ "crm.panels.maturity": "Maturity",
30217
30578
  "crm.deals.viewBoard": "Board",
30218
30579
  "crm.deals.viewList": "List",
30219
30580
  "crm.deals.viewFunnel": "Conversion",
@@ -30416,6 +30777,26 @@ var en = {
30416
30777
  "crm.quoteForm.validOneWeek": "1 week",
30417
30778
  "crm.quoteForm.validThirtyDays": "30 days",
30418
30779
  "crm.quoteForm.validUntil": "Valid Until",
30780
+ "crm.quotes.filtersTitle": "Filters",
30781
+ "crm.quotes.filterApply": "Search",
30782
+ "crm.quotes.filterClear": "Clear",
30783
+ "crm.quotes.filterPending": "Filters changed",
30784
+ "crm.quotes.filterPendingHint": "The list still shows the previous selection. Click Search to apply.",
30785
+ "crm.quotes.filterFrom": "From",
30786
+ "crm.quotes.filterTo": "To",
30787
+ "crm.quotes.filterAllStatuses": "All",
30788
+ "crm.quotes.filterAllContacts": "All",
30789
+ "crm.quotes.filterContactPlaceholder": "Type...",
30790
+ "crm.quotes.filterMinChars": "Type at least 2 characters to search.",
30791
+ "crm.quotes.filterNoContact": "No record found.",
30792
+ "crm.quotes.filterSearching": "Searching records...",
30793
+ "crm.quotes.searchPlaceholder": "Search by number or notes...",
30794
+ "crm.quotes.status.draft": "Draft",
30795
+ "crm.quotes.status.sent": "Sent",
30796
+ "crm.quotes.status.approved": "Approved",
30797
+ "crm.quotes.status.rejected": "Rejected",
30798
+ "crm.quotes.status.expired": "Expired",
30799
+ "crm.quotes.status.archived": "Archived",
30419
30800
  "crm.quotes.amount": "Amount",
30420
30801
  "crm.quotes.archive": "Archive",
30421
30802
  "crm.quotes.archiveTitle": "Archive this quote?",
@@ -31119,7 +31500,23 @@ var ptBR = {
31119
31500
  "crm.board.prop.value": "Valor",
31120
31501
  "crm.board.prop.age": "Idade",
31121
31502
  "crm.deals.switchView": "Trocar a vis\xE3o dos neg\xF3cios",
31122
- "crm.deals.viewBoard": "Funil",
31503
+ "crm.engagement.title": "Engajamento",
31504
+ "crm.engagement.tasks": "Tarefas",
31505
+ "crm.engagement.followUps": "Follow-ups",
31506
+ "crm.retention.title": "Fideliza\xE7\xE3o",
31507
+ "crm.retention.loyalty": "Clube de Fidelidade",
31508
+ "crm.retention.referrals": "Indica\xE7\xF5es",
31509
+ "crm.retention.birthdays": "Aniversariantes",
31510
+ "crm.retention.pendingReturns": "Retornos Pendentes",
31511
+ "crm.goals.title": "Metas",
31512
+ "crm.goals.units": "Unidades",
31513
+ "crm.goals.kpi": "Indicadores",
31514
+ "crm.goals.professionals": "Profissionais",
31515
+ "crm.goals.franchisor": "Franqueador",
31516
+ "crm.panels.title": "Pain\xE9is",
31517
+ "crm.panels.operational": "Operacional",
31518
+ "crm.panels.maturity": "Maturidade",
31519
+ "crm.deals.viewBoard": "Quadro",
31123
31520
  "crm.deals.viewList": "Lista",
31124
31521
  "crm.deals.viewFunnel": "Convers\xE3o",
31125
31522
  "crm.deals.colDeal": "Neg\xF3cio",
@@ -31321,6 +31718,26 @@ var ptBR = {
31321
31718
  "crm.quoteForm.validOneWeek": "1 semana",
31322
31719
  "crm.quoteForm.validThirtyDays": "30 dias",
31323
31720
  "crm.quoteForm.validUntil": "V\xE1lido At\xE9",
31721
+ "crm.quotes.filtersTitle": "Filtros",
31722
+ "crm.quotes.filterApply": "Buscar",
31723
+ "crm.quotes.filterClear": "Limpar",
31724
+ "crm.quotes.filterPending": "Filtros alterados",
31725
+ "crm.quotes.filterPendingHint": "A lista ainda mostra o recorte anterior. Clique em Buscar para aplicar.",
31726
+ "crm.quotes.filterFrom": "De",
31727
+ "crm.quotes.filterTo": "At\xE9",
31728
+ "crm.quotes.filterAllStatuses": "Todos",
31729
+ "crm.quotes.filterAllContacts": "Todos",
31730
+ "crm.quotes.filterContactPlaceholder": "Digite...",
31731
+ "crm.quotes.filterMinChars": "Digite pelo menos 2 caracteres para buscar.",
31732
+ "crm.quotes.filterNoContact": "Nenhum cadastro encontrado.",
31733
+ "crm.quotes.filterSearching": "Buscando cadastros...",
31734
+ "crm.quotes.searchPlaceholder": "Buscar por n\xFAmero ou observa\xE7\xE3o...",
31735
+ "crm.quotes.status.draft": "Rascunho",
31736
+ "crm.quotes.status.sent": "Enviado",
31737
+ "crm.quotes.status.approved": "Aprovado",
31738
+ "crm.quotes.status.rejected": "Recusado",
31739
+ "crm.quotes.status.expired": "Expirado",
31740
+ "crm.quotes.status.archived": "Arquivado",
31324
31741
  "crm.quotes.amount": "Valor",
31325
31742
  "crm.quotes.archive": "Arquivar",
31326
31743
  "crm.quotes.archiveTitle": "Arquivar este or\xE7amento?",