@fayz-ai/plugin-crm 0.9.3 → 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/components/ActivityTimeline.d.ts +7 -0
- package/dist/components/ActivityTimeline.d.ts.map +1 -0
- package/dist/components/AutomationBolt.d.ts.map +1 -1
- package/dist/components/BoardFilters.d.ts.map +1 -1
- package/dist/components/FormAnswers.d.ts +8 -0
- package/dist/components/FormAnswers.d.ts.map +1 -0
- package/dist/components/LeadStatusBadge.d.ts +14 -0
- package/dist/components/LeadStatusBadge.d.ts.map +1 -0
- package/dist/index.js +730 -342
- package/dist/index.js.map +1 -1
- package/dist/locales/en.d.ts.map +1 -1
- package/dist/locales/pt-BR.d.ts.map +1 -1
- package/dist/store.d.ts +5 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/views/ActivityListView.d.ts.map +1 -1
- package/dist/views/CrmPage.d.ts.map +1 -1
- package/dist/views/DealSidebar.d.ts.map +1 -1
- package/dist/views/LeadListView.d.ts.map +1 -1
- package/dist/views/LeadSidebar.d.ts +11 -0
- package/dist/views/LeadSidebar.d.ts.map +1 -0
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
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,
|
|
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
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
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__ */
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
e
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
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
|
-
|
|
708
|
-
|
|
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
|
-
|
|
717
|
-
{ value: "overview", label:
|
|
718
|
-
{ value: "activity", label:
|
|
719
|
-
{ value: "quotes", label:
|
|
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
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
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
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
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
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
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 {};
|
|
@@ -1057,92 +1080,104 @@ function BoardFilters({
|
|
|
1057
1080
|
selectedTags.includes(slug) ? selectedTags.filter((s) => s !== slug) : [...selectedTags, slug]
|
|
1058
1081
|
);
|
|
1059
1082
|
};
|
|
1060
|
-
return /* @__PURE__ */
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
{ value: "24h", label: t2("crm.filters.period24h") },
|
|
1067
|
-
{ value: "7d", label: t2("crm.filters.period7d") },
|
|
1068
|
-
{ value: "custom", label: t2("crm.filters.periodCustom") }
|
|
1069
|
-
],
|
|
1070
|
-
value: period,
|
|
1071
|
-
onChange: onPeriodChange,
|
|
1072
|
-
"aria-label": t2("crm.filters.period")
|
|
1073
|
-
}
|
|
1074
|
-
),
|
|
1075
|
-
period === "custom" && // As duas pontas usam a MESMA chrome do segmentado ao lado (variant
|
|
1076
|
-
// toolbar), com a seta ligando uma à outra — antes eram dois campos de
|
|
1077
|
-
// formulário em altura cheia no meio de uma barra de pills.
|
|
1078
|
-
/* @__PURE__ */ jsxs("div", { className: "inline-flex items-center gap-1.5", children: [
|
|
1079
|
-
/* @__PURE__ */ jsx(
|
|
1080
|
-
DatePicker,
|
|
1081
|
-
{
|
|
1082
|
-
variant: "toolbar",
|
|
1083
|
-
value: customFrom,
|
|
1084
|
-
onChange: (v) => onCustomChange(v, v > customTo ? v : customTo)
|
|
1085
|
-
}
|
|
1086
|
-
),
|
|
1087
|
-
/* @__PURE__ */ jsx(ArrowRight, { className: "h-3 w-3 shrink-0 text-muted-foreground", "aria-hidden": true }),
|
|
1088
|
-
/* @__PURE__ */ jsx(
|
|
1089
|
-
DatePicker,
|
|
1090
|
-
{
|
|
1091
|
-
variant: "toolbar",
|
|
1092
|
-
value: customTo,
|
|
1093
|
-
onChange: (v) => onCustomChange(v < customFrom ? v : customFrom, v)
|
|
1094
|
-
}
|
|
1095
|
-
)
|
|
1096
|
-
] }),
|
|
1097
|
-
options.length > 0 && /* @__PURE__ */ jsxs("div", { className: "relative", ref: tagsRef, children: [
|
|
1098
|
-
/* @__PURE__ */ jsxs(
|
|
1099
|
-
"button",
|
|
1083
|
+
return /* @__PURE__ */ jsx(
|
|
1084
|
+
PageToolbar,
|
|
1085
|
+
{
|
|
1086
|
+
className,
|
|
1087
|
+
range: /* @__PURE__ */ jsx(
|
|
1088
|
+
RangeControl,
|
|
1100
1089
|
{
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1090
|
+
options: [
|
|
1091
|
+
{ value: "all", label: t2("crm.filters.periodAll") },
|
|
1092
|
+
{ value: "24h", label: t2("crm.filters.period24h") },
|
|
1093
|
+
{ value: "7d", label: t2("crm.filters.period7d") },
|
|
1094
|
+
{ value: "custom", label: t2("crm.filters.periodCustom") }
|
|
1095
|
+
],
|
|
1096
|
+
value: period,
|
|
1097
|
+
onChange: (v) => onPeriodChange(v),
|
|
1098
|
+
children: period === "custom" && /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
1099
|
+
/* @__PURE__ */ jsx(
|
|
1100
|
+
DatePicker,
|
|
1101
|
+
{
|
|
1102
|
+
variant: "toolbar",
|
|
1103
|
+
value: customFrom,
|
|
1104
|
+
onChange: (v) => onCustomChange(v, v > customTo ? v : customTo)
|
|
1105
|
+
}
|
|
1106
|
+
),
|
|
1107
|
+
/* @__PURE__ */ jsx(ArrowRight, { className: "h-3 w-3 shrink-0 text-muted-foreground", "aria-hidden": true }),
|
|
1108
|
+
/* @__PURE__ */ jsx(
|
|
1109
|
+
DatePicker,
|
|
1110
|
+
{
|
|
1111
|
+
variant: "toolbar",
|
|
1112
|
+
value: customTo,
|
|
1113
|
+
onChange: (v) => onCustomChange(v < customFrom ? v : customFrom, v)
|
|
1114
|
+
}
|
|
1115
|
+
)
|
|
1116
|
+
] })
|
|
1108
1117
|
}
|
|
1109
1118
|
),
|
|
1110
|
-
|
|
1119
|
+
filters: options.length > 0 && /* @__PURE__ */ jsxs("span", { className: "relative", ref: tagsRef, children: [
|
|
1120
|
+
/* @__PURE__ */ jsx(
|
|
1121
|
+
ToolbarButton,
|
|
1122
|
+
{
|
|
1123
|
+
icon: Tag,
|
|
1124
|
+
caret: true,
|
|
1125
|
+
onClick: () => setTagsOpen((o) => !o),
|
|
1126
|
+
className: selectedTags.length ? "text-primary" : void 0,
|
|
1127
|
+
children: selectedTags.length ? t2("crm.filters.tagsSelected", { count: selectedTags.length }) : t2("crm.filters.tags")
|
|
1128
|
+
}
|
|
1129
|
+
),
|
|
1130
|
+
tagsOpen && /* @__PURE__ */ jsx("div", { className: "absolute left-0 z-50 mt-1 max-h-72 w-56 overflow-y-auto rounded-lg border bg-popover p-1 shadow-md", children: options.map((slug) => {
|
|
1131
|
+
const def = tagDefs.get(slug);
|
|
1132
|
+
const checked = selectedTags.includes(slug);
|
|
1133
|
+
return /* @__PURE__ */ jsxs(
|
|
1134
|
+
"button",
|
|
1135
|
+
{
|
|
1136
|
+
type: "button",
|
|
1137
|
+
onClick: () => toggle(slug),
|
|
1138
|
+
className: "flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs hover:bg-muted",
|
|
1139
|
+
children: [
|
|
1140
|
+
/* @__PURE__ */ jsx(
|
|
1141
|
+
"span",
|
|
1142
|
+
{
|
|
1143
|
+
className: `flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded border ${checked ? "border-primary bg-primary text-primary-foreground" : "border-border"}`,
|
|
1144
|
+
children: checked && /* @__PURE__ */ jsx("span", { className: "text-[9px] leading-none", children: "\u2713" })
|
|
1145
|
+
}
|
|
1146
|
+
),
|
|
1147
|
+
def?.color && /* @__PURE__ */ jsx("span", { className: "h-2 w-2 shrink-0 rounded-full", style: { backgroundColor: def.color } }),
|
|
1148
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: def?.name ?? humanizeTag(slug) })
|
|
1149
|
+
]
|
|
1150
|
+
},
|
|
1151
|
+
slug
|
|
1152
|
+
);
|
|
1153
|
+
}) })
|
|
1154
|
+
] }),
|
|
1155
|
+
chips: selectedTags.map((slug) => {
|
|
1111
1156
|
const def = tagDefs.get(slug);
|
|
1112
|
-
const checked = selectedTags.includes(slug);
|
|
1113
1157
|
return /* @__PURE__ */ jsxs(
|
|
1114
|
-
"
|
|
1158
|
+
"span",
|
|
1115
1159
|
{
|
|
1116
|
-
|
|
1117
|
-
onClick: () => toggle(slug),
|
|
1118
|
-
className: "flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs hover:bg-muted",
|
|
1160
|
+
className: "inline-flex h-[26px] shrink-0 items-center gap-1 rounded-full border border-primary/30 bg-primary/10 py-1 pl-2.5 pr-1 text-xs font-medium text-primary",
|
|
1119
1161
|
children: [
|
|
1162
|
+
def?.color && /* @__PURE__ */ jsx("span", { className: "h-2 w-2 shrink-0 rounded-full", style: { backgroundColor: def.color } }),
|
|
1163
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[10rem] truncate", children: def?.name ?? humanizeTag(slug) }),
|
|
1120
1164
|
/* @__PURE__ */ jsx(
|
|
1121
|
-
"
|
|
1165
|
+
"button",
|
|
1122
1166
|
{
|
|
1123
|
-
|
|
1124
|
-
|
|
1167
|
+
type: "button",
|
|
1168
|
+
onClick: () => onTagsChange(selectedTags.filter((s) => s !== slug)),
|
|
1169
|
+
"aria-label": `${t2("crm.filters.clearTags")}: ${def?.name ?? slug}`,
|
|
1170
|
+
className: "rounded-full p-0.5 transition-colors hover:bg-primary/20",
|
|
1171
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
1125
1172
|
}
|
|
1126
|
-
)
|
|
1127
|
-
def?.color && /* @__PURE__ */ jsx("span", { className: "h-2 w-2 shrink-0 rounded-full", style: { backgroundColor: def.color } }),
|
|
1128
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: def?.name ?? humanizeTag(slug) })
|
|
1173
|
+
)
|
|
1129
1174
|
]
|
|
1130
1175
|
},
|
|
1131
1176
|
slug
|
|
1132
1177
|
);
|
|
1133
|
-
})
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
"button",
|
|
1137
|
-
{
|
|
1138
|
-
type: "button",
|
|
1139
|
-
onClick: () => onTagsChange([]),
|
|
1140
|
-
className: "inline-flex h-[26px] items-center gap-1 rounded-md px-1.5 text-xs text-muted-foreground hover:text-foreground",
|
|
1141
|
-
title: t2("crm.filters.clearTags"),
|
|
1142
|
-
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
1143
|
-
}
|
|
1144
|
-
)
|
|
1145
|
-
] });
|
|
1178
|
+
})
|
|
1179
|
+
}
|
|
1180
|
+
);
|
|
1146
1181
|
}
|
|
1147
1182
|
function localDate(offsetDays = 0) {
|
|
1148
1183
|
const d = /* @__PURE__ */ new Date();
|
|
@@ -1156,7 +1191,7 @@ function PipelineSkeleton() {
|
|
|
1156
1191
|
/* @__PURE__ */ jsx("div", { className: "h-3 w-16 rounded bg-muted/40 animate-pulse" }),
|
|
1157
1192
|
/* @__PURE__ */ jsx("div", { className: "h-3 w-5 rounded bg-muted/30 animate-pulse" })
|
|
1158
1193
|
] }),
|
|
1159
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: Array.from({ length: col <= 2 ? 2 : 1 }).map((_, i) => /* @__PURE__ */ jsxs("div", { className: "rounded-
|
|
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: [
|
|
1160
1195
|
/* @__PURE__ */ jsx("div", { className: "h-4 w-3/4 rounded bg-muted/40 animate-pulse" }),
|
|
1161
1196
|
/* @__PURE__ */ jsx("div", { className: "h-3 w-1/2 rounded bg-muted/30 animate-pulse" }),
|
|
1162
1197
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pt-1", children: [
|
|
@@ -1175,7 +1210,7 @@ function DealCard({ deal, saving, currency, tagDefs, onClick, onArchive, onDragS
|
|
|
1175
1210
|
onDragStart,
|
|
1176
1211
|
onDragEnd,
|
|
1177
1212
|
onClick,
|
|
1178
|
-
className: `group rounded-
|
|
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"}`,
|
|
1179
1214
|
children: [
|
|
1180
1215
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1181
1216
|
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium truncate", children: deal.title }),
|
|
@@ -1468,13 +1503,25 @@ function PipelineView({ onDealClick, onViewLead, onViewQuote, onAddLead, onOpenS
|
|
|
1468
1503
|
)
|
|
1469
1504
|
] });
|
|
1470
1505
|
}
|
|
1471
|
-
var
|
|
1472
|
-
{ value: "new",
|
|
1473
|
-
{ value: "contacted",
|
|
1474
|
-
{ value: "qualified",
|
|
1475
|
-
{ value: "unqualified",
|
|
1476
|
-
{ value: "converted",
|
|
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" }
|
|
1477
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
|
+
}
|
|
1478
1525
|
var columns = [
|
|
1479
1526
|
{ accessorKey: "name", header: "Name", cell: ({ getValue }) => /* @__PURE__ */ jsx("span", { className: "font-medium", children: getValue() }) },
|
|
1480
1527
|
{
|
|
@@ -1490,11 +1537,7 @@ var columns = [
|
|
|
1490
1537
|
{
|
|
1491
1538
|
accessorKey: "status",
|
|
1492
1539
|
header: "Status",
|
|
1493
|
-
cell: ({ getValue }) => {
|
|
1494
|
-
const status = getValue();
|
|
1495
|
-
const opt = STATUS_OPTIONS.find((o) => o.value === status);
|
|
1496
|
-
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 });
|
|
1497
|
-
}
|
|
1540
|
+
cell: ({ getValue }) => /* @__PURE__ */ jsx(LeadStatusBadge, { status: getValue() })
|
|
1498
1541
|
},
|
|
1499
1542
|
{
|
|
1500
1543
|
// When the lead came in. The list is already sorted by it (provider orders
|
|
@@ -1517,15 +1560,73 @@ var columns = [
|
|
|
1517
1560
|
];
|
|
1518
1561
|
function LeadListView({ onNew, onEdit }) {
|
|
1519
1562
|
const t2 = useTranslation();
|
|
1563
|
+
const can = usePermissionOptional();
|
|
1564
|
+
const provider = useCrmProvider();
|
|
1520
1565
|
const leads = useCrmStore((s) => s.leads);
|
|
1521
1566
|
const leadsLoading = useCrmStore((s) => s.leadsLoading);
|
|
1522
1567
|
const fetchLeads = useCrmStore((s) => s.fetchLeads);
|
|
1568
|
+
const updateLead = useCrmStore((s) => s.updateLead);
|
|
1569
|
+
const refreshLeads = useCrmStore((s) => s.refreshLeads);
|
|
1523
1570
|
const [search, setSearch] = useState("");
|
|
1524
1571
|
const [statusFilter, setStatusFilter] = useState([]);
|
|
1572
|
+
const [archiveTarget, setArchiveTarget] = useState(null);
|
|
1573
|
+
const [bulkBusy, setBulkBusy] = useState(false);
|
|
1525
1574
|
useEffect(() => {
|
|
1526
1575
|
fetchLeads({ status: statusFilter.length > 0 ? statusFilter : void 0, search: search || void 0 });
|
|
1527
1576
|
}, [statusFilter, search]);
|
|
1528
|
-
const tags = useMemo(() =>
|
|
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]);
|
|
1529
1630
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
1530
1631
|
/* @__PURE__ */ jsx(SubpageHeader, { title: t2("crm.leads.title") }),
|
|
1531
1632
|
/* @__PURE__ */ jsx(
|
|
@@ -1543,12 +1644,34 @@ function LeadListView({ onNew, onEdit }) {
|
|
|
1543
1644
|
onTagChange: (v) => setStatusFilter(v ? [v] : []),
|
|
1544
1645
|
newLabel: t2("crm.leads.newLead"),
|
|
1545
1646
|
onNew,
|
|
1647
|
+
bulkActions,
|
|
1546
1648
|
onRowClick: (row) => onEdit?.(row.id),
|
|
1547
1649
|
emptyIcon: UserPlus,
|
|
1548
1650
|
emptyMessage: t2("crm.leads.noLeads"),
|
|
1549
1651
|
emptyActionLabel: onNew ? t2("crm.leads.captureFirst") : void 0,
|
|
1550
1652
|
onEmptyAction: onNew
|
|
1551
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
|
+
}
|
|
1552
1675
|
)
|
|
1553
1676
|
] });
|
|
1554
1677
|
}
|
|
@@ -1583,45 +1706,44 @@ function LeadFormView({ onSaved }) {
|
|
|
1583
1706
|
setSaving(false);
|
|
1584
1707
|
}
|
|
1585
1708
|
}
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
] });
|
|
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
|
+
);
|
|
1625
1747
|
}
|
|
1626
1748
|
var STATUS_COLORS = {
|
|
1627
1749
|
draft: "bg-muted text-muted-foreground",
|
|
@@ -1708,7 +1830,7 @@ function QuoteListView({ onNew, onEdit, onEditQuote }) {
|
|
|
1708
1830
|
SubpageHeader,
|
|
1709
1831
|
{
|
|
1710
1832
|
title: t2("crm.quotes.title"),
|
|
1711
|
-
actions: onNew && /* @__PURE__ */ jsxs("button", { onClick: onNew, className: "inline-flex items-center gap-1.5 rounded-
|
|
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: [
|
|
1712
1834
|
/* @__PURE__ */ jsx("span", { className: "h-3.5 w-3.5 inline-flex items-center justify-center", children: "+" }),
|
|
1713
1835
|
" ",
|
|
1714
1836
|
t2("crm.quotes.newQuote")
|
|
@@ -1729,7 +1851,7 @@ function QuoteListView({ onNew, onEdit, onEditQuote }) {
|
|
|
1729
1851
|
"button",
|
|
1730
1852
|
{
|
|
1731
1853
|
onClick: onNew,
|
|
1732
|
-
className: "mt-3 inline-flex items-center gap-1.5 rounded-
|
|
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",
|
|
1733
1855
|
children: t2("crm.quotes.createFirst")
|
|
1734
1856
|
}
|
|
1735
1857
|
)
|
|
@@ -1878,7 +2000,7 @@ function QuoteFormView({ quoteId, leadId, onSaved }) {
|
|
|
1878
2000
|
observations,
|
|
1879
2001
|
items: items.map((it) => ({ itemKind: it.itemKind, description: it.description, quantity: it.quantity, unitPrice: it.unitPrice, discount: it.discount }))
|
|
1880
2002
|
};
|
|
1881
|
-
const snapshot =
|
|
2003
|
+
const snapshot = React17.useRef(null);
|
|
1882
2004
|
useEffect(() => {
|
|
1883
2005
|
if (!loadingExisting && snapshot.current === null) snapshot.current = JSON.stringify(currentFields);
|
|
1884
2006
|
}, [loadingExisting]);
|
|
@@ -1892,7 +2014,7 @@ function QuoteFormView({ quoteId, leadId, onSaved }) {
|
|
|
1892
2014
|
onDiscard: () => onSaved?.(),
|
|
1893
2015
|
saveLabel: isEdit ? t2("crm.quoteForm.saveChanges") : t2("crm.quoteForm.saveQuote")
|
|
1894
2016
|
});
|
|
1895
|
-
if (loadingExisting) return /* @__PURE__ */ jsx(OrderFormSkeleton, {});
|
|
2017
|
+
if (loadingExisting) return /* @__PURE__ */ jsx(OrderFormSkeleton, { parentLabel: t2("crm.quotes.title"), onBack: () => onSaved?.() });
|
|
1896
2018
|
const money = (v) => formatCurrency(v, currency);
|
|
1897
2019
|
const sideSections = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1898
2020
|
/* @__PURE__ */ jsx(OrderFormBlock, { title: t2("crm.quoteForm.client"), children: /* @__PURE__ */ jsx(
|
|
@@ -2086,7 +2208,7 @@ function QuoteDetailView({ quoteId, onBack, onEdit, onInvoiceCreated }) {
|
|
|
2086
2208
|
setRejecting(false);
|
|
2087
2209
|
}
|
|
2088
2210
|
}
|
|
2089
|
-
if (loading) return /* @__PURE__ */ jsx(OrderDetailSkeleton, {});
|
|
2211
|
+
if (loading) return /* @__PURE__ */ jsx(OrderDetailSkeleton, { parentLabel: t2("crm.quotes.title"), onBack });
|
|
2090
2212
|
if (!quote) {
|
|
2091
2213
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-5", children: [
|
|
2092
2214
|
/* @__PURE__ */ jsx(SubpageHeader, { title: t2("crm.quoteDetail.title"), onBack, parentLabel: t2("crm.quotes.title") }),
|
|
@@ -2123,7 +2245,7 @@ function QuoteDetailView({ quoteId, onBack, onEdit, onInvoiceCreated }) {
|
|
|
2123
2245
|
type: "button",
|
|
2124
2246
|
onClick: () => setSendMenuOpen((p) => !p),
|
|
2125
2247
|
disabled: sending,
|
|
2126
|
-
className: "inline-flex items-center gap-1.5 rounded-
|
|
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",
|
|
2127
2249
|
children: [
|
|
2128
2250
|
/* @__PURE__ */ jsx(Send, { className: "h-3 w-3" }),
|
|
2129
2251
|
sending ? t2("crm.quoteDetail.sending") : t2("crm.quoteDetail.send"),
|
|
@@ -2339,7 +2461,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
|
|
|
2339
2461
|
/* @__PURE__ */ jsx("div", { className: "border-t" }),
|
|
2340
2462
|
/* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
2341
2463
|
/* @__PURE__ */ jsx("div", { className: "h-4 w-36 rounded bg-muted/30 animate-pulse" }),
|
|
2342
|
-
/* @__PURE__ */ jsx("div", { className: "rounded-
|
|
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: [
|
|
2343
2465
|
/* @__PURE__ */ jsx("div", { className: "h-3 w-16 rounded bg-muted/30 animate-pulse" }),
|
|
2344
2466
|
/* @__PURE__ */ jsx("div", { className: "col-span-2 h-3 w-24 rounded bg-muted/40 animate-pulse" })
|
|
2345
2467
|
] }, i)) })
|
|
@@ -2391,7 +2513,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
|
|
|
2391
2513
|
"button",
|
|
2392
2514
|
{
|
|
2393
2515
|
onClick: () => onCreateQuote(leadId),
|
|
2394
|
-
className: "inline-flex items-center gap-1.5 rounded-
|
|
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",
|
|
2395
2517
|
children: [
|
|
2396
2518
|
/* @__PURE__ */ jsx(FileText, { className: "h-3 w-3" }),
|
|
2397
2519
|
" ",
|
|
@@ -2404,7 +2526,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
|
|
|
2404
2526
|
/* @__PURE__ */ jsx("div", { className: "border-t" }),
|
|
2405
2527
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2406
2528
|
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.contactInfo") }),
|
|
2407
|
-
/* @__PURE__ */ jsx("div", { className: "rounded-
|
|
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: [
|
|
2408
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 }) }),
|
|
2409
2531
|
/* @__PURE__ */ jsx("div", { className: "px-5 md:border-b", children: /* @__PURE__ */ jsx(
|
|
2410
2532
|
FieldRow,
|
|
@@ -2425,7 +2547,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
|
|
|
2425
2547
|
if (!fields.length && !utm.length && !attachments.length) return null;
|
|
2426
2548
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2427
2549
|
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.formAnswers") }),
|
|
2428
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-
|
|
2550
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-card border bg-card shadow-sm", children: [
|
|
2429
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)) }),
|
|
2430
2552
|
attachments.length > 0 && /* @__PURE__ */ jsx("div", { className: "border-t px-5 py-3", children: /* @__PURE__ */ jsx(LeadAttachments, { attachments }) }),
|
|
2431
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: [
|
|
@@ -2439,7 +2561,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
|
|
|
2439
2561
|
})(),
|
|
2440
2562
|
deal && /* @__PURE__ */ jsxs("div", { children: [
|
|
2441
2563
|
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.pipeline") }),
|
|
2442
|
-
/* @__PURE__ */ jsx("div", { className: "rounded-
|
|
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: [
|
|
2443
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: [
|
|
2444
2566
|
deal.stageColor && /* @__PURE__ */ jsx("span", { className: "h-2 w-2 rounded-full", style: { backgroundColor: deal.stageColor } }),
|
|
2445
2567
|
deal.stageName
|
|
@@ -2451,7 +2573,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
|
|
|
2451
2573
|
] }),
|
|
2452
2574
|
quotes.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
|
|
2453
2575
|
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.quotes") }),
|
|
2454
|
-
/* @__PURE__ */ jsx("div", { className: "rounded-
|
|
2576
|
+
/* @__PURE__ */ jsx("div", { className: "rounded-card border bg-card shadow-sm divide-y", children: quotes.map((q) => /* @__PURE__ */ jsxs(
|
|
2455
2577
|
"div",
|
|
2456
2578
|
{
|
|
2457
2579
|
onClick: () => onViewQuote?.(q.id),
|
|
@@ -2475,7 +2597,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
|
|
|
2475
2597
|
] }),
|
|
2476
2598
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
2477
2599
|
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.details") }),
|
|
2478
|
-
/* @__PURE__ */ jsx("div", { className: "rounded-
|
|
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: [
|
|
2479
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 }) }),
|
|
2480
2602
|
/* @__PURE__ */ jsx("div", { className: "px-5 md:border-b", children: /* @__PURE__ */ jsx(FieldRow, { label: t2("crm.leadDetail.assignedTo"), value: lead.assignedToName }) }),
|
|
2481
2603
|
/* @__PURE__ */ jsx("div", { className: "px-5 md:border-b md:last:border-b-0", children: /* @__PURE__ */ jsx(
|
|
@@ -2510,14 +2632,204 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote }) {
|
|
|
2510
2632
|
] }),
|
|
2511
2633
|
lead.tags && lead.tags.length > 0 && /* @__PURE__ */ jsxs("div", { children: [
|
|
2512
2634
|
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.tags") }),
|
|
2513
|
-
/* @__PURE__ */ jsx("div", { className: "rounded-
|
|
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)) }) })
|
|
2514
2636
|
] }),
|
|
2515
2637
|
lead.notes && /* @__PURE__ */ jsxs("div", { children: [
|
|
2516
2638
|
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.notes") }),
|
|
2517
|
-
/* @__PURE__ */ jsx("div", { className: "rounded-
|
|
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 }) })
|
|
2640
|
+
] })
|
|
2641
|
+
] });
|
|
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 })
|
|
2518
2727
|
] })
|
|
2519
2728
|
] });
|
|
2520
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
|
+
}
|
|
2521
2833
|
|
|
2522
2834
|
// src/types.ts
|
|
2523
2835
|
var SYSTEM_ACTIVITY_TYPES = [
|
|
@@ -2560,7 +2872,7 @@ var TYPE_CONFIG = {
|
|
|
2560
2872
|
var SYSTEM_TYPES = new Set(SYSTEM_ACTIVITY_TYPES);
|
|
2561
2873
|
var MANUAL_TYPES = Object.keys(TYPE_CONFIG).filter((t2) => !SYSTEM_TYPES.has(t2));
|
|
2562
2874
|
function ActivitySkeleton() {
|
|
2563
|
-
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-
|
|
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: [
|
|
2564
2876
|
/* @__PURE__ */ jsx("div", { className: "h-9 w-9 rounded-lg bg-muted/40 animate-pulse shrink-0" }),
|
|
2565
2877
|
/* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-2 pt-0.5", children: [
|
|
2566
2878
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
@@ -2575,9 +2887,9 @@ function ActivitySkeleton() {
|
|
|
2575
2887
|
}
|
|
2576
2888
|
function ActivityListView({ onOpenLead, onOpenQuote } = {}) {
|
|
2577
2889
|
const t2 = useTranslation();
|
|
2578
|
-
const provider = useCrmProvider();
|
|
2579
2890
|
const { currency } = useCrmConfig();
|
|
2580
2891
|
const [selectedDealId, setSelectedDealId] = useState(null);
|
|
2892
|
+
const [selectedLeadId, setSelectedLeadId] = useState(null);
|
|
2581
2893
|
const activities = useCrmStore((s) => s.activities);
|
|
2582
2894
|
const activitiesLoading = useCrmStore((s) => s.activitiesLoading);
|
|
2583
2895
|
const fetchActivities = useCrmStore((s) => s.fetchActivities);
|
|
@@ -2669,18 +2981,19 @@ function ActivityListView({ onOpenLead, onOpenQuote } = {}) {
|
|
|
2669
2981
|
const Icon = cfg.icon;
|
|
2670
2982
|
const isSystem = SYSTEM_TYPES.has(a.activityType);
|
|
2671
2983
|
const isOverdue = !a.completedAt && a.dueDate && a.dueDate < (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2672
|
-
const openRecord = a.dealId ? () =>
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2984
|
+
const openRecord = a.dealId ? () => {
|
|
2985
|
+
setSelectedLeadId(null);
|
|
2986
|
+
setSelectedDealId(a.dealId);
|
|
2987
|
+
} : a.leadId ? () => {
|
|
2988
|
+
setSelectedDealId(null);
|
|
2989
|
+
setSelectedLeadId(a.leadId);
|
|
2677
2990
|
} : void 0;
|
|
2678
2991
|
return /* @__PURE__ */ jsxs(
|
|
2679
2992
|
"div",
|
|
2680
2993
|
{
|
|
2681
2994
|
onClick: openRecord,
|
|
2682
2995
|
role: openRecord ? "button" : void 0,
|
|
2683
|
-
className: `group flex items-start gap-3 rounded-
|
|
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" : ""}`,
|
|
2684
2997
|
children: [
|
|
2685
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" }) }),
|
|
2686
2999
|
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0 pt-0.5", children: [
|
|
@@ -2739,9 +3052,25 @@ function ActivityListView({ onOpenLead, onOpenQuote } = {}) {
|
|
|
2739
3052
|
dealId: selectedDealId ?? "",
|
|
2740
3053
|
open: !!selectedDealId,
|
|
2741
3054
|
onClose: () => setSelectedDealId(null),
|
|
2742
|
-
onViewLead:
|
|
3055
|
+
onViewLead: (id) => {
|
|
3056
|
+
setSelectedDealId(null);
|
|
3057
|
+
setSelectedLeadId(id);
|
|
3058
|
+
},
|
|
2743
3059
|
onViewQuote: onOpenQuote
|
|
2744
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
|
+
}
|
|
2745
3074
|
)
|
|
2746
3075
|
] });
|
|
2747
3076
|
}
|
|
@@ -2852,7 +3181,12 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
2852
3181
|
const renderView = createViewRouter([
|
|
2853
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 }) },
|
|
2854
3183
|
{ id: "leads-list", render: () => /* @__PURE__ */ jsx(LeadListView, { onNew: () => navigate("leads-new"), onEdit: (id) => navigate(`leads-detail:${id}`) }) },
|
|
2855
|
-
|
|
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
|
+
] }) },
|
|
2856
3190
|
{ id: "quotes-new", render: () => {
|
|
2857
3191
|
const hashParams = new URLSearchParams(window.location.hash.split("?")[1] ?? "");
|
|
2858
3192
|
const lid = hashParams.get("leadId") ?? void 0;
|
|
@@ -2875,7 +3209,7 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
2875
3209
|
nav,
|
|
2876
3210
|
navVariant: config.moduleNav,
|
|
2877
3211
|
showHeader: isSummary,
|
|
2878
|
-
viewKey: view,
|
|
3212
|
+
viewKey: view === "leads-new" ? "leads-list" : view,
|
|
2879
3213
|
direction,
|
|
2880
3214
|
headerAction: /* @__PURE__ */ jsx(
|
|
2881
3215
|
ModuleActionBar,
|
|
@@ -4542,6 +4876,7 @@ function createSupabaseCrmProvider(options) {
|
|
|
4542
4876
|
}
|
|
4543
4877
|
function createCrmStore(provider) {
|
|
4544
4878
|
let lastActivitiesQuery = {};
|
|
4879
|
+
let lastLeadsQuery = {};
|
|
4545
4880
|
let lastBoard = null;
|
|
4546
4881
|
return createStore$1((set, get) => ({
|
|
4547
4882
|
pipelines: [],
|
|
@@ -4599,6 +4934,7 @@ function createCrmStore(provider) {
|
|
|
4599
4934
|
});
|
|
4600
4935
|
},
|
|
4601
4936
|
async fetchLeads(query) {
|
|
4937
|
+
lastLeadsQuery = query;
|
|
4602
4938
|
return dedup("crm:leads:" + JSON.stringify(query), async () => {
|
|
4603
4939
|
set({ leadsLoading: true });
|
|
4604
4940
|
const result = await provider.getLeads(query);
|
|
@@ -4683,6 +5019,18 @@ function createCrmStore(provider) {
|
|
|
4683
5019
|
throw err;
|
|
4684
5020
|
}
|
|
4685
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
|
+
},
|
|
4686
5034
|
async createDeal(input) {
|
|
4687
5035
|
try {
|
|
4688
5036
|
const deal = await provider.createDeal(input);
|
|
@@ -4878,7 +5226,7 @@ function createCrmStore(provider) {
|
|
|
4878
5226
|
try {
|
|
4879
5227
|
await provider.archiveLead(leadId);
|
|
4880
5228
|
const [leadsResult, summary] = await Promise.all([
|
|
4881
|
-
provider.getLeads(
|
|
5229
|
+
provider.getLeads(lastLeadsQuery),
|
|
4882
5230
|
provider.getSummary(),
|
|
4883
5231
|
get().refreshBoard()
|
|
4884
5232
|
]);
|
|
@@ -5156,6 +5504,26 @@ var en = {
|
|
|
5156
5504
|
"crm.leadForm.saving": "Saving...",
|
|
5157
5505
|
"crm.leadForm.subtitle": "Capture a new lead",
|
|
5158
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",
|
|
5159
5527
|
"crm.leads.captureFirst": "Capture your first lead",
|
|
5160
5528
|
"crm.leads.contactCol": "Contact",
|
|
5161
5529
|
"crm.leads.name": "Name",
|
|
@@ -5468,6 +5836,26 @@ var ptBR = {
|
|
|
5468
5836
|
"crm.leadForm.saving": "Salvando...",
|
|
5469
5837
|
"crm.leadForm.subtitle": "Capturar um novo lead",
|
|
5470
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",
|
|
5471
5859
|
"crm.leads.captureFirst": "Capture seu primeiro lead",
|
|
5472
5860
|
"crm.leads.contactCol": "Contato",
|
|
5473
5861
|
"crm.leads.name": "Nome",
|
|
@@ -5760,10 +6148,11 @@ function createCrmPlugin(options) {
|
|
|
5760
6148
|
() => createMockCrmProvider({ activityTypes })
|
|
5761
6149
|
);
|
|
5762
6150
|
const store = createCrmStore(provider);
|
|
5763
|
-
const PageComponent = () =>
|
|
6151
|
+
const PageComponent = () => React17.createElement(CrmPage, { config, provider, store, registries: crmRegistries2 });
|
|
5764
6152
|
const dashboardWidgets = createCrmDashboardWidgets({ config, provider, store });
|
|
5765
6153
|
return {
|
|
5766
6154
|
id: "crm",
|
|
6155
|
+
defaultAgentRole: "growth",
|
|
5767
6156
|
name: config.labels.pageTitle,
|
|
5768
6157
|
icon: "Filter",
|
|
5769
6158
|
version: "1.0.0",
|
|
@@ -6024,13 +6413,12 @@ function createCrmPlugin(options) {
|
|
|
6024
6413
|
label: "Sales & CRM",
|
|
6025
6414
|
icon: "Filter",
|
|
6026
6415
|
component: (() => {
|
|
6027
|
-
const Tab = () =>
|
|
6416
|
+
const Tab = () => React17.createElement(
|
|
6028
6417
|
CrmContextProvider,
|
|
6029
6418
|
{ config, provider, store },
|
|
6030
|
-
|
|
6419
|
+
React17.createElement(PluginSettingsPanel, {
|
|
6031
6420
|
title: "Sales & CRM",
|
|
6032
|
-
|
|
6033
|
-
generalSettings: React16.createElement(CrmGeneralSettings),
|
|
6421
|
+
generalSettings: React17.createElement(CrmGeneralSettings),
|
|
6034
6422
|
registries: crmRegistries2,
|
|
6035
6423
|
hostPluginId: "crm",
|
|
6036
6424
|
routeBase: "/settings/crm"
|