@fayz-ai/plugin-crm 0.9.4 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import React16, { useState, useEffect, useMemo, useRef } from 'react';
1
+ import React17, { useState, useEffect, useMemo, useRef, useCallback } from 'react';
2
2
  import { registerTranslations, registerMessageDefaults, createSafeDataProvider, getSupabaseClientOptional, usePluginRuntimeOptional, useTranslation, useActiveTenantId, getActiveTenantId, loadMessageOverrides, resolveMessages } from '@fayz-ai/core';
3
- import { createPluginContext, PluginSettingsPanel, registerTimelineSource, dedup, useModuleNavigation, createViewRouter, ModuleActionBar, useTenantPluginSettings, SettingsGroup, ToggleRow, adminNavigateTo, useLimitGuard, OrderFormSkeleton, OrderFormBlock, OrderFormView, OrderFormItemsCard, OrderFormItemRow, OrderFormAddItemStep, formatCurrency, OrderDetailSkeleton, OrderDetailBlock, OrderDetailView, PersonLink, useAccessOptional, invalidateLimit, useOrganizationStore } from '@fayz-ai/admin';
4
- import { toast, defineKpiWidget, defineChartWidget, defineCustomWidget, defineTableWidget, PageTransition, ModulePage, Button, SubpageHeader, ListView, useSaveBar, SearchSelect, DatePicker, DataTable, Breadcrumb, PhoneLink, DashboardCanvas, PageToolbar, ToolbarButton, RangeControl, Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription, SheetBody, SheetFooter, Dropdown, DropdownTrigger, DropdownContent, DropdownLabel, DropdownSeparator, DropdownItem, ConfirmDialog, SegmentedControl, normalizePhone, KpiCard, ChartWidget, Card, CardHeader, CardTitle, CardContent, TableWidget } from '@fayz-ai/ui';
3
+ import { createPluginContext, PluginSettingsPanel, registerTimelineSource, dedup, useModuleNavigation, createViewRouter, ModuleActionBar, useTenantPluginSettings, SettingsGroup, ToggleRow, adminNavigateTo, usePermissionOptional, useLimitGuard, RightRailPage, OrderFormSkeleton, OrderFormBlock, OrderFormView, OrderFormItemsCard, OrderFormItemRow, OrderFormAddItemStep, formatCurrency, OrderDetailSkeleton, OrderDetailBlock, OrderDetailView, PersonLink, useAccessOptional, invalidateLimit, useOrganizationStore, getRailPage } from '@fayz-ai/admin';
4
+ import { toast, defineKpiWidget, defineChartWidget, defineCustomWidget, defineTableWidget, PageTransition, ModulePage, Button, SubpageHeader, ListView, ConfirmDialog, SheetBody, SheetFooter, useSaveBar, SearchSelect, DatePicker, DataTable, Breadcrumb, PhoneLink, DashboardCanvas, PageToolbar, ToolbarButton, RangeControl, HeaderTabs, Dropdown, DropdownTrigger, DropdownContent, DropdownLabel, DropdownSeparator, DropdownItem, normalizePhone, KpiCard, ChartWidget, Card, CardHeader, CardTitle, CardContent, TableWidget } from '@fayz-ai/ui';
5
5
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
6
- import { Archive, FileX2, FileCheck2, Send, FilePlus2, XCircle, Trophy, MoveRight, Target, ArrowRightLeft, UserPlus, MessageCircle, CheckSquare, FileText, Users, Mail, Phone, Filter, Globe, Check, ChevronRight, Sparkles, Clock, Calendar, ArrowRight, ChevronDown, Printer, X, Pencil, CircleCheckBig, Ban, Receipt, Package, CalendarClock, Tag, Plus, Zap, Paperclip, ImageOff, CircleAlert, CircleDashed, Loader2, DollarSign, User } from 'lucide-react';
6
+ import { Archive, FileX2, FileCheck2, Send, FilePlus2, XCircle, Trophy, MoveRight, Target, ArrowRightLeft, UserPlus, MessageCircle, CheckSquare, FileText, Users, Mail, Phone, Filter, Globe, Check, ChevronRight, Sparkles, Clock, Calendar, ArrowRight, ChevronDown, Printer, X, Pencil, CircleCheckBig, Ban, Receipt, Package, CalendarClock, Tag, Plus, Zap, Paperclip, ImageOff, CircleAlert, CircleDashed, Loader2, DollarSign, User, Building2 } from 'lucide-react';
7
7
  import { createPortal } from 'react-dom';
8
8
  import { createStore as createStore$1 } from 'zustand/vanilla';
9
9
 
@@ -576,51 +576,22 @@ function LeadAttachments({ attachments, variant = "full" }) {
576
576
  )) })
577
577
  ] });
578
578
  }
579
-
580
- // src/lib/relative-time.ts
581
- var MINUTE = 60;
582
- var HOUR = 60 * MINUTE;
583
- var DAY = 24 * HOUR;
584
- var WEEK = 7 * DAY;
585
- var MONTH = 30 * DAY;
586
- var YEAR = 365 * DAY;
587
- var STEPS2 = [
588
- ["year", YEAR],
589
- ["month", MONTH],
590
- ["week", WEEK],
591
- ["day", DAY],
592
- ["hour", HOUR],
593
- ["minute", MINUTE]
594
- ];
595
- function formatRelativeTime(iso, locale = "pt-BR", now2 = /* @__PURE__ */ new Date()) {
596
- if (!iso) return "";
597
- const then = new Date(iso);
598
- const at = then.getTime();
599
- if (Number.isNaN(at)) return "";
600
- const elapsed = Math.round((now2.getTime() - at) / 1e3);
601
- const abs = Math.abs(elapsed);
602
- if (abs < 45) {
603
- return new Intl.RelativeTimeFormat(locale, { numeric: "auto" }).format(0, "second");
604
- }
605
- const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "always" });
606
- for (const [unit, seconds] of STEPS2) {
607
- if (abs >= seconds) {
608
- return rtf.format(-Math.round(elapsed / seconds), unit);
609
- }
610
- }
611
- return rtf.format(0, "second");
612
- }
613
- function formatDateTime(iso, locale = "pt-BR") {
614
- if (!iso) return "";
615
- const at = new Date(iso);
616
- if (Number.isNaN(at.getTime())) return "";
617
- return at.toLocaleString(locale, {
618
- day: "2-digit",
619
- month: "2-digit",
620
- year: "numeric",
621
- hour: "2-digit",
622
- minute: "2-digit"
623
- });
579
+ function FormAnswers({ lead }) {
580
+ const t2 = useTranslation();
581
+ const entries = answerEntries(lead?.metadata?.fields);
582
+ const attachments = leadAttachments(lead?.metadata);
583
+ if (entries.length === 0 && attachments.length === 0) return null;
584
+ const formId = lead?.metadata?.formId;
585
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
586
+ entries.length > 0 && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
587
+ /* @__PURE__ */ jsx("h4", { className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wider", children: formId ? `${t2("crm.leadDetail.formAnswers")} \xB7 ${formId}` : t2("crm.leadDetail.formAnswers") }),
588
+ /* @__PURE__ */ jsx("div", { className: "rounded-xl border divide-y", children: entries.map(([key, value]) => /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 px-4 py-2.5", children: [
589
+ /* @__PURE__ */ jsx("span", { className: "text-[11px] text-muted-foreground shrink-0 min-w-24", children: humanizeKey(key) }),
590
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-right flex-1 break-words", children: renderFieldValue(value) ?? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/50", children: "\u2014" }) })
591
+ ] }, key)) })
592
+ ] }),
593
+ /* @__PURE__ */ jsx(LeadAttachments, { attachments, variant: "compact" })
594
+ ] });
624
595
  }
625
596
  function automationKeyFor(activityType) {
626
597
  return `crm.${activityType}`;
@@ -661,24 +632,45 @@ function describe(hits) {
661
632
  return `${parts.join(" \xB7 ")} \u2014 clique para abrir a automa\xE7\xE3o`;
662
633
  }
663
634
  function AutomationBolt({ activityType, messages, className = "" }) {
635
+ const [open, setOpen] = useState(false);
636
+ const Detail = getRailPage("automations.detail");
664
637
  const hits = messages.filter((m) => m.event.name === automationKeyFor(activityType));
665
638
  if (hits.length === 0) return null;
666
639
  const target = hits.find((m) => m.enabled) ?? hits[0];
667
640
  const active = hits.some((m) => m.enabled);
668
- return /* @__PURE__ */ jsx(
669
- "button",
670
- {
671
- type: "button",
672
- onClick: (e) => {
673
- e.stopPropagation();
674
- adminNavigateTo(`/automations/${target.event.name}/${target.channel}`);
675
- },
676
- title: describe(hits),
677
- "aria-label": describe(hits),
678
- className: `inline-flex shrink-0 items-center justify-center rounded transition-colors ${active ? "text-primary hover:text-primary/70" : "text-muted-foreground/40 hover:text-muted-foreground"} ${className}`,
679
- children: /* @__PURE__ */ jsx(Zap, { className: `h-3.5 w-3.5 ${active ? "fill-current" : ""}` })
680
- }
681
- );
641
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
642
+ /* @__PURE__ */ jsx(
643
+ "button",
644
+ {
645
+ type: "button",
646
+ onClick: (e) => {
647
+ e.stopPropagation();
648
+ if (Detail) setOpen(true);
649
+ else adminNavigateTo(`/automations/${target.event.name}/${target.channel}`);
650
+ },
651
+ title: describe(hits),
652
+ "aria-label": describe(hits),
653
+ className: `inline-flex shrink-0 items-center justify-center rounded transition-colors ${active ? "text-primary hover:text-primary/70" : "text-muted-foreground/40 hover:text-muted-foreground"} ${className}`,
654
+ children: /* @__PURE__ */ jsx(Zap, { className: `h-3.5 w-3.5 ${active ? "fill-current" : ""}` })
655
+ }
656
+ ),
657
+ open && Detail && /* @__PURE__ */ jsx(
658
+ RightRailPage,
659
+ {
660
+ title: target.event.title ?? target.event.name,
661
+ open: true,
662
+ onClose: () => setOpen(false),
663
+ width: "max-w-2xl",
664
+ children: /* @__PURE__ */ jsx("div", { className: "min-h-0 flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(
665
+ Detail,
666
+ {
667
+ params: { eventKey: target.event.name, channel: target.channel },
668
+ onClose: () => setOpen(false)
669
+ }
670
+ ) })
671
+ }
672
+ )
673
+ ] });
682
674
  }
683
675
  var TYPE_ICONS = {
684
676
  call: Phone,
@@ -702,42 +694,107 @@ var TYPE_ICONS = {
702
694
  deal_archived: Archive,
703
695
  quote_archived: Archive
704
696
  };
697
+ function ActivityTimeline({ activities, loading }) {
698
+ const t2 = useTranslation();
699
+ const messages = useActivityAutomations();
700
+ if (loading) {
701
+ return /* @__PURE__ */ jsx("div", { className: "space-y-3", children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
702
+ /* @__PURE__ */ jsx("div", { className: "h-8 w-8 rounded-lg bg-muted/40 animate-pulse shrink-0" }),
703
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-1.5 pt-0.5", children: [
704
+ /* @__PURE__ */ jsx("div", { className: "h-3.5 w-2/3 rounded bg-muted/40 animate-pulse" }),
705
+ /* @__PURE__ */ jsx("div", { className: "h-2.5 w-1/3 rounded bg-muted/30 animate-pulse" })
706
+ ] })
707
+ ] }, i)) });
708
+ }
709
+ if (activities.length === 0) {
710
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: [
711
+ /* @__PURE__ */ jsx("div", { className: "flex h-12 w-12 items-center justify-center rounded-2xl bg-muted/30 mb-3", children: /* @__PURE__ */ jsx(Clock, { className: "h-5 w-5 text-muted-foreground/40" }) }),
712
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t2("crm.dealSidebar.noActivities") }),
713
+ /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground/60 mt-0.5", children: t2("crm.dealSidebar.activitiesAppear") })
714
+ ] });
715
+ }
716
+ return /* @__PURE__ */ jsx("div", { className: "space-y-1", children: activities.map((a) => {
717
+ const Icon = TYPE_ICONS[a.activityType] ?? FileText;
718
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 rounded-lg px-2 py-2.5 hover:bg-muted/20 transition-colors", children: [
719
+ /* @__PURE__ */ jsx("div", { className: "flex h-8 w-8 items-center justify-center rounded-lg bg-muted shrink-0", children: /* @__PURE__ */ jsx(Icon, { className: "h-3.5 w-3.5 text-muted-foreground" }) }),
720
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0 pt-0.5", children: [
721
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
722
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-medium truncate", children: a.title }),
723
+ a.completedAt && /* @__PURE__ */ jsx(Check, { className: "h-3 w-3 text-success shrink-0" }),
724
+ /* @__PURE__ */ jsx(AutomationBolt, { activityType: a.activityType, messages })
725
+ ] }),
726
+ a.description && /* @__PURE__ */ jsx("p", { className: "text-[11px] text-muted-foreground mt-0.5 line-clamp-2", children: a.description }),
727
+ /* @__PURE__ */ jsxs("p", { className: "text-[10px] text-muted-foreground/50 mt-1 capitalize", children: [
728
+ a.activityType,
729
+ " \xB7 ",
730
+ new Date(a.createdAt).toLocaleDateString()
731
+ ] })
732
+ ] })
733
+ ] }, a.id);
734
+ }) });
735
+ }
736
+
737
+ // src/lib/relative-time.ts
738
+ var MINUTE = 60;
739
+ var HOUR = 60 * MINUTE;
740
+ var DAY = 24 * HOUR;
741
+ var WEEK = 7 * DAY;
742
+ var MONTH = 30 * DAY;
743
+ var YEAR = 365 * DAY;
744
+ var STEPS2 = [
745
+ ["year", YEAR],
746
+ ["month", MONTH],
747
+ ["week", WEEK],
748
+ ["day", DAY],
749
+ ["hour", HOUR],
750
+ ["minute", MINUTE]
751
+ ];
752
+ function formatRelativeTime(iso, locale = "pt-BR", now2 = /* @__PURE__ */ new Date()) {
753
+ if (!iso) return "";
754
+ const then = new Date(iso);
755
+ const at = then.getTime();
756
+ if (Number.isNaN(at)) return "";
757
+ const elapsed = Math.round((now2.getTime() - at) / 1e3);
758
+ const abs = Math.abs(elapsed);
759
+ if (abs < 45) {
760
+ return new Intl.RelativeTimeFormat(locale, { numeric: "auto" }).format(0, "second");
761
+ }
762
+ const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "always" });
763
+ for (const [unit, seconds] of STEPS2) {
764
+ if (abs >= seconds) {
765
+ return rtf.format(-Math.round(elapsed / seconds), unit);
766
+ }
767
+ }
768
+ return rtf.format(0, "second");
769
+ }
770
+ function formatDateTime(iso, locale = "pt-BR") {
771
+ if (!iso) return "";
772
+ const at = new Date(iso);
773
+ if (Number.isNaN(at.getTime())) return "";
774
+ return at.toLocaleString(locale, {
775
+ day: "2-digit",
776
+ month: "2-digit",
777
+ year: "numeric",
778
+ hour: "2-digit",
779
+ minute: "2-digit"
780
+ });
781
+ }
705
782
  function TabBar({ active, counts, onChange }) {
706
783
  const t2 = useTranslation();
707
- const label2 = (text, count, isActive) => /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1.5", children: [
708
- text,
709
- count != null && count > 0 && /* @__PURE__ */ jsx("span", { className: `inline-flex items-center justify-center min-w-[16px] h-4 rounded-full px-1 text-[10px] font-semibold ${isActive ? "bg-background/20 text-background" : "bg-muted text-muted-foreground"}`, children: count })
710
- ] });
711
- return /* @__PURE__ */ jsx("div", { className: "px-5 py-2 border-b shrink-0", children: /* @__PURE__ */ jsx(
712
- SegmentedControl,
784
+ return /* @__PURE__ */ jsx("div", { className: "shrink-0 border-b px-5 pt-1", children: /* @__PURE__ */ jsx(
785
+ HeaderTabs,
713
786
  {
787
+ className: "-mb-px",
714
788
  value: active,
715
789
  onChange,
716
- options: [
717
- { value: "overview", label: label2(t2("crm.dealSidebar.overview"), void 0, active === "overview") },
718
- { value: "activity", label: label2(t2("crm.dealSidebar.activity"), counts.activity, active === "activity") },
719
- { value: "quotes", label: label2(t2("crm.dealSidebar.quotes"), counts.quotes, active === "quotes") }
790
+ tabs: [
791
+ { value: "overview", label: t2("crm.dealSidebar.overview") },
792
+ { value: "activity", label: t2("crm.dealSidebar.activity"), count: counts.activity || void 0 },
793
+ { value: "quotes", label: t2("crm.dealSidebar.quotes"), count: counts.quotes || void 0 }
720
794
  ]
721
795
  }
722
796
  ) });
723
797
  }
724
- function FormAnswers({ lead }) {
725
- const t2 = useTranslation();
726
- const entries = answerEntries(lead?.metadata?.fields);
727
- const attachments = leadAttachments(lead?.metadata);
728
- if (entries.length === 0 && attachments.length === 0) return null;
729
- const formId = lead?.metadata?.formId;
730
- return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
731
- entries.length > 0 && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
732
- /* @__PURE__ */ jsx("h4", { className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wider", children: formId ? `${t2("crm.leadDetail.formAnswers")} \xB7 ${formId}` : t2("crm.leadDetail.formAnswers") }),
733
- /* @__PURE__ */ jsx("div", { className: "rounded-xl border divide-y", children: entries.map(([key, value]) => /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 px-4 py-2.5", children: [
734
- /* @__PURE__ */ jsx("span", { className: "text-[11px] text-muted-foreground shrink-0 min-w-24", children: humanizeKey(key) }),
735
- /* @__PURE__ */ jsx("span", { className: "text-xs text-right flex-1 break-words", children: renderFieldValue(value) ?? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/50", children: "\u2014" }) })
736
- ] }, key)) })
737
- ] }),
738
- /* @__PURE__ */ jsx(LeadAttachments, { attachments, variant: "compact" })
739
- ] });
740
- }
741
798
  function OverviewTab({ deal, lead, currency }) {
742
799
  const t2 = useTranslation();
743
800
  const initial = (lead?.name ?? deal.contactName ?? deal.title).charAt(0).toUpperCase();
@@ -837,45 +894,6 @@ function OverviewTab({ deal, lead, currency }) {
837
894
  ] })
838
895
  ] });
839
896
  }
840
- function ActivityTab({ activities, loading }) {
841
- const t2 = useTranslation();
842
- const messages = useActivityAutomations();
843
- if (loading) {
844
- return /* @__PURE__ */ jsx("div", { className: "space-y-3", children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
845
- /* @__PURE__ */ jsx("div", { className: "h-8 w-8 rounded-lg bg-muted/40 animate-pulse shrink-0" }),
846
- /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-1.5 pt-0.5", children: [
847
- /* @__PURE__ */ jsx("div", { className: "h-3.5 w-2/3 rounded bg-muted/40 animate-pulse" }),
848
- /* @__PURE__ */ jsx("div", { className: "h-2.5 w-1/3 rounded bg-muted/30 animate-pulse" })
849
- ] })
850
- ] }, i)) });
851
- }
852
- if (activities.length === 0) {
853
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: [
854
- /* @__PURE__ */ jsx("div", { className: "flex h-12 w-12 items-center justify-center rounded-2xl bg-muted/30 mb-3", children: /* @__PURE__ */ jsx(Clock, { className: "h-5 w-5 text-muted-foreground/40" }) }),
855
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t2("crm.dealSidebar.noActivities") }),
856
- /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground/60 mt-0.5", children: t2("crm.dealSidebar.activitiesAppear") })
857
- ] });
858
- }
859
- return /* @__PURE__ */ jsx("div", { className: "space-y-1", children: activities.map((a, i) => {
860
- const Icon = TYPE_ICONS[a.activityType] ?? FileText;
861
- return /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 rounded-lg px-2 py-2.5 hover:bg-muted/20 transition-colors", children: [
862
- /* @__PURE__ */ jsx("div", { className: "flex h-8 w-8 items-center justify-center rounded-lg bg-muted shrink-0", children: /* @__PURE__ */ jsx(Icon, { className: "h-3.5 w-3.5 text-muted-foreground" }) }),
863
- /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0 pt-0.5", children: [
864
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
865
- /* @__PURE__ */ jsx("p", { className: "text-xs font-medium truncate", children: a.title }),
866
- a.completedAt && /* @__PURE__ */ jsx(Check, { className: "h-3 w-3 text-success shrink-0" }),
867
- /* @__PURE__ */ jsx(AutomationBolt, { activityType: a.activityType, messages })
868
- ] }),
869
- a.description && /* @__PURE__ */ jsx("p", { className: "text-[11px] text-muted-foreground mt-0.5 line-clamp-2", children: a.description }),
870
- /* @__PURE__ */ jsxs("p", { className: "text-[10px] text-muted-foreground/50 mt-1 capitalize", children: [
871
- a.activityType,
872
- " \xB7 ",
873
- new Date(a.createdAt).toLocaleDateString()
874
- ] })
875
- ] })
876
- ] }, a.id);
877
- }) });
878
- }
879
897
  function QuotesTab({ quotes, loading, currency, onViewQuote, onQuoteUpdated }) {
880
898
  const t2 = useTranslation();
881
899
  if (loading) {
@@ -949,66 +967,71 @@ function DealSidebar({ dealId, open, onClose, onViewLead, onViewQuote }) {
949
967
  setQuotesLoading(false);
950
968
  });
951
969
  }, [dealId, open]);
952
- return /* @__PURE__ */ jsx(Sheet, { open, onOpenChange: (v) => {
953
- if (!v) onClose();
954
- }, children: /* @__PURE__ */ jsxs(SheetContent, { width: "max-w-md", children: [
955
- /* @__PURE__ */ jsx(SheetHeader, { children: loading ? /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 pr-8", children: [
956
- /* @__PURE__ */ jsx("div", { className: "h-4 w-40 rounded bg-muted/40 animate-pulse" }),
957
- /* @__PURE__ */ jsx("div", { className: "h-3 w-24 rounded bg-muted/30 animate-pulse" })
958
- ] }) : /* @__PURE__ */ jsxs("div", { className: "pr-8", children: [
959
- /* @__PURE__ */ jsx(SheetTitle, { children: deal?.title ?? t2("crm.dealSidebar.deal") }),
960
- deal?.contactName && /* @__PURE__ */ jsx(SheetDescription, { children: deal.contactName })
961
- ] }) }),
962
- /* @__PURE__ */ jsx(
963
- TabBar,
964
- {
965
- active: activeTab,
966
- counts: { activity: activities.length, quotes: quotes.length },
967
- onChange: setActiveTab
968
- }
969
- ),
970
- /* @__PURE__ */ jsx(SheetBody, { children: loading ? /* @__PURE__ */ jsxs("div", { className: "space-y-5", children: [
971
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3.5", children: [
972
- /* @__PURE__ */ jsx("div", { className: "h-14 w-14 rounded-2xl bg-muted/40 animate-pulse" }),
973
- /* @__PURE__ */ jsxs("div", { className: "space-y-2 flex-1", children: [
974
- /* @__PURE__ */ jsx("div", { className: "h-4 w-32 rounded bg-muted/40 animate-pulse" }),
975
- /* @__PURE__ */ jsx("div", { className: "h-3 w-24 rounded bg-muted/30 animate-pulse" })
976
- ] })
977
- ] }),
978
- /* @__PURE__ */ jsx("div", { className: "rounded-xl border divide-y", children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-3", children: [
979
- /* @__PURE__ */ jsx("div", { className: "h-3 w-20 rounded bg-muted/30 animate-pulse" }),
980
- /* @__PURE__ */ jsx("div", { className: "h-3 w-24 rounded bg-muted/40 animate-pulse" })
981
- ] }, i)) })
982
- ] }) : deal ? /* @__PURE__ */ jsxs(Fragment, { children: [
983
- activeTab === "overview" && /* @__PURE__ */ jsx(OverviewTab, { deal, lead, currency }),
984
- activeTab === "activity" && /* @__PURE__ */ jsx(ActivityTab, { activities, loading: activitiesLoading }),
985
- activeTab === "quotes" && /* @__PURE__ */ jsx(QuotesTab, { quotes, loading: quotesLoading, currency, onViewQuote: (id) => {
986
- onViewQuote?.(id);
987
- onClose();
988
- }, onQuoteUpdated: (updated) => setQuotes(quotes.map((q) => q.id === updated.id ? updated : q)) })
989
- ] }) : /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t2("crm.dealSidebar.dealNotFound") }) }) }),
990
- deal && /* @__PURE__ */ jsxs("p", { className: "shrink-0 border-t border-border/40 px-5 py-1.5 text-[10px] text-muted-foreground/60", children: [
991
- t2("crm.dealSidebar.created"),
992
- " ",
993
- deal.createdAt?.slice(0, 10),
994
- deal.updatedAt ? ` \xB7 ${t2("crm.dealSidebar.updated")} ${deal.updatedAt.slice(0, 10)}` : ""
995
- ] }),
996
- deal && lead && onViewLead && /* @__PURE__ */ jsx(SheetFooter, { children: /* @__PURE__ */ jsxs(
997
- "button",
970
+ return (
971
+ // No header of its own: the column heads the page, with the deal's name
972
+ // centred and the way back beside it. It used to print the title twice —
973
+ // once in the sheet header and again as the first line of the overview.
974
+ /* @__PURE__ */ jsxs(
975
+ RightRailPage,
998
976
  {
999
- onClick: () => {
1000
- onViewLead(lead.id);
1001
- onClose();
1002
- },
1003
- className: "flex-1 inline-flex items-center justify-center gap-2 rounded-lg border px-3 py-2.5 text-xs font-medium hover:bg-muted bg-card shadow-button active:shadow-button-inset transition-colors",
977
+ title: loading ? t2("crm.dealSidebar.deal") : deal?.title ?? t2("crm.dealSidebar.deal"),
978
+ open,
979
+ onClose,
980
+ width: "max-w-md",
1004
981
  children: [
1005
- t2("crm.dealSidebar.viewLeadProfile"),
1006
- " ",
1007
- /* @__PURE__ */ jsx(ArrowRight, { className: "h-3 w-3" })
982
+ /* @__PURE__ */ jsx(
983
+ TabBar,
984
+ {
985
+ active: activeTab,
986
+ counts: { activity: activities.length, quotes: quotes.length },
987
+ onChange: setActiveTab
988
+ }
989
+ ),
990
+ /* @__PURE__ */ jsx(SheetBody, { children: loading ? /* @__PURE__ */ jsxs("div", { className: "space-y-5", children: [
991
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3.5", children: [
992
+ /* @__PURE__ */ jsx("div", { className: "h-14 w-14 rounded-2xl bg-muted/40 animate-pulse" }),
993
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2 flex-1", children: [
994
+ /* @__PURE__ */ jsx("div", { className: "h-4 w-32 rounded bg-muted/40 animate-pulse" }),
995
+ /* @__PURE__ */ jsx("div", { className: "h-3 w-24 rounded bg-muted/30 animate-pulse" })
996
+ ] })
997
+ ] }),
998
+ /* @__PURE__ */ jsx("div", { className: "rounded-xl border divide-y", children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-3", children: [
999
+ /* @__PURE__ */ jsx("div", { className: "h-3 w-20 rounded bg-muted/30 animate-pulse" }),
1000
+ /* @__PURE__ */ jsx("div", { className: "h-3 w-24 rounded bg-muted/40 animate-pulse" })
1001
+ ] }, i)) })
1002
+ ] }) : deal ? /* @__PURE__ */ jsxs(Fragment, { children: [
1003
+ activeTab === "overview" && /* @__PURE__ */ jsx(OverviewTab, { deal, lead, currency }),
1004
+ activeTab === "activity" && /* @__PURE__ */ jsx(ActivityTimeline, { activities, loading: activitiesLoading }),
1005
+ activeTab === "quotes" && /* @__PURE__ */ jsx(QuotesTab, { quotes, loading: quotesLoading, currency, onViewQuote: (id) => {
1006
+ onViewQuote?.(id);
1007
+ onClose();
1008
+ }, onQuoteUpdated: (updated) => setQuotes(quotes.map((q) => q.id === updated.id ? updated : q)) })
1009
+ ] }) : /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t2("crm.dealSidebar.dealNotFound") }) }) }),
1010
+ deal && /* @__PURE__ */ jsxs("p", { className: "shrink-0 border-t border-border/40 px-5 py-1.5 text-[10px] text-muted-foreground/60", children: [
1011
+ t2("crm.dealSidebar.created"),
1012
+ " ",
1013
+ deal.createdAt?.slice(0, 10),
1014
+ deal.updatedAt ? ` \xB7 ${t2("crm.dealSidebar.updated")} ${deal.updatedAt.slice(0, 10)}` : ""
1015
+ ] }),
1016
+ deal && lead && onViewLead && /* @__PURE__ */ jsx(SheetFooter, { children: /* @__PURE__ */ jsxs(
1017
+ "button",
1018
+ {
1019
+ onClick: () => {
1020
+ onViewLead(lead.id);
1021
+ onClose();
1022
+ },
1023
+ className: "flex-1 inline-flex items-center justify-center gap-2 rounded-lg border px-3 py-2.5 text-xs font-medium hover:bg-muted bg-card shadow-button active:shadow-button-inset transition-colors",
1024
+ children: [
1025
+ t2("crm.dealSidebar.viewLeadProfile"),
1026
+ " ",
1027
+ /* @__PURE__ */ jsx(ArrowRight, { className: "h-3 w-3" })
1028
+ ]
1029
+ }
1030
+ ) })
1008
1031
  ]
1009
1032
  }
1010
- ) })
1011
- ] }) });
1033
+ )
1034
+ );
1012
1035
  }
1013
1036
  function periodToRange(period, customFrom, customTo) {
1014
1037
  if (period === "all") return {};
@@ -1168,7 +1191,7 @@ function PipelineSkeleton() {
1168
1191
  /* @__PURE__ */ jsx("div", { className: "h-3 w-16 rounded bg-muted/40 animate-pulse" }),
1169
1192
  /* @__PURE__ */ jsx("div", { className: "h-3 w-5 rounded bg-muted/30 animate-pulse" })
1170
1193
  ] }),
1171
- /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Array.from({ length: col <= 2 ? 2 : 1 }).map((_, i) => /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card shadow-sm p-3 space-y-2", children: [
1194
+ /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Array.from({ length: col <= 2 ? 2 : 1 }).map((_, i) => /* @__PURE__ */ jsxs("div", { className: "rounded-card border bg-card shadow-sm p-3 space-y-2", children: [
1172
1195
  /* @__PURE__ */ jsx("div", { className: "h-4 w-3/4 rounded bg-muted/40 animate-pulse" }),
1173
1196
  /* @__PURE__ */ jsx("div", { className: "h-3 w-1/2 rounded bg-muted/30 animate-pulse" }),
1174
1197
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pt-1", children: [
@@ -1187,7 +1210,7 @@ function DealCard({ deal, saving, currency, tagDefs, onClick, onArchive, onDragS
1187
1210
  onDragStart,
1188
1211
  onDragEnd,
1189
1212
  onClick,
1190
- className: `group rounded-lg border bg-card p-3 transition-shadow ${saving ? "opacity-70" : "hover:shadow-sm cursor-grab active:cursor-grabbing active:opacity-70"}`,
1213
+ className: `group rounded-card border bg-card p-3 transition-shadow ${saving ? "opacity-70" : "hover:shadow-sm cursor-grab active:cursor-grabbing active:opacity-70"}`,
1191
1214
  children: [
1192
1215
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
1193
1216
  /* @__PURE__ */ jsx("p", { className: "text-sm font-medium truncate", children: deal.title }),
@@ -1480,13 +1503,25 @@ function PipelineView({ onDealClick, onViewLead, onViewQuote, onAddLead, onOpenS
1480
1503
  )
1481
1504
  ] });
1482
1505
  }
1483
- var STATUS_OPTIONS = [
1484
- { value: "new", label: "New", color: "bg-info-soft text-info-soft-foreground" },
1485
- { value: "contacted", label: "Contacted", color: "bg-magic-soft text-magic-soft-foreground" },
1486
- { value: "qualified", label: "Qualified", color: "bg-success-soft text-success-soft-foreground" },
1487
- { value: "unqualified", label: "Unqualified", color: "bg-muted text-muted-foreground" },
1488
- { value: "converted", label: "Converted", color: "bg-warning-soft text-warning-soft-foreground" }
1506
+ var LEAD_STATUS_OPTIONS = [
1507
+ { value: "new", labelKey: "crm.leads.statusNew", color: "bg-info-soft text-info-soft-foreground" },
1508
+ { value: "contacted", labelKey: "crm.leads.statusContacted", color: "bg-magic-soft text-magic-soft-foreground" },
1509
+ { value: "qualified", labelKey: "crm.leads.statusQualified", color: "bg-success-soft text-success-soft-foreground" },
1510
+ { value: "unqualified", labelKey: "crm.leads.statusUnqualified", color: "bg-muted text-muted-foreground" },
1511
+ { value: "converted", labelKey: "crm.leads.statusConverted", color: "bg-warning-soft text-warning-soft-foreground" },
1512
+ { value: "lost", labelKey: "crm.leads.statusLost", color: "bg-destructive-soft text-destructive-soft-foreground" }
1489
1513
  ];
1514
+ function LeadStatusBadge({ status, className }) {
1515
+ const t2 = useTranslation();
1516
+ const opt = LEAD_STATUS_OPTIONS.find((o) => o.value === status);
1517
+ return /* @__PURE__ */ jsx(
1518
+ "span",
1519
+ {
1520
+ className: `inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium ${opt?.color ?? "bg-muted text-muted-foreground"} ${className ?? ""}`,
1521
+ children: opt ? t2(opt.labelKey) : status
1522
+ }
1523
+ );
1524
+ }
1490
1525
  var columns = [
1491
1526
  { accessorKey: "name", header: "Name", cell: ({ getValue }) => /* @__PURE__ */ jsx("span", { className: "font-medium", children: getValue() }) },
1492
1527
  {
@@ -1502,11 +1537,7 @@ var columns = [
1502
1537
  {
1503
1538
  accessorKey: "status",
1504
1539
  header: "Status",
1505
- cell: ({ getValue }) => {
1506
- const status = getValue();
1507
- const opt = STATUS_OPTIONS.find((o) => o.value === status);
1508
- return /* @__PURE__ */ jsx("span", { className: `inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium ${opt?.color ?? "bg-muted text-muted-foreground"}`, children: opt?.label ?? status });
1509
- }
1540
+ cell: ({ getValue }) => /* @__PURE__ */ jsx(LeadStatusBadge, { status: getValue() })
1510
1541
  },
1511
1542
  {
1512
1543
  // When the lead came in. The list is already sorted by it (provider orders
@@ -1529,15 +1560,73 @@ var columns = [
1529
1560
  ];
1530
1561
  function LeadListView({ onNew, onEdit }) {
1531
1562
  const t2 = useTranslation();
1563
+ const can = usePermissionOptional();
1564
+ const provider = useCrmProvider();
1532
1565
  const leads = useCrmStore((s) => s.leads);
1533
1566
  const leadsLoading = useCrmStore((s) => s.leadsLoading);
1534
1567
  const fetchLeads = useCrmStore((s) => s.fetchLeads);
1568
+ const updateLead = useCrmStore((s) => s.updateLead);
1569
+ const refreshLeads = useCrmStore((s) => s.refreshLeads);
1535
1570
  const [search, setSearch] = useState("");
1536
1571
  const [statusFilter, setStatusFilter] = useState([]);
1572
+ const [archiveTarget, setArchiveTarget] = useState(null);
1573
+ const [bulkBusy, setBulkBusy] = useState(false);
1537
1574
  useEffect(() => {
1538
1575
  fetchLeads({ status: statusFilter.length > 0 ? statusFilter : void 0, search: search || void 0 });
1539
1576
  }, [statusFilter, search]);
1540
- const tags = useMemo(() => STATUS_OPTIONS.map((o) => ({ value: o.value, label: o.label })), []);
1577
+ const tags = useMemo(() => LEAD_STATUS_OPTIONS.map((o) => ({ value: o.value, label: t2(o.labelKey) })), [t2]);
1578
+ const runBulk = useCallback(async (rows, write, labels) => {
1579
+ setBulkBusy(true);
1580
+ let done = 0;
1581
+ let failed = 0;
1582
+ for (const lead of rows) {
1583
+ try {
1584
+ await write(lead);
1585
+ done++;
1586
+ } catch (err) {
1587
+ failed++;
1588
+ console.warn("[crm] bulk lead write failed", lead.id, err);
1589
+ }
1590
+ }
1591
+ setBulkBusy(false);
1592
+ await refreshLeads();
1593
+ if (done > 0) toast.success(t2(labels.done, { count: String(done) }));
1594
+ if (failed > 0) toast.error(t2(labels.failed, { count: String(failed) }));
1595
+ }, [refreshLeads, t2]);
1596
+ const bulkActions = useMemo(() => {
1597
+ if (!can("sales", "edit")) return void 0;
1598
+ const statusActions = LEAD_STATUS_OPTIONS.filter((o) => o.value !== "converted" && o.value !== "lost").map((opt) => ({
1599
+ id: `status-${opt.value}`,
1600
+ label: t2("crm.leads.bulkSetStatus", { status: t2(opt.labelKey) }),
1601
+ // Os dois movimentos do dia a dia ficam à mão; o resto no menu, senão a
1602
+ // barra vira uma fileira de cinco botões quase iguais.
1603
+ overflow: opt.value !== "contacted" && opt.value !== "qualified",
1604
+ disabled: bulkBusy,
1605
+ onSelect: (rows) => {
1606
+ const targets = rows.filter((lead) => lead.status !== opt.value);
1607
+ if (targets.length === 0) {
1608
+ toast.error(t2("crm.leads.bulkStatusNone"));
1609
+ return;
1610
+ }
1611
+ void runBulk(targets, (lead) => updateLead(lead.id, { status: opt.value }), {
1612
+ done: "crm.leads.bulkStatusDone",
1613
+ failed: "crm.leads.bulkStatusFailed"
1614
+ });
1615
+ }
1616
+ }));
1617
+ return [
1618
+ ...statusActions,
1619
+ ...can("sales", "delete") ? [{
1620
+ id: "archive",
1621
+ label: t2("crm.leads.bulkArchive"),
1622
+ icon: Archive,
1623
+ destructive: true,
1624
+ overflow: true,
1625
+ disabled: bulkBusy,
1626
+ onSelect: (rows) => setArchiveTarget(rows)
1627
+ }] : []
1628
+ ];
1629
+ }, [can, bulkBusy, runBulk, updateLead, t2]);
1541
1630
  return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
1542
1631
  /* @__PURE__ */ jsx(SubpageHeader, { title: t2("crm.leads.title") }),
1543
1632
  /* @__PURE__ */ jsx(
@@ -1555,12 +1644,34 @@ function LeadListView({ onNew, onEdit }) {
1555
1644
  onTagChange: (v) => setStatusFilter(v ? [v] : []),
1556
1645
  newLabel: t2("crm.leads.newLead"),
1557
1646
  onNew,
1647
+ bulkActions,
1558
1648
  onRowClick: (row) => onEdit?.(row.id),
1559
1649
  emptyIcon: UserPlus,
1560
1650
  emptyMessage: t2("crm.leads.noLeads"),
1561
1651
  emptyActionLabel: onNew ? t2("crm.leads.captureFirst") : void 0,
1562
1652
  onEmptyAction: onNew
1563
1653
  }
1654
+ ),
1655
+ /* @__PURE__ */ jsx(
1656
+ ConfirmDialog,
1657
+ {
1658
+ open: archiveTarget !== null,
1659
+ variant: "destructive",
1660
+ title: t2("crm.leads.bulkArchiveTitle", { count: String(archiveTarget?.length ?? 0) }),
1661
+ description: t2("crm.leads.bulkArchiveDesc"),
1662
+ confirmLabel: t2("crm.leads.bulkArchive"),
1663
+ cancelLabel: t2("crm.leads.bulkKeep"),
1664
+ loading: bulkBusy,
1665
+ onConfirm: () => {
1666
+ const rows = archiveTarget ?? [];
1667
+ setArchiveTarget(null);
1668
+ void runBulk(rows, (lead) => provider.archiveLead(lead.id), {
1669
+ done: "crm.leads.bulkArchiveDone",
1670
+ failed: "crm.leads.bulkArchiveFailed"
1671
+ });
1672
+ },
1673
+ onCancel: () => setArchiveTarget(null)
1674
+ }
1564
1675
  )
1565
1676
  ] });
1566
1677
  }
@@ -1595,45 +1706,44 @@ function LeadFormView({ onSaved }) {
1595
1706
  setSaving(false);
1596
1707
  }
1597
1708
  }
1598
- const dirty = !!(name || email || phone || company || notes);
1599
- useSaveBar({
1600
- dirty,
1601
- saving,
1602
- onSave: () => {
1603
- void handleSave();
1604
- },
1605
- onDiscard: () => onSaved?.(),
1606
- saveLabel: t2("crm.leadForm.save")
1607
- });
1608
- return /* @__PURE__ */ jsxs("div", { className: "space-y-5", children: [
1609
- /* @__PURE__ */ jsx(SubpageHeader, { title: t2("crm.leadForm.title"), subtitle: t2("crm.leadForm.subtitle"), onBack: onSaved, parentLabel: t2("crm.leads.title") }),
1610
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card shadow-sm p-5 space-y-4", children: [
1611
- /* @__PURE__ */ jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [
1612
- /* @__PURE__ */ jsxs("div", { children: [
1613
- /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-muted-foreground", children: t2("crm.leadForm.name") }),
1614
- /* @__PURE__ */ jsx("input", { type: "text", value: name, onChange: (e) => setName(e.target.value), placeholder: t2("crm.leadForm.namePlaceholder"), autoFocus: true, className: "w-full mt-1 rounded-input border border-input bg-card shadow-[inset_0_1px_0_rgb(0_0_0_/0.06)] px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring" })
1615
- ] }),
1616
- /* @__PURE__ */ jsxs("div", { children: [
1617
- /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-muted-foreground", children: t2("crm.leadForm.company") }),
1618
- /* @__PURE__ */ jsx("input", { type: "text", value: company, onChange: (e) => setCompany(e.target.value), placeholder: t2("crm.leadForm.companyPlaceholder"), className: "w-full mt-1 rounded-input border border-input bg-card shadow-[inset_0_1px_0_rgb(0_0_0_/0.06)] px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring" })
1619
- ] })
1620
- ] }),
1621
- /* @__PURE__ */ jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [
1622
- /* @__PURE__ */ jsxs("div", { children: [
1623
- /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-muted-foreground", children: t2("crm.leadForm.email") }),
1624
- /* @__PURE__ */ jsx("input", { type: "email", value: email, onChange: (e) => setEmail(e.target.value), placeholder: t2("crm.leadForm.emailPlaceholder"), className: "w-full mt-1 rounded-input border border-input bg-card shadow-[inset_0_1px_0_rgb(0_0_0_/0.06)] px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring" })
1625
- ] }),
1626
- /* @__PURE__ */ jsxs("div", { children: [
1627
- /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-muted-foreground", children: t2("crm.leadForm.phone") }),
1628
- /* @__PURE__ */ jsx("input", { type: "tel", value: phone, onChange: (e) => setPhone(e.target.value), placeholder: t2("crm.leadForm.phonePlaceholder"), className: "w-full mt-1 rounded-input border border-input bg-card shadow-[inset_0_1px_0_rgb(0_0_0_/0.06)] px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring" })
1629
- ] })
1630
- ] }),
1631
- /* @__PURE__ */ jsxs("div", { children: [
1632
- /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-muted-foreground", children: t2("crm.leadForm.notes") }),
1633
- /* @__PURE__ */ jsx("textarea", { value: notes, onChange: (e) => setNotes(e.target.value), rows: 2, placeholder: t2("crm.leadForm.notesPlaceholder"), className: "w-full mt-1 rounded-input border border-input bg-card shadow-[inset_0_1px_0_rgb(0_0_0_/0.06)] px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring resize-none" })
1634
- ] })
1635
- ] })
1636
- ] });
1709
+ return (
1710
+ // Beside the list, not instead of it: a lead is entered while looking at
1711
+ // the ones already there, and the full-page form replaced exactly that.
1712
+ /* @__PURE__ */ jsxs(
1713
+ RightRailPage,
1714
+ {
1715
+ title: t2("crm.leadForm.title"),
1716
+ open: true,
1717
+ onClose: () => onSaved?.(),
1718
+ width: "max-w-md",
1719
+ children: [
1720
+ /* @__PURE__ */ jsxs(SheetBody, { className: "space-y-4", children: [
1721
+ /* @__PURE__ */ jsxs("div", { children: [
1722
+ /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-muted-foreground", children: t2("crm.leadForm.name") }),
1723
+ /* @__PURE__ */ jsx("input", { type: "text", value: name, onChange: (e) => setName(e.target.value), placeholder: t2("crm.leadForm.namePlaceholder"), autoFocus: true, className: "w-full mt-1 rounded-input border border-input bg-card shadow-[inset_0_1px_0_rgb(0_0_0_/0.06)] px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring" })
1724
+ ] }),
1725
+ /* @__PURE__ */ jsxs("div", { children: [
1726
+ /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-muted-foreground", children: t2("crm.leadForm.company") }),
1727
+ /* @__PURE__ */ jsx("input", { type: "text", value: company, onChange: (e) => setCompany(e.target.value), placeholder: t2("crm.leadForm.companyPlaceholder"), className: "w-full mt-1 rounded-input border border-input bg-card shadow-[inset_0_1px_0_rgb(0_0_0_/0.06)] px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring" })
1728
+ ] }),
1729
+ /* @__PURE__ */ jsxs("div", { children: [
1730
+ /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-muted-foreground", children: t2("crm.leadForm.email") }),
1731
+ /* @__PURE__ */ jsx("input", { type: "email", value: email, onChange: (e) => setEmail(e.target.value), placeholder: t2("crm.leadForm.emailPlaceholder"), className: "w-full mt-1 rounded-input border border-input bg-card shadow-[inset_0_1px_0_rgb(0_0_0_/0.06)] px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring" })
1732
+ ] }),
1733
+ /* @__PURE__ */ jsxs("div", { children: [
1734
+ /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-muted-foreground", children: t2("crm.leadForm.phone") }),
1735
+ /* @__PURE__ */ jsx("input", { type: "tel", value: phone, onChange: (e) => setPhone(e.target.value), placeholder: t2("crm.leadForm.phonePlaceholder"), className: "w-full mt-1 rounded-input border border-input bg-card shadow-[inset_0_1px_0_rgb(0_0_0_/0.06)] px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring" })
1736
+ ] }),
1737
+ /* @__PURE__ */ jsxs("div", { children: [
1738
+ /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-muted-foreground", children: t2("crm.leadForm.notes") }),
1739
+ /* @__PURE__ */ jsx("textarea", { value: notes, onChange: (e) => setNotes(e.target.value), rows: 2, placeholder: t2("crm.leadForm.notesPlaceholder"), className: "w-full mt-1 rounded-input border border-input bg-card shadow-[inset_0_1px_0_rgb(0_0_0_/0.06)] px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring resize-none" })
1740
+ ] })
1741
+ ] }),
1742
+ /* @__PURE__ */ jsx(SheetFooter, { children: /* @__PURE__ */ jsx(Button, { className: "flex-1", onClick: () => void handleSave(), disabled: saving || !name.trim(), children: saving ? t2("common.saving") : t2("crm.leadForm.save") }) })
1743
+ ]
1744
+ }
1745
+ )
1746
+ );
1637
1747
  }
1638
1748
  var STATUS_COLORS = {
1639
1749
  draft: "bg-muted text-muted-foreground",
@@ -1720,7 +1830,7 @@ function QuoteListView({ onNew, onEdit, onEditQuote }) {
1720
1830
  SubpageHeader,
1721
1831
  {
1722
1832
  title: t2("crm.quotes.title"),
1723
- actions: onNew && /* @__PURE__ */ jsxs("button", { onClick: onNew, className: "inline-flex items-center gap-1.5 rounded-lg bg-primary border border-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 shadow-button-primary active:shadow-button-inset transition-colors", children: [
1833
+ actions: onNew && /* @__PURE__ */ jsxs("button", { onClick: onNew, className: "inline-flex items-center gap-1.5 rounded-button bg-primary border border-primary px-3 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 shadow-button-primary active:shadow-button-inset transition-colors", children: [
1724
1834
  /* @__PURE__ */ jsx("span", { className: "h-3.5 w-3.5 inline-flex items-center justify-center", children: "+" }),
1725
1835
  " ",
1726
1836
  t2("crm.quotes.newQuote")
@@ -1741,7 +1851,7 @@ function QuoteListView({ onNew, onEdit, onEditQuote }) {
1741
1851
  "button",
1742
1852
  {
1743
1853
  onClick: onNew,
1744
- className: "mt-3 inline-flex items-center gap-1.5 rounded-lg border border-primary bg-primary px-3 py-2 text-sm font-medium text-primary-foreground shadow-button-primary transition-colors hover:bg-primary/90 active:shadow-button-inset",
1854
+ className: "mt-3 inline-flex items-center gap-1.5 rounded-button border border-primary bg-primary px-3 py-2 text-sm font-medium text-primary-foreground shadow-button-primary transition-colors hover:bg-primary/90 active:shadow-button-inset",
1745
1855
  children: t2("crm.quotes.createFirst")
1746
1856
  }
1747
1857
  )
@@ -1890,7 +2000,7 @@ function QuoteFormView({ quoteId, leadId, onSaved }) {
1890
2000
  observations,
1891
2001
  items: items.map((it) => ({ itemKind: it.itemKind, description: it.description, quantity: it.quantity, unitPrice: it.unitPrice, discount: it.discount }))
1892
2002
  };
1893
- const snapshot = React16.useRef(null);
2003
+ const snapshot = React17.useRef(null);
1894
2004
  useEffect(() => {
1895
2005
  if (!loadingExisting && snapshot.current === null) snapshot.current = JSON.stringify(currentFields);
1896
2006
  }, [loadingExisting]);
@@ -1904,7 +2014,7 @@ function QuoteFormView({ quoteId, leadId, onSaved }) {
1904
2014
  onDiscard: () => onSaved?.(),
1905
2015
  saveLabel: isEdit ? t2("crm.quoteForm.saveChanges") : t2("crm.quoteForm.saveQuote")
1906
2016
  });
1907
- if (loadingExisting) return /* @__PURE__ */ jsx(OrderFormSkeleton, {});
2017
+ if (loadingExisting) return /* @__PURE__ */ jsx(OrderFormSkeleton, { parentLabel: t2("crm.quotes.title"), onBack: () => onSaved?.() });
1908
2018
  const money = (v) => formatCurrency(v, currency);
1909
2019
  const sideSections = /* @__PURE__ */ jsxs(Fragment, { children: [
1910
2020
  /* @__PURE__ */ jsx(OrderFormBlock, { title: t2("crm.quoteForm.client"), children: /* @__PURE__ */ jsx(
@@ -2098,7 +2208,7 @@ function QuoteDetailView({ quoteId, onBack, onEdit, onInvoiceCreated }) {
2098
2208
  setRejecting(false);
2099
2209
  }
2100
2210
  }
2101
- if (loading) return /* @__PURE__ */ jsx(OrderDetailSkeleton, {});
2211
+ if (loading) return /* @__PURE__ */ jsx(OrderDetailSkeleton, { parentLabel: t2("crm.quotes.title"), onBack });
2102
2212
  if (!quote) {
2103
2213
  return /* @__PURE__ */ jsxs("div", { className: "space-y-5", children: [
2104
2214
  /* @__PURE__ */ jsx(SubpageHeader, { title: t2("crm.quoteDetail.title"), onBack, parentLabel: t2("crm.quotes.title") }),
@@ -2135,7 +2245,7 @@ function QuoteDetailView({ quoteId, onBack, onEdit, onInvoiceCreated }) {
2135
2245
  type: "button",
2136
2246
  onClick: () => setSendMenuOpen((p) => !p),
2137
2247
  disabled: sending,
2138
- className: "inline-flex items-center gap-1.5 rounded-lg border border-primary bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-button-primary transition-colors hover:bg-primary/90 active:shadow-button-inset disabled:opacity-50",
2248
+ className: "inline-flex items-center gap-1.5 rounded-button border border-primary bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-button-primary transition-colors hover:bg-primary/90 active:shadow-button-inset disabled:opacity-50",
2139
2249
  children: [
2140
2250
  /* @__PURE__ */ jsx(Send, { className: "h-3 w-3" }),
2141
2251
  sending ? t2("crm.quoteDetail.sending") : t2("crm.quoteDetail.send"),
@@ -2351,7 +2461,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
2351
2461
  /* @__PURE__ */ jsx("div", { className: "border-t" }),
2352
2462
  /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
2353
2463
  /* @__PURE__ */ jsx("div", { className: "h-4 w-36 rounded bg-muted/30 animate-pulse" }),
2354
- /* @__PURE__ */ jsx("div", { className: "rounded-xl border bg-card shadow-sm p-5 space-y-3", children: [1, 2, 3, 4].map((i) => /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 gap-4", children: [
2464
+ /* @__PURE__ */ jsx("div", { className: "rounded-card border bg-card shadow-sm p-5 space-y-3", children: [1, 2, 3, 4].map((i) => /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 gap-4", children: [
2355
2465
  /* @__PURE__ */ jsx("div", { className: "h-3 w-16 rounded bg-muted/30 animate-pulse" }),
2356
2466
  /* @__PURE__ */ jsx("div", { className: "col-span-2 h-3 w-24 rounded bg-muted/40 animate-pulse" })
2357
2467
  ] }, i)) })
@@ -2403,7 +2513,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
2403
2513
  "button",
2404
2514
  {
2405
2515
  onClick: () => onCreateQuote(leadId),
2406
- className: "inline-flex items-center gap-1.5 rounded-lg bg-primary border border-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 shadow-button-primary active:shadow-button-inset transition-colors",
2516
+ className: "inline-flex items-center gap-1.5 rounded-button bg-primary border border-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 shadow-button-primary active:shadow-button-inset transition-colors",
2407
2517
  children: [
2408
2518
  /* @__PURE__ */ jsx(FileText, { className: "h-3 w-3" }),
2409
2519
  " ",
@@ -2416,7 +2526,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
2416
2526
  /* @__PURE__ */ jsx("div", { className: "border-t" }),
2417
2527
  /* @__PURE__ */ jsxs("div", { children: [
2418
2528
  /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.contactInfo") }),
2419
- /* @__PURE__ */ jsx("div", { className: "rounded-xl border bg-card shadow-sm", children: /* @__PURE__ */ jsxs("dl", { className: "grid divide-y md:grid-cols-2 md:divide-y-0", children: [
2529
+ /* @__PURE__ */ jsx("div", { className: "rounded-card border bg-card shadow-sm", children: /* @__PURE__ */ jsxs("dl", { className: "grid divide-y md:grid-cols-2 md:divide-y-0", children: [
2420
2530
  /* @__PURE__ */ jsx("div", { className: "px-5 md:border-b", children: /* @__PURE__ */ jsx(FieldRow, { label: t2("crm.leadDetail.email"), value: lead.email ? /* @__PURE__ */ jsx("a", { href: `mailto:${lead.email}`, className: "text-primary hover:underline", children: lead.email }) : null }) }),
2421
2531
  /* @__PURE__ */ jsx("div", { className: "px-5 md:border-b", children: /* @__PURE__ */ jsx(
2422
2532
  FieldRow,
@@ -2437,7 +2547,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
2437
2547
  if (!fields.length && !utm.length && !attachments.length) return null;
2438
2548
  return /* @__PURE__ */ jsxs("div", { children: [
2439
2549
  /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.formAnswers") }),
2440
- /* @__PURE__ */ jsxs("div", { className: "rounded-xl border bg-card shadow-sm", children: [
2550
+ /* @__PURE__ */ jsxs("div", { className: "rounded-card border bg-card shadow-sm", children: [
2441
2551
  /* @__PURE__ */ jsx("dl", { className: "grid divide-y md:grid-cols-2 md:divide-y-0", children: fields.map(([key, value]) => /* @__PURE__ */ jsx("div", { className: "px-5 md:border-b md:last:border-b-0", children: /* @__PURE__ */ jsx(FieldRow, { label: humanizeKey2(key), value: renderFieldValue2(value) }) }, key)) }),
2442
2552
  attachments.length > 0 && /* @__PURE__ */ jsx("div", { className: "border-t px-5 py-3", children: /* @__PURE__ */ jsx(LeadAttachments, { attachments }) }),
2443
2553
  utm.length > 0 && /* @__PURE__ */ jsx("div", { className: "border-t px-5 py-3 flex flex-wrap gap-x-4 gap-y-1", children: utm.map(([key, value]) => /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
@@ -2451,7 +2561,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
2451
2561
  })(),
2452
2562
  deal && /* @__PURE__ */ jsxs("div", { children: [
2453
2563
  /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.pipeline") }),
2454
- /* @__PURE__ */ jsx("div", { className: "rounded-xl border bg-card shadow-sm", children: /* @__PURE__ */ jsxs("dl", { className: "grid divide-y md:grid-cols-2 md:divide-y-0", children: [
2564
+ /* @__PURE__ */ jsx("div", { className: "rounded-card border bg-card shadow-sm", children: /* @__PURE__ */ jsxs("dl", { className: "grid divide-y md:grid-cols-2 md:divide-y-0", children: [
2455
2565
  /* @__PURE__ */ jsx("div", { className: "px-5 md:border-b", children: /* @__PURE__ */ jsx(FieldRow, { label: t2("crm.leadDetail.stage"), value: deal.stageName ? /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1.5", children: [
2456
2566
  deal.stageColor && /* @__PURE__ */ jsx("span", { className: "h-2 w-2 rounded-full", style: { backgroundColor: deal.stageColor } }),
2457
2567
  deal.stageName
@@ -2463,7 +2573,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
2463
2573
  ] }),
2464
2574
  quotes.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
2465
2575
  /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.quotes") }),
2466
- /* @__PURE__ */ jsx("div", { className: "rounded-xl border bg-card shadow-sm divide-y", children: quotes.map((q) => /* @__PURE__ */ jsxs(
2576
+ /* @__PURE__ */ jsx("div", { className: "rounded-card border bg-card shadow-sm divide-y", children: quotes.map((q) => /* @__PURE__ */ jsxs(
2467
2577
  "div",
2468
2578
  {
2469
2579
  onClick: () => onViewQuote?.(q.id),
@@ -2487,7 +2597,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
2487
2597
  ] }),
2488
2598
  /* @__PURE__ */ jsxs("div", { children: [
2489
2599
  /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.details") }),
2490
- /* @__PURE__ */ jsx("div", { className: "rounded-xl border bg-card shadow-sm", children: /* @__PURE__ */ jsxs("dl", { className: "grid divide-y md:grid-cols-2 md:divide-y-0", children: [
2600
+ /* @__PURE__ */ jsx("div", { className: "rounded-card border bg-card shadow-sm", children: /* @__PURE__ */ jsxs("dl", { className: "grid divide-y md:grid-cols-2 md:divide-y-0", children: [
2491
2601
  /* @__PURE__ */ jsx("div", { className: "px-5 md:border-b", children: /* @__PURE__ */ jsx(FieldRow, { label: t2("crm.leadDetail.value"), value: lead.value != null && lead.value > 0 ? lead.value : null }) }),
2492
2602
  /* @__PURE__ */ jsx("div", { className: "px-5 md:border-b", children: /* @__PURE__ */ jsx(FieldRow, { label: t2("crm.leadDetail.assignedTo"), value: lead.assignedToName }) }),
2493
2603
  /* @__PURE__ */ jsx("div", { className: "px-5 md:border-b md:last:border-b-0", children: /* @__PURE__ */ jsx(
@@ -2522,14 +2632,204 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
2522
2632
  ] }),
2523
2633
  lead.tags && lead.tags.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
2524
2634
  /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.tags") }),
2525
- /* @__PURE__ */ jsx("div", { className: "rounded-xl border bg-card shadow-sm px-5 py-4", children: /* @__PURE__ */ jsx("div", { className: "flex gap-1.5 flex-wrap", children: lead.tags.map((tag) => /* @__PURE__ */ jsx("span", { className: "inline-flex items-center rounded-full bg-muted px-2.5 py-0.5 text-[10px] font-medium text-muted-foreground", children: tag }, tag)) }) })
2635
+ /* @__PURE__ */ jsx("div", { className: "rounded-card border bg-card shadow-sm px-5 py-4", children: /* @__PURE__ */ jsx("div", { className: "flex gap-1.5 flex-wrap", children: lead.tags.map((tag) => /* @__PURE__ */ jsx("span", { className: "inline-flex items-center rounded-full bg-muted px-2.5 py-0.5 text-[10px] font-medium text-muted-foreground", children: tag }, tag)) }) })
2526
2636
  ] }),
2527
2637
  lead.notes && /* @__PURE__ */ jsxs("div", { children: [
2528
2638
  /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.notes") }),
2529
- /* @__PURE__ */ jsx("div", { className: "rounded-xl border bg-card shadow-sm px-5 py-4", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground whitespace-pre-wrap", children: lead.notes }) })
2639
+ /* @__PURE__ */ jsx("div", { className: "rounded-card border bg-card shadow-sm px-5 py-4", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground whitespace-pre-wrap", children: lead.notes }) })
2530
2640
  ] })
2531
2641
  ] });
2532
2642
  }
2643
+ function OverviewTab2({ lead, deal, currency }) {
2644
+ const t2 = useTranslation();
2645
+ const tagDefs = useCrmStore((s) => s.tagDefs);
2646
+ const fetchTagDefs = useCrmStore((s) => s.fetchTagDefs);
2647
+ useEffect(() => {
2648
+ fetchTagDefs();
2649
+ }, []);
2650
+ const initial = lead.name.charAt(0).toUpperCase();
2651
+ const value = lead.value ?? deal?.value;
2652
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-5", children: [
2653
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3.5", children: [
2654
+ /* @__PURE__ */ jsx("div", { className: "flex h-14 w-14 shrink-0 items-center justify-center rounded-2xl bg-primary/10 text-primary text-xl font-bold", children: initial }),
2655
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
2656
+ /* @__PURE__ */ jsx("p", { className: "text-base font-semibold truncate", children: lead.name }),
2657
+ (lead.email || lead.phone) && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground truncate", children: lead.email || lead.phone }),
2658
+ /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex flex-wrap items-center gap-1.5", children: [
2659
+ /* @__PURE__ */ jsx(LeadStatusBadge, { status: lead.status }),
2660
+ lead.sourceName && /* @__PURE__ */ jsx("span", { className: "inline-flex items-center rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground", children: lead.sourceName })
2661
+ ] })
2662
+ ] })
2663
+ ] }),
2664
+ /* @__PURE__ */ jsxs("div", { className: "rounded-xl border divide-y", children: [
2665
+ value !== void 0 && value > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-4 py-3", children: [
2666
+ /* @__PURE__ */ jsx(DollarSign, { className: "h-4 w-4 text-muted-foreground shrink-0" }),
2667
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground flex-1", children: t2("crm.dealSidebar.value") }),
2668
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-bold", children: formatCurrency(value, currency) })
2669
+ ] }),
2670
+ lead.company && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-4 py-3", children: [
2671
+ /* @__PURE__ */ jsx(Building2, { className: "h-4 w-4 text-muted-foreground shrink-0" }),
2672
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground flex-1", children: t2("crm.leadSidebar.company") }),
2673
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-right", children: lead.company })
2674
+ ] }),
2675
+ deal?.stageName && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-4 py-3", children: [
2676
+ /* @__PURE__ */ jsx(Target, { className: "h-4 w-4 text-muted-foreground shrink-0" }),
2677
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground flex-1", children: t2("crm.dealSidebar.stage") }),
2678
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium", children: deal.stageName })
2679
+ ] }),
2680
+ lead.assignedToName && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-4 py-3", children: [
2681
+ /* @__PURE__ */ jsx(User, { className: "h-4 w-4 text-muted-foreground shrink-0" }),
2682
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground flex-1", children: t2("crm.dealSidebar.assignedTo") }),
2683
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-medium", children: lead.assignedToName })
2684
+ ] }),
2685
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-4 py-3", children: [
2686
+ /* @__PURE__ */ jsx(Clock, { className: "h-4 w-4 text-muted-foreground shrink-0" }),
2687
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground flex-1", children: t2("crm.dealSidebar.created") }),
2688
+ /* @__PURE__ */ jsxs("span", { className: "text-xs font-medium text-right", children: [
2689
+ formatDateTime(lead.createdAt, currency.locale),
2690
+ /* @__PURE__ */ jsxs("span", { className: "ml-1.5 text-muted-foreground", children: [
2691
+ "(",
2692
+ formatRelativeTime(lead.createdAt, currency.locale),
2693
+ ")"
2694
+ ] })
2695
+ ] })
2696
+ ] })
2697
+ ] }),
2698
+ (lead.email || lead.phone) && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
2699
+ /* @__PURE__ */ jsx("h4", { className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wider", children: t2("crm.dealSidebar.contact") }),
2700
+ /* @__PURE__ */ jsxs("div", { className: "rounded-xl border divide-y", children: [
2701
+ lead.email && /* @__PURE__ */ jsxs("a", { href: `mailto:${lead.email}`, className: "flex items-center gap-3 px-4 py-2.5 text-xs text-primary hover:bg-muted/30 transition-colors", children: [
2702
+ /* @__PURE__ */ jsx(Mail, { className: "h-3.5 w-3.5 shrink-0" }),
2703
+ " ",
2704
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: lead.email })
2705
+ ] }),
2706
+ lead.phone && /* @__PURE__ */ jsxs(
2707
+ PhoneLink,
2708
+ {
2709
+ phone: lead.phone,
2710
+ className: "flex items-center gap-3 px-4 py-2.5 text-xs text-primary hover:bg-muted/30 transition-colors hover:no-underline",
2711
+ children: [
2712
+ /* @__PURE__ */ jsx(MessageCircle, { className: "h-3.5 w-3.5 shrink-0" }),
2713
+ /* @__PURE__ */ jsx("span", { children: normalizePhone(lead.phone).display })
2714
+ ]
2715
+ }
2716
+ )
2717
+ ] })
2718
+ ] }),
2719
+ /* @__PURE__ */ jsx(FormAnswers, { lead }),
2720
+ lead.tags && lead.tags.length > 0 && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
2721
+ /* @__PURE__ */ jsx("h4", { className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wider", children: t2("crm.dealSidebar.tags") }),
2722
+ /* @__PURE__ */ jsx(TagChips, { tags: lead.tags, defs: tagDefs, size: "sm", className: "gap-1.5" })
2723
+ ] }),
2724
+ lead.notes && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
2725
+ /* @__PURE__ */ jsx("h4", { className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-wider", children: t2("crm.dealSidebar.notes") }),
2726
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground whitespace-pre-wrap leading-relaxed", children: lead.notes })
2727
+ ] })
2728
+ ] });
2729
+ }
2730
+ function LeadSidebar({ leadId, open, onClose, onViewDeal, onOpenLead }) {
2731
+ const t2 = useTranslation();
2732
+ const provider = useCrmProvider();
2733
+ const { currency } = useCrmConfig();
2734
+ const [lead, setLead] = useState(null);
2735
+ const [deal, setDeal] = useState(null);
2736
+ const [activities, setActivities] = useState([]);
2737
+ const [loading, setLoading] = useState(true);
2738
+ const [activitiesLoading, setActivitiesLoading] = useState(true);
2739
+ const [activeTab, setActiveTab] = useState("overview");
2740
+ useEffect(() => {
2741
+ if (!open || !leadId) return;
2742
+ setLoading(true);
2743
+ setActivitiesLoading(true);
2744
+ setActiveTab("overview");
2745
+ setLead(null);
2746
+ setDeal(null);
2747
+ setActivities([]);
2748
+ provider.getLeadById(leadId).then(async (l) => {
2749
+ setLead(l);
2750
+ if (l) setDeal(await provider.getDealByLeadId(leadId).catch(() => null));
2751
+ setLoading(false);
2752
+ });
2753
+ provider.getActivities({ leadId }).then((r) => {
2754
+ setActivities(r.data);
2755
+ setActivitiesLoading(false);
2756
+ });
2757
+ }, [leadId, open]);
2758
+ return /* @__PURE__ */ jsxs(
2759
+ RightRailPage,
2760
+ {
2761
+ title: loading ? t2("crm.leadSidebar.lead") : lead?.name ?? t2("crm.leadSidebar.lead"),
2762
+ open,
2763
+ onClose,
2764
+ width: "max-w-md",
2765
+ children: [
2766
+ /* @__PURE__ */ jsx("div", { className: "shrink-0 border-b px-5 pt-1", children: /* @__PURE__ */ jsx(
2767
+ HeaderTabs,
2768
+ {
2769
+ className: "-mb-px",
2770
+ value: activeTab,
2771
+ onChange: setActiveTab,
2772
+ tabs: [
2773
+ { value: "overview", label: t2("crm.dealSidebar.overview") },
2774
+ { value: "activity", label: t2("crm.dealSidebar.activity"), count: activities.length || void 0 }
2775
+ ]
2776
+ }
2777
+ ) }),
2778
+ /* @__PURE__ */ jsx(SheetBody, { children: loading ? /* @__PURE__ */ jsxs("div", { className: "space-y-5", children: [
2779
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3.5", children: [
2780
+ /* @__PURE__ */ jsx("div", { className: "h-14 w-14 rounded-2xl bg-muted/40 animate-pulse" }),
2781
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2 flex-1", children: [
2782
+ /* @__PURE__ */ jsx("div", { className: "h-4 w-32 rounded bg-muted/40 animate-pulse" }),
2783
+ /* @__PURE__ */ jsx("div", { className: "h-3 w-24 rounded bg-muted/30 animate-pulse" })
2784
+ ] })
2785
+ ] }),
2786
+ /* @__PURE__ */ jsx("div", { className: "rounded-xl border divide-y", children: [1, 2, 3].map((i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-3", children: [
2787
+ /* @__PURE__ */ jsx("div", { className: "h-3 w-20 rounded bg-muted/30 animate-pulse" }),
2788
+ /* @__PURE__ */ jsx("div", { className: "h-3 w-24 rounded bg-muted/40 animate-pulse" })
2789
+ ] }, i)) })
2790
+ ] }) : lead ? /* @__PURE__ */ jsxs(Fragment, { children: [
2791
+ activeTab === "overview" && /* @__PURE__ */ jsx(OverviewTab2, { lead, deal, currency }),
2792
+ activeTab === "activity" && /* @__PURE__ */ jsx(ActivityTimeline, { activities, loading: activitiesLoading })
2793
+ ] }) : /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t2("crm.leadDetail.leadNotFound") }) }) }),
2794
+ lead && /* @__PURE__ */ jsxs("p", { className: "shrink-0 border-t border-border/40 px-5 py-1.5 text-[10px] text-muted-foreground/60", children: [
2795
+ t2("crm.dealSidebar.created"),
2796
+ " ",
2797
+ lead.createdAt?.slice(0, 10),
2798
+ lead.updatedAt ? ` \xB7 ${t2("crm.dealSidebar.updated")} ${lead.updatedAt.slice(0, 10)}` : ""
2799
+ ] }),
2800
+ lead && (deal || onOpenLead) && /* @__PURE__ */ jsxs(SheetFooter, { children: [
2801
+ deal && onViewDeal && /* @__PURE__ */ jsxs(
2802
+ "button",
2803
+ {
2804
+ onClick: () => onViewDeal(deal.id),
2805
+ className: "flex-1 inline-flex items-center justify-center gap-2 rounded-lg border px-3 py-2.5 text-xs font-medium hover:bg-muted bg-card shadow-button active:shadow-button-inset transition-colors",
2806
+ children: [
2807
+ t2("crm.leadSidebar.viewDeal"),
2808
+ " ",
2809
+ /* @__PURE__ */ jsx(ArrowRight, { className: "h-3 w-3" })
2810
+ ]
2811
+ }
2812
+ ),
2813
+ onOpenLead && /* @__PURE__ */ jsxs(
2814
+ "button",
2815
+ {
2816
+ onClick: () => {
2817
+ onOpenLead(lead.id);
2818
+ onClose();
2819
+ },
2820
+ className: "flex-1 inline-flex items-center justify-center gap-2 rounded-lg border px-3 py-2.5 text-xs font-medium hover:bg-muted bg-card shadow-button active:shadow-button-inset transition-colors",
2821
+ children: [
2822
+ t2("crm.leadSidebar.openFullProfile"),
2823
+ " ",
2824
+ /* @__PURE__ */ jsx(ArrowRight, { className: "h-3 w-3" })
2825
+ ]
2826
+ }
2827
+ )
2828
+ ] })
2829
+ ]
2830
+ }
2831
+ );
2832
+ }
2533
2833
 
2534
2834
  // src/types.ts
2535
2835
  var SYSTEM_ACTIVITY_TYPES = [
@@ -2572,7 +2872,7 @@ var TYPE_CONFIG = {
2572
2872
  var SYSTEM_TYPES = new Set(SYSTEM_ACTIVITY_TYPES);
2573
2873
  var MANUAL_TYPES = Object.keys(TYPE_CONFIG).filter((t2) => !SYSTEM_TYPES.has(t2));
2574
2874
  function ActivitySkeleton() {
2575
- return /* @__PURE__ */ jsx("div", { className: "space-y-2", children: [1, 2, 3, 4, 5].map((i) => /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 rounded-lg border bg-card shadow-sm p-4", children: [
2875
+ return /* @__PURE__ */ jsx("div", { className: "space-y-2", children: [1, 2, 3, 4, 5].map((i) => /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 rounded-card border bg-card shadow-sm p-4", children: [
2576
2876
  /* @__PURE__ */ jsx("div", { className: "h-9 w-9 rounded-lg bg-muted/40 animate-pulse shrink-0" }),
2577
2877
  /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-2 pt-0.5", children: [
2578
2878
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
@@ -2587,9 +2887,9 @@ function ActivitySkeleton() {
2587
2887
  }
2588
2888
  function ActivityListView({ onOpenLead, onOpenQuote } = {}) {
2589
2889
  const t2 = useTranslation();
2590
- const provider = useCrmProvider();
2591
2890
  const { currency } = useCrmConfig();
2592
2891
  const [selectedDealId, setSelectedDealId] = useState(null);
2892
+ const [selectedLeadId, setSelectedLeadId] = useState(null);
2593
2893
  const activities = useCrmStore((s) => s.activities);
2594
2894
  const activitiesLoading = useCrmStore((s) => s.activitiesLoading);
2595
2895
  const fetchActivities = useCrmStore((s) => s.fetchActivities);
@@ -2681,18 +2981,19 @@ function ActivityListView({ onOpenLead, onOpenQuote } = {}) {
2681
2981
  const Icon = cfg.icon;
2682
2982
  const isSystem = SYSTEM_TYPES.has(a.activityType);
2683
2983
  const isOverdue = !a.completedAt && a.dueDate && a.dueDate < (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
2684
- const openRecord = a.dealId ? () => setSelectedDealId(a.dealId) : a.leadId ? () => {
2685
- void provider.getDealByLeadId(a.leadId).then((deal) => {
2686
- if (deal) setSelectedDealId(deal.id);
2687
- else onOpenLead?.(a.leadId);
2688
- });
2984
+ const openRecord = a.dealId ? () => {
2985
+ setSelectedLeadId(null);
2986
+ setSelectedDealId(a.dealId);
2987
+ } : a.leadId ? () => {
2988
+ setSelectedDealId(null);
2989
+ setSelectedLeadId(a.leadId);
2689
2990
  } : void 0;
2690
2991
  return /* @__PURE__ */ jsxs(
2691
2992
  "div",
2692
2993
  {
2693
2994
  onClick: openRecord,
2694
2995
  role: openRecord ? "button" : void 0,
2695
- className: `group flex items-start gap-3 rounded-lg border bg-card p-4 transition-colors ${isOverdue ? "border-destructive/30 dark:border-destructive/20" : ""} ${openRecord ? "cursor-pointer hover:bg-muted/30" : ""}`,
2996
+ className: `group flex items-start gap-3 rounded-card border bg-card p-4 transition-colors ${isOverdue ? "border-destructive/30 dark:border-destructive/20" : ""} ${openRecord ? "cursor-pointer hover:bg-muted/30" : ""}`,
2696
2997
  children: [
2697
2998
  /* @__PURE__ */ jsx("div", { className: `flex h-9 w-9 items-center justify-center rounded-lg shrink-0 ${cfg.color}`, children: /* @__PURE__ */ jsx(Icon, { className: "h-4 w-4" }) }),
2698
2999
  /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0 pt-0.5", children: [
@@ -2751,9 +3052,25 @@ function ActivityListView({ onOpenLead, onOpenQuote } = {}) {
2751
3052
  dealId: selectedDealId ?? "",
2752
3053
  open: !!selectedDealId,
2753
3054
  onClose: () => setSelectedDealId(null),
2754
- onViewLead: onOpenLead,
3055
+ onViewLead: (id) => {
3056
+ setSelectedDealId(null);
3057
+ setSelectedLeadId(id);
3058
+ },
2755
3059
  onViewQuote: onOpenQuote
2756
3060
  }
3061
+ ),
3062
+ /* @__PURE__ */ jsx(
3063
+ LeadSidebar,
3064
+ {
3065
+ leadId: selectedLeadId ?? "",
3066
+ open: !!selectedLeadId,
3067
+ onClose: () => setSelectedLeadId(null),
3068
+ onViewDeal: (id) => {
3069
+ setSelectedLeadId(null);
3070
+ setSelectedDealId(id);
3071
+ },
3072
+ onOpenLead
3073
+ }
2757
3074
  )
2758
3075
  ] });
2759
3076
  }
@@ -2864,7 +3181,12 @@ function CrmPage({ config, provider, store, registries }) {
2864
3181
  const renderView = createViewRouter([
2865
3182
  { id: "pipeline", render: () => /* @__PURE__ */ jsx(PipelineView, { onViewLead: (id) => navigate(`leads-detail:${id}`), onViewQuote: (id) => navigate(`quotes-detail:${id}`), onAddLead: () => navigate("leads-new"), onOpenSettings: openStageSettings }) },
2866
3183
  { id: "leads-list", render: () => /* @__PURE__ */ jsx(LeadListView, { onNew: () => navigate("leads-new"), onEdit: (id) => navigate(`leads-detail:${id}`) }) },
2867
- { id: "leads-new", render: () => /* @__PURE__ */ jsx(LeadFormView, { onSaved: (id) => id ? navigate(`leads-detail:${id}`) : navigate("leads-list") }) },
3184
+ // The form lives in the right column, so the list it is added to stays on
3185
+ // screen behind it — rendered here, not replaced.
3186
+ { id: "leads-new", render: () => /* @__PURE__ */ jsxs(Fragment, { children: [
3187
+ /* @__PURE__ */ jsx(LeadListView, { onNew: () => navigate("leads-new"), onEdit: (id) => navigate(`leads-detail:${id}`) }),
3188
+ /* @__PURE__ */ jsx(LeadFormView, { onSaved: (id) => id ? navigate(`leads-detail:${id}`) : navigate("leads-list") })
3189
+ ] }) },
2868
3190
  { id: "quotes-new", render: () => {
2869
3191
  const hashParams = new URLSearchParams(window.location.hash.split("?")[1] ?? "");
2870
3192
  const lid = hashParams.get("leadId") ?? void 0;
@@ -2887,7 +3209,7 @@ function CrmPage({ config, provider, store, registries }) {
2887
3209
  nav,
2888
3210
  navVariant: config.moduleNav,
2889
3211
  showHeader: isSummary,
2890
- viewKey: view,
3212
+ viewKey: view === "leads-new" ? "leads-list" : view,
2891
3213
  direction,
2892
3214
  headerAction: /* @__PURE__ */ jsx(
2893
3215
  ModuleActionBar,
@@ -4554,6 +4876,7 @@ function createSupabaseCrmProvider(options) {
4554
4876
  }
4555
4877
  function createCrmStore(provider) {
4556
4878
  let lastActivitiesQuery = {};
4879
+ let lastLeadsQuery = {};
4557
4880
  let lastBoard = null;
4558
4881
  return createStore$1((set, get) => ({
4559
4882
  pipelines: [],
@@ -4611,6 +4934,7 @@ function createCrmStore(provider) {
4611
4934
  });
4612
4935
  },
4613
4936
  async fetchLeads(query) {
4937
+ lastLeadsQuery = query;
4614
4938
  return dedup("crm:leads:" + JSON.stringify(query), async () => {
4615
4939
  set({ leadsLoading: true });
4616
4940
  const result = await provider.getLeads(query);
@@ -4695,6 +5019,18 @@ function createCrmStore(provider) {
4695
5019
  throw err;
4696
5020
  }
4697
5021
  },
5022
+ async updateLead(id, data) {
5023
+ return provider.updateLead(id, data);
5024
+ },
5025
+ async refreshLeads() {
5026
+ const [leadsResult, summary] = await Promise.all([
5027
+ provider.getLeads(lastLeadsQuery),
5028
+ provider.getSummary(),
5029
+ get().refreshBoard()
5030
+ ]);
5031
+ set({ leads: leadsResult.data, leadsTotal: leadsResult.total, summary });
5032
+ void get().refreshActivities();
5033
+ },
4698
5034
  async createDeal(input) {
4699
5035
  try {
4700
5036
  const deal = await provider.createDeal(input);
@@ -4890,7 +5226,7 @@ function createCrmStore(provider) {
4890
5226
  try {
4891
5227
  await provider.archiveLead(leadId);
4892
5228
  const [leadsResult, summary] = await Promise.all([
4893
- provider.getLeads({}),
5229
+ provider.getLeads(lastLeadsQuery),
4894
5230
  provider.getSummary(),
4895
5231
  get().refreshBoard()
4896
5232
  ]);
@@ -5168,6 +5504,26 @@ var en = {
5168
5504
  "crm.leadForm.saving": "Saving...",
5169
5505
  "crm.leadForm.subtitle": "Capture a new lead",
5170
5506
  "crm.leadForm.title": "New Lead",
5507
+ "crm.leadSidebar.company": "Company",
5508
+ "crm.leadSidebar.lead": "Lead",
5509
+ "crm.leadSidebar.openFullProfile": "Open full profile",
5510
+ "crm.leadSidebar.viewDeal": "View deal",
5511
+ "crm.leads.statusLost": "Lost",
5512
+ "crm.leads.bulkArchive": "Archive",
5513
+ "crm.leads.bulkArchiveDesc": "They leave the list and the pipeline board. This cannot be undone from here.",
5514
+ "crm.leads.bulkArchiveDone": "{{count}} lead(s) archived",
5515
+ "crm.leads.bulkArchiveFailed": "{{count}} lead(s) could not be archived",
5516
+ "crm.leads.bulkArchiveTitle": "Archive {{count}} lead(s)?",
5517
+ "crm.leads.bulkKeep": "Keep",
5518
+ "crm.leads.bulkSetStatus": "Mark as {{status}}",
5519
+ "crm.leads.bulkStatusDone": "{{count}} lead(s) updated",
5520
+ "crm.leads.bulkStatusFailed": "{{count}} lead(s) could not be updated",
5521
+ "crm.leads.bulkStatusNone": "The selected leads already have this status.",
5522
+ "crm.leads.statusContacted": "Contacted",
5523
+ "crm.leads.statusConverted": "Converted",
5524
+ "crm.leads.statusNew": "New",
5525
+ "crm.leads.statusQualified": "Qualified",
5526
+ "crm.leads.statusUnqualified": "Unqualified",
5171
5527
  "crm.leads.captureFirst": "Capture your first lead",
5172
5528
  "crm.leads.contactCol": "Contact",
5173
5529
  "crm.leads.name": "Name",
@@ -5480,6 +5836,26 @@ var ptBR = {
5480
5836
  "crm.leadForm.saving": "Salvando...",
5481
5837
  "crm.leadForm.subtitle": "Capturar um novo lead",
5482
5838
  "crm.leadForm.title": "Novo Lead",
5839
+ "crm.leadSidebar.company": "Empresa",
5840
+ "crm.leadSidebar.lead": "Lead",
5841
+ "crm.leadSidebar.openFullProfile": "Abrir ficha completa",
5842
+ "crm.leadSidebar.viewDeal": "Ver neg\xF3cio",
5843
+ "crm.leads.statusLost": "Perdido",
5844
+ "crm.leads.bulkArchive": "Arquivar",
5845
+ "crm.leads.bulkArchiveDesc": "Eles saem da lista e do quadro do funil. N\xE3o d\xE1 para desfazer por aqui.",
5846
+ "crm.leads.bulkArchiveDone": "{{count}} lead(s) arquivado(s)",
5847
+ "crm.leads.bulkArchiveFailed": "{{count}} lead(s) n\xE3o puderam ser arquivados",
5848
+ "crm.leads.bulkArchiveTitle": "Arquivar {{count}} lead(s)?",
5849
+ "crm.leads.bulkKeep": "Manter",
5850
+ "crm.leads.bulkSetStatus": "Marcar como {{status}}",
5851
+ "crm.leads.bulkStatusDone": "{{count}} lead(s) atualizado(s)",
5852
+ "crm.leads.bulkStatusFailed": "{{count}} lead(s) n\xE3o puderam ser atualizados",
5853
+ "crm.leads.bulkStatusNone": "Os leads selecionados j\xE1 est\xE3o nesse status.",
5854
+ "crm.leads.statusContacted": "Contatado",
5855
+ "crm.leads.statusConverted": "Convertido",
5856
+ "crm.leads.statusNew": "Novo",
5857
+ "crm.leads.statusQualified": "Qualificado",
5858
+ "crm.leads.statusUnqualified": "Desqualificado",
5483
5859
  "crm.leads.captureFirst": "Capture seu primeiro lead",
5484
5860
  "crm.leads.contactCol": "Contato",
5485
5861
  "crm.leads.name": "Nome",
@@ -5772,10 +6148,11 @@ function createCrmPlugin(options) {
5772
6148
  () => createMockCrmProvider({ activityTypes })
5773
6149
  );
5774
6150
  const store = createCrmStore(provider);
5775
- const PageComponent = () => React16.createElement(CrmPage, { config, provider, store, registries: crmRegistries2 });
6151
+ const PageComponent = () => React17.createElement(CrmPage, { config, provider, store, registries: crmRegistries2 });
5776
6152
  const dashboardWidgets = createCrmDashboardWidgets({ config, provider, store });
5777
6153
  return {
5778
6154
  id: "crm",
6155
+ defaultAgentRole: "growth",
5779
6156
  name: config.labels.pageTitle,
5780
6157
  icon: "Filter",
5781
6158
  version: "1.0.0",
@@ -6036,13 +6413,12 @@ function createCrmPlugin(options) {
6036
6413
  label: "Sales & CRM",
6037
6414
  icon: "Filter",
6038
6415
  component: (() => {
6039
- const Tab = () => React16.createElement(
6416
+ const Tab = () => React17.createElement(
6040
6417
  CrmContextProvider,
6041
6418
  { config, provider, store },
6042
- React16.createElement(PluginSettingsPanel, {
6419
+ React17.createElement(PluginSettingsPanel, {
6043
6420
  title: "Sales & CRM",
6044
- subtitle: "Pipeline, lead management, and CRM properties",
6045
- generalSettings: React16.createElement(CrmGeneralSettings),
6421
+ generalSettings: React17.createElement(CrmGeneralSettings),
6046
6422
  registries: crmRegistries2,
6047
6423
  hostPluginId: "crm",
6048
6424
  routeBase: "/settings/crm"