@fayz-ai/plugin-crm 0.28.3 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ActivityTimeline.d.ts.map +1 -1
- package/dist/components/FutureContactPicker.d.ts +10 -0
- package/dist/components/FutureContactPicker.d.ts.map +1 -0
- package/dist/components/LogActivityButton.d.ts.map +1 -1
- package/dist/index.js +125 -57
- 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/views/CrmPage.d.ts.map +1 -1
- package/dist/views/DealCardModal.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActivityTimeline.d.ts","sourceRoot":"","sources":["../../src/components/ActivityTimeline.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAuBxC,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE;IAC7E,UAAU,EAAE,QAAQ,EAAE,CAAA;IACtB,OAAO,EAAE,OAAO,CAAA;IAChB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;0EACsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,
|
|
1
|
+
{"version":3,"file":"ActivityTimeline.d.ts","sourceRoot":"","sources":["../../src/components/ActivityTimeline.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAuBxC,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE;IAC7E,UAAU,EAAE,QAAQ,EAAE,CAAA;IACtB,OAAO,EAAE,OAAO,CAAA;IAChB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;0EACsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,qBAgFA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function addDaysToDate(value: Date, days: number): string;
|
|
3
|
+
export declare function addMonthsToDate(value: Date, months: number): string;
|
|
4
|
+
export declare function defaultFutureContactDate(now?: Date): string;
|
|
5
|
+
export declare function FutureContactPicker({ value, onChange, required }: {
|
|
6
|
+
value: string;
|
|
7
|
+
onChange: (value: string) => void;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
}): React.JSX.Element;
|
|
10
|
+
//# sourceMappingURL=FutureContactPicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FutureContactPicker.d.ts","sourceRoot":"","sources":["../../src/components/FutureContactPicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAYzB,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI/D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMnE;AAED,wBAAgB,wBAAwB,CAAC,GAAG,OAAa,GAAG,MAAM,CAEjE;AAED,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAgB,EAAE,EAAE;IACzE,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,qBAmCA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogActivityButton.d.ts","sourceRoot":"","sources":["../../src/components/LogActivityButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAA;AAU3D,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"LogActivityButton.d.ts","sourceRoot":"","sources":["../../src/components/LogActivityButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAA;AAU3D,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,UAAU,CAAA;AAiBzD,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAYD,wBAAgB,iBAAiB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE;IACtD,MAAM,EAAE,cAAc,CAAA;IACtB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAA;CACxC,qBAqKA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { useState, useEffect,
|
|
1
|
+
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react';
|
|
2
2
|
import { tl, useTranslation, getSupabaseClientOptional, registerTranslations, registerMessageDefaults, createSafeDataProvider, getActiveTenantId, countByTenant, usePluginRuntimeOptional, useActiveTenantId, exportCSV, loadMessageOverrides, resolveMessages, useActiveUnitId } from '@fayz-ai/core';
|
|
3
|
-
import { createPluginContext, useUnitBootstrap, useUnitStore, createCrudPage, PluginSettingsPanel, registerTimelineSource, dedup, useModuleNavigation, createViewRouter, ModuleActionBar, usePermissionOptional, PageActions, useTenantPluginSettings, SettingsGroup, ToggleRow, adminNavigateTo, usePersistedState, useScrollMemory, useLimitGuard, OrderFormSkeleton, OrderFormBlock, OrderFormView, OrderFormItemsCard, OrderFormItemRow, OrderFormAddItemStep, formatCurrency, useRecordVisit, OrderDetailSkeleton, OrderDetailBlock, OrderDetailView, PersonLink, RightRailPage, KanbanBoard, invalidateLimit, useAccessOptional, useOrganizationStore, getRailPage, ContactPicker } from '@fayz-ai/admin';
|
|
3
|
+
import { createPluginContext, useUnitBootstrap, useUnitStore, createCrudPage, PluginSettingsPanel, registerTimelineSource, dedup, useModuleNavigation, usePluginOnboardingGate, PluginOnboardingGateSkeleton, createViewRouter, ModuleActionBar, usePermissionOptional, PageActions, useTenantPluginSettings, SettingsGroup, ToggleRow, adminNavigateTo, usePersistedState, useScrollMemory, useLimitGuard, OrderFormSkeleton, OrderFormBlock, OrderFormView, OrderFormItemsCard, OrderFormItemRow, OrderFormAddItemStep, formatCurrency, useRecordVisit, OrderDetailSkeleton, OrderDetailBlock, OrderDetailView, PersonLink, RightRailPage, KanbanBoard, invalidateLimit, useAccessOptional, useOrganizationStore, getRailPage, ContactPicker } from '@fayz-ai/admin';
|
|
4
4
|
import { Archive, FileX2, FileCheck2, Send, FilePlus2, XCircle, Trophy, PhoneCall, MoveRight, Target, ArrowRightLeft, UserPlus, MapPin, MessageCircle, CheckSquare, FileText, Users, Mail, Phone, ArrowUp, ArrowDown, X, Plus, Filter, Lock, Pencil, Trash2, Globe, Check, ChevronRight, Settings, Tag, Building2, CircleDot, User, Download, Inbox, Play, Clock, Sparkles, Calendar, ArrowRight, ChevronDown, Printer, CircleCheckBig, Ban, Receipt, Package, CalendarClock, Loader2, Network, Fingerprint, Link2, Star, MessageSquareQuote, UserRound, CalendarDays, Search, SignalHigh, CalendarRange, ChevronLeft, TrendingDown, ThumbsDown, MoreHorizontal, UserCheck, AlertTriangle, Settings2, Repeat, Zap, Snowflake, Sun, Flame, Merge, Paperclip, ImageOff, CircleAlert, CircleDashed, CheckCircle2, SlidersHorizontal, ExternalLink, Clipboard, DollarSign, ThumbsUp, UserRoundPlus } from 'lucide-react';
|
|
5
5
|
import { Badge, Checkbox, toast, defineKpiWidget, defineChartWidget, defineCustomWidget, defineTableWidget, PageTransition, ModulePage, PageViewBar, ViewTabs, SubpageHeader, Button, TooltipProvider, Tooltip, TooltipTrigger, TooltipContent, Switch, ConfirmDialog, useIsWide, PageHeaderActions, FilterChip, MultiSelect, FilterMenu, FilterMenuRow, PersonAvatar, ListView, Modal, ModalContent, ModalHeader, ModalTitle, ModalBody, Input, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, ModalFooter, useSaveBar, SearchSelect, DatePicker, DataTable, PhoneLink, SheetBody, SheetFooter, DashboardCanvas, ModalDescription, Card, Dropdown, DropdownTrigger, DropdownContent, DropdownItem, PersonPicker, CurrencyInput, HeaderTabs, Popover, PopoverTrigger, PopoverContent, getLucideIcon, DictateButton, DropdownLabel, DropdownSeparator, normalizePhone, KpiCard, ChartWidget, CardHeader, CardTitle, CardContent, TableWidget } from '@fayz-ai/ui';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -3100,22 +3100,22 @@ function ActivityTimeline({ activities, loading, locale, contactName }) {
|
|
|
3100
3100
|
/* @__PURE__ */ jsx("span", { className: "relative flex h-6 w-6 items-center justify-center rounded-full border bg-card", children: /* @__PURE__ */ jsx(Icon, { className: "h-3 w-3 text-muted-foreground" }) })
|
|
3101
3101
|
] }),
|
|
3102
3102
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 pt-0.5", children: [
|
|
3103
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
3104
|
-
/* @__PURE__ */ jsxs("p", { className: "min-w-0
|
|
3103
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2", children: [
|
|
3104
|
+
/* @__PURE__ */ jsxs("p", { className: "min-w-0 break-words text-xs font-medium leading-5", children: [
|
|
3105
3105
|
a.title,
|
|
3106
|
-
a.createdByName && /* @__PURE__ */ jsxs("span", { className: "ml-1.5 inline-flex items-center gap-1 align-middle font-normal text-muted-foreground", children: [
|
|
3107
|
-
"\xB7 ",
|
|
3108
|
-
/* @__PURE__ */ jsx(PersonAvatar, { name: a.createdByName, size: "xs" }),
|
|
3109
|
-
" ",
|
|
3110
|
-
a.createdByName
|
|
3111
|
-
] }),
|
|
3112
3106
|
a.contactName && a.contactName !== contactName && /* @__PURE__ */ jsxs("span", { className: "ml-1.5 font-normal text-muted-foreground/70", children: [
|
|
3113
3107
|
"\xB7 ",
|
|
3114
3108
|
a.contactName
|
|
3115
3109
|
] })
|
|
3116
3110
|
] }),
|
|
3117
|
-
|
|
3118
|
-
|
|
3111
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-[5.5rem] items-center justify-end gap-1.5", children: [
|
|
3112
|
+
a.completedAt && /* @__PURE__ */ jsx(Check, { className: "h-3 w-3 shrink-0 text-success" }),
|
|
3113
|
+
/* @__PURE__ */ jsx(AutomationBolt, { activityType: a.activityType, messages }),
|
|
3114
|
+
a.createdByName && /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center justify-end gap-1 text-xs font-normal text-muted-foreground", children: [
|
|
3115
|
+
/* @__PURE__ */ jsx(PersonAvatar, { name: a.createdByName, size: "xs" }),
|
|
3116
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-20 truncate", children: a.createdByName })
|
|
3117
|
+
] })
|
|
3118
|
+
] }),
|
|
3119
3119
|
/* @__PURE__ */ jsx("time", { className: "shrink-0 text-[10px] tabular-nums text-muted-foreground/70", children: formatRelativeTime(a.createdAt, locale) })
|
|
3120
3120
|
] }),
|
|
3121
3121
|
a.description && /* @__PURE__ */ jsx("p", { className: "whitespace-pre-wrap text-[11px] leading-snug text-muted-foreground", children: a.description })
|
|
@@ -3783,6 +3783,57 @@ function TemperatureBadge({ score, size = "sm", className }) {
|
|
|
3783
3783
|
}
|
|
3784
3784
|
);
|
|
3785
3785
|
}
|
|
3786
|
+
function toLocalDate(value) {
|
|
3787
|
+
const year = value.getFullYear();
|
|
3788
|
+
const month = String(value.getMonth() + 1).padStart(2, "0");
|
|
3789
|
+
const day = String(value.getDate()).padStart(2, "0");
|
|
3790
|
+
return `${year}-${month}-${day}`;
|
|
3791
|
+
}
|
|
3792
|
+
function addDaysToDate(value, days) {
|
|
3793
|
+
const result = new Date(value.getFullYear(), value.getMonth(), value.getDate());
|
|
3794
|
+
result.setDate(result.getDate() + days);
|
|
3795
|
+
return toLocalDate(result);
|
|
3796
|
+
}
|
|
3797
|
+
function addMonthsToDate(value, months) {
|
|
3798
|
+
const day = value.getDate();
|
|
3799
|
+
const result = new Date(value.getFullYear(), value.getMonth() + months, 1);
|
|
3800
|
+
const lastDay = new Date(result.getFullYear(), result.getMonth() + 1, 0).getDate();
|
|
3801
|
+
result.setDate(Math.min(day, lastDay));
|
|
3802
|
+
return toLocalDate(result);
|
|
3803
|
+
}
|
|
3804
|
+
function defaultFutureContactDate(now2 = /* @__PURE__ */ new Date()) {
|
|
3805
|
+
return addMonthsToDate(now2, 1);
|
|
3806
|
+
}
|
|
3807
|
+
function FutureContactPicker({ value, onChange, required = false }) {
|
|
3808
|
+
const t2 = useTranslation();
|
|
3809
|
+
const today2 = /* @__PURE__ */ new Date();
|
|
3810
|
+
const presets = [
|
|
3811
|
+
{ label: t2("crm.followUp.inSevenDays"), value: addDaysToDate(today2, 7) },
|
|
3812
|
+
{ label: t2("crm.followUp.inOneMonth"), value: addMonthsToDate(today2, 1) },
|
|
3813
|
+
{ label: t2("crm.followUp.inThreeMonths"), value: addMonthsToDate(today2, 3) }
|
|
3814
|
+
];
|
|
3815
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-full space-y-2 rounded-lg border border-amber-300/70 bg-amber-50/60 p-2.5 dark:border-amber-700/60 dark:bg-amber-950/20", children: [
|
|
3816
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-xs font-medium text-foreground", children: [
|
|
3817
|
+
/* @__PURE__ */ jsx(CalendarClock, { className: "h-3.5 w-3.5 text-amber-600" }),
|
|
3818
|
+
t2("crm.followUp.futureContact"),
|
|
3819
|
+
required ? " *" : ""
|
|
3820
|
+
] }),
|
|
3821
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1.5", children: presets.map((preset) => /* @__PURE__ */ jsx(
|
|
3822
|
+
Button,
|
|
3823
|
+
{
|
|
3824
|
+
type: "button",
|
|
3825
|
+
size: "sm",
|
|
3826
|
+
variant: value === preset.value ? "default" : "outline",
|
|
3827
|
+
className: "h-7 px-2 text-[11px]",
|
|
3828
|
+
onClick: () => onChange(preset.value),
|
|
3829
|
+
children: preset.label
|
|
3830
|
+
},
|
|
3831
|
+
preset.value
|
|
3832
|
+
)) }),
|
|
3833
|
+
/* @__PURE__ */ jsx(DatePicker, { value, onChange }),
|
|
3834
|
+
required && !value && /* @__PURE__ */ jsx("p", { className: "text-[11px] text-destructive", children: t2("crm.followUp.futureRequired") })
|
|
3835
|
+
] });
|
|
3836
|
+
}
|
|
3786
3837
|
function Section({ title, action, children }) {
|
|
3787
3838
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
3788
3839
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
|
|
@@ -3930,6 +3981,7 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
3930
3981
|
const [ctype, setCtype] = useState("whatsapp");
|
|
3931
3982
|
const [cnote, setCnote] = useState("");
|
|
3932
3983
|
const [coutcome, setCoutcome] = useState("connected");
|
|
3984
|
+
const [cfutureDate, setCfutureDate] = useState("");
|
|
3933
3985
|
const [cdue, setCdue] = useState(() => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10));
|
|
3934
3986
|
const [csaving, setCsaving] = useState(false);
|
|
3935
3987
|
const composerRef = useRef(null);
|
|
@@ -3987,6 +4039,8 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
3987
4039
|
}, [activities, timelineTab, CONTACT_TYPES2]);
|
|
3988
4040
|
async function logFromComposer() {
|
|
3989
4041
|
if (csaving) return;
|
|
4042
|
+
const needsFutureContact = CONTACT_TYPES2.has(ctype) && coutcome === "not_now";
|
|
4043
|
+
if (needsFutureContact && !cfutureDate) return;
|
|
3990
4044
|
const body = cnote.trim();
|
|
3991
4045
|
if (!body && (ctype === "note" || ctype === "task")) return;
|
|
3992
4046
|
setCsaving(true);
|
|
@@ -3998,14 +4052,24 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
3998
4052
|
leadId: deal?.leadId,
|
|
3999
4053
|
contactId: deal?.contactId,
|
|
4000
4054
|
activityType: ctype,
|
|
4001
|
-
outcome: CONTACT_TYPES2.has(ctype) ? coutcome : void 0,
|
|
4002
|
-
title: firstLine ? firstLine.slice(0, 120) : typeLabel,
|
|
4003
|
-
description: body && firstLine !== body ? body : void 0,
|
|
4055
|
+
outcome: CONTACT_TYPES2.has(ctype) && coutcome !== "not_now" ? coutcome : void 0,
|
|
4056
|
+
title: coutcome === "not_now" ? t2("crm.outcome.not_now") : firstLine ? firstLine.slice(0, 120) : typeLabel,
|
|
4057
|
+
description: coutcome === "not_now" ? body || void 0 : body && firstLine !== body ? body : void 0,
|
|
4004
4058
|
dueDate: ctype === "task" ? cdue : void 0
|
|
4005
4059
|
});
|
|
4006
|
-
|
|
4060
|
+
const futureTask = needsFutureContact ? await createActivity({
|
|
4061
|
+
dealId,
|
|
4062
|
+
leadId: deal?.leadId,
|
|
4063
|
+
contactId: deal?.contactId,
|
|
4064
|
+
activityType: "task",
|
|
4065
|
+
title: t2("crm.followUp.futureTaskTitle"),
|
|
4066
|
+
dueDate: cfutureDate,
|
|
4067
|
+
assignedToId: deal?.assignedToId
|
|
4068
|
+
}) : void 0;
|
|
4069
|
+
setActivities((prev) => futureTask ? [futureTask, logged, ...prev] : [logged, ...prev]);
|
|
4007
4070
|
setCnote("");
|
|
4008
4071
|
setCoutcome("connected");
|
|
4072
|
+
setCfutureDate("");
|
|
4009
4073
|
setComposerOpen(false);
|
|
4010
4074
|
setTimeout(() => {
|
|
4011
4075
|
void provider.getLiveDealById(dealId).then((d) => {
|
|
@@ -4520,9 +4584,13 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
4520
4584
|
}
|
|
4521
4585
|
),
|
|
4522
4586
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
4523
|
-
CONTACT_TYPES2.has(ctype) && /* @__PURE__ */ jsxs(Select, { value: coutcome, onValueChange: (v) =>
|
|
4587
|
+
CONTACT_TYPES2.has(ctype) && /* @__PURE__ */ jsxs(Select, { value: coutcome, onValueChange: (v) => {
|
|
4588
|
+
const nextOutcome = v;
|
|
4589
|
+
setCoutcome(nextOutcome);
|
|
4590
|
+
if (nextOutcome === "not_now" && !cfutureDate) setCfutureDate(defaultFutureContactDate());
|
|
4591
|
+
}, children: [
|
|
4524
4592
|
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 w-auto min-w-[10rem] text-xs", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
4525
|
-
/* @__PURE__ */ jsx(SelectContent, { children: ["connected", "no_answer", "left_message", "replied", "scheduled"].map((o) => /* @__PURE__ */ jsx(SelectItem, { value: o, children: t2(`crm.outcome.${o}`) }, o)) })
|
|
4593
|
+
/* @__PURE__ */ jsx(SelectContent, { children: ["connected", "no_answer", "left_message", "replied", "scheduled", "not_now"].map((o) => /* @__PURE__ */ jsx(SelectItem, { value: o, children: t2(`crm.outcome.${o}`) }, o)) })
|
|
4526
4594
|
] }),
|
|
4527
4595
|
ctype === "task" && /* @__PURE__ */ jsx(
|
|
4528
4596
|
"input",
|
|
@@ -4533,11 +4601,12 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
4533
4601
|
className: "h-8 rounded-lg border bg-background px-2 text-xs outline-none focus:ring-2 focus:ring-ring"
|
|
4534
4602
|
}
|
|
4535
4603
|
),
|
|
4604
|
+
CONTACT_TYPES2.has(ctype) && coutcome === "not_now" && /* @__PURE__ */ jsx(FutureContactPicker, { value: cfutureDate, onChange: setCfutureDate, required: true }),
|
|
4536
4605
|
/* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-1.5", children: [
|
|
4537
4606
|
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: () => setComposerOpen(false), children: t2("crm.card.cancelEdit") }),
|
|
4538
4607
|
/* @__PURE__ */ jsxs(Button, { size: "sm", onClick: () => {
|
|
4539
4608
|
void logFromComposer();
|
|
4540
|
-
}, disabled: csaving, children: [
|
|
4609
|
+
}, disabled: csaving || CONTACT_TYPES2.has(ctype) && coutcome === "not_now" && !cfutureDate, children: [
|
|
4541
4610
|
csaving && /* @__PURE__ */ jsx(Loader2, { className: "h-3 w-3 animate-spin" }),
|
|
4542
4611
|
t2("crm.followUp.save")
|
|
4543
4612
|
] })
|
|
@@ -6813,7 +6882,7 @@ function LeadQualification({ lead }) {
|
|
|
6813
6882
|
}
|
|
6814
6883
|
var PREFERRED_ORDER = ["whatsapp", "call", "visit", "email", "meeting", "note"];
|
|
6815
6884
|
var CONTACT_TYPES = /* @__PURE__ */ new Set(["whatsapp", "call", "visit", "email", "meeting"]);
|
|
6816
|
-
var OUTCOMES = ["connected", "no_answer", "left_message", "replied", "scheduled"];
|
|
6885
|
+
var OUTCOMES = ["connected", "no_answer", "left_message", "replied", "scheduled", "not_now"];
|
|
6817
6886
|
function LogActivityButton({ target, onLogged }) {
|
|
6818
6887
|
const t2 = useTranslation();
|
|
6819
6888
|
const provider = useCrmProvider();
|
|
@@ -6849,6 +6918,7 @@ function LogActivityButton({ target, onLogged }) {
|
|
|
6849
6918
|
const asksOutcome = CONTACT_TYPES.has(type);
|
|
6850
6919
|
async function submit() {
|
|
6851
6920
|
if (saving) return;
|
|
6921
|
+
if (asksOutcome && outcome === "not_now" && !nextDate) return;
|
|
6852
6922
|
const body = note.trim();
|
|
6853
6923
|
setSaving(true);
|
|
6854
6924
|
try {
|
|
@@ -6856,17 +6926,17 @@ function LogActivityButton({ target, onLogged }) {
|
|
|
6856
6926
|
const logged = await createActivity({
|
|
6857
6927
|
...target,
|
|
6858
6928
|
activityType: type,
|
|
6859
|
-
outcome: asksOutcome ? outcome : void 0,
|
|
6929
|
+
outcome: asksOutcome && outcome !== "not_now" ? outcome : void 0,
|
|
6860
6930
|
// O título é a primeira linha do relato — é o que a linha do tempo
|
|
6861
6931
|
// mostra em negrito. Sem relato, o tipo já diz o que aconteceu.
|
|
6862
|
-
title: firstLine ? firstLine.slice(0, 120) : typeLabel,
|
|
6863
|
-
description: body && firstLine !== body ? body : void 0
|
|
6932
|
+
title: outcome === "not_now" ? t2("crm.outcome.not_now") : firstLine ? firstLine.slice(0, 120) : typeLabel,
|
|
6933
|
+
description: outcome === "not_now" ? body || void 0 : body && firstLine !== body ? body : void 0
|
|
6864
6934
|
});
|
|
6865
6935
|
if (nextDate) {
|
|
6866
6936
|
await createActivity({
|
|
6867
6937
|
...target,
|
|
6868
6938
|
activityType: "task",
|
|
6869
|
-
title: t2("crm.followUp.defaultNextTitle", { type: typeLabel }),
|
|
6939
|
+
title: asksOutcome && outcome === "not_now" ? t2("crm.followUp.futureTaskTitle") : t2("crm.followUp.defaultNextTitle", { type: typeLabel }),
|
|
6870
6940
|
dueDate: nextDate
|
|
6871
6941
|
});
|
|
6872
6942
|
}
|
|
@@ -6899,7 +6969,11 @@ function LogActivityButton({ target, onLogged }) {
|
|
|
6899
6969
|
] }) }, opt.value);
|
|
6900
6970
|
}) })
|
|
6901
6971
|
] }),
|
|
6902
|
-
asksOutcome && /* @__PURE__ */ jsxs(Select, { value: outcome, onValueChange: (v) =>
|
|
6972
|
+
asksOutcome && /* @__PURE__ */ jsxs(Select, { value: outcome, onValueChange: (v) => {
|
|
6973
|
+
const nextOutcome = v;
|
|
6974
|
+
setOutcome(nextOutcome);
|
|
6975
|
+
if (nextOutcome === "not_now" && !nextDate) setNextDate(defaultFutureContactDate());
|
|
6976
|
+
}, children: [
|
|
6903
6977
|
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 text-sm", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
6904
6978
|
/* @__PURE__ */ jsx(SelectContent, { children: OUTCOMES.map((o) => /* @__PURE__ */ jsx(SelectItem, { value: o, children: t2(`crm.outcome.${o}`) }, o)) })
|
|
6905
6979
|
] }),
|
|
@@ -6937,16 +7011,12 @@ function LogActivityButton({ target, onLogged }) {
|
|
|
6937
7011
|
}
|
|
6938
7012
|
)
|
|
6939
7013
|
] }),
|
|
6940
|
-
/* @__PURE__ */
|
|
6941
|
-
/* @__PURE__ */ jsx(CalendarClock, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
6942
|
-
/* @__PURE__ */ jsx(DatePicker, { value: nextDate, onChange: setNextDate }),
|
|
6943
|
-
/* @__PURE__ */ jsx("span", { className: "text-[11px] text-muted-foreground", children: t2("crm.followUp.nextStepShort") })
|
|
6944
|
-
] }),
|
|
7014
|
+
/* @__PURE__ */ jsx(FutureContactPicker, { value: nextDate, onChange: setNextDate, required: asksOutcome && outcome === "not_now" }),
|
|
6945
7015
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2 pt-0.5", children: [
|
|
6946
7016
|
/* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: () => setOpen(false), children: t2("common.cancel") }),
|
|
6947
7017
|
/* @__PURE__ */ jsxs(Button, { size: "sm", onClick: () => {
|
|
6948
7018
|
void submit();
|
|
6949
|
-
}, disabled: saving, children: [
|
|
7019
|
+
}, disabled: saving || asksOutcome && outcome === "not_now" && !nextDate, children: [
|
|
6950
7020
|
saving && /* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
6951
7021
|
t2("crm.followUp.save")
|
|
6952
7022
|
] })
|
|
@@ -9972,24 +10042,11 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
9972
10042
|
"distribution-board": 0,
|
|
9973
10043
|
settings: 1
|
|
9974
10044
|
}, "dashboard");
|
|
9975
|
-
const
|
|
9976
|
-
|
|
9977
|
-
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
}
|
|
9981
|
-
});
|
|
9982
|
-
useEffect(() => {
|
|
9983
|
-
if (onboardingComplete) return;
|
|
9984
|
-
let cancelled = false;
|
|
9985
|
-
void provider.getLeads({ pageSize: 1 }).then((res) => {
|
|
9986
|
-
if (!cancelled && res.total > 0) setOnboardingComplete(true);
|
|
9987
|
-
}).catch(() => {
|
|
9988
|
-
});
|
|
9989
|
-
return () => {
|
|
9990
|
-
cancelled = true;
|
|
9991
|
-
};
|
|
9992
|
-
}, [onboardingComplete, provider]);
|
|
10045
|
+
const checkExistingData = useCallback(
|
|
10046
|
+
async () => (await provider.getLeads({ pageSize: 1 })).total > 0,
|
|
10047
|
+
[provider]
|
|
10048
|
+
);
|
|
10049
|
+
const onboarding = usePluginOnboardingGate("saas-core:crm-onboarded", checkExistingData);
|
|
9993
10050
|
const isSettings = view === "settings";
|
|
9994
10051
|
const isSummary = view === "dashboard";
|
|
9995
10052
|
const leadsFamilyTab = view === "leads-list" || view === "leads-new" ? "leads" : view === "companies-list" || view === "companies-new" ? "companies" : view === "company-groups" ? "groups" : null;
|
|
@@ -10005,14 +10062,11 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
10005
10062
|
...config.modules.quotes ? [{ id: "new-quote", label: t2("crm.quickActions.newQuote"), icon: "FileText", description: t2("crm.quickActions.newQuoteDesc"), action: () => navigate("quotes-new") }] : [],
|
|
10006
10063
|
...config.modules.activities ? [{ id: "log-activity", label: t2("crm.quickActions.logActivity"), icon: "MessageCircle", description: t2("crm.quickActions.logActivityDesc"), action: () => navigate("activities") }] : []
|
|
10007
10064
|
], [config.modules]);
|
|
10008
|
-
if (
|
|
10009
|
-
return /* @__PURE__ */ jsx(CrmContextProvider, { config, provider, store, children: /* @__PURE__ */ jsx(
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
} catch {
|
|
10014
|
-
}
|
|
10015
|
-
} }) });
|
|
10065
|
+
if (isSummary && onboarding.status === "checking") {
|
|
10066
|
+
return /* @__PURE__ */ jsx(CrmContextProvider, { config, provider, store, children: /* @__PURE__ */ jsx(PluginOnboardingGateSkeleton, {}) });
|
|
10067
|
+
}
|
|
10068
|
+
if (isSummary && onboarding.status === "needed") {
|
|
10069
|
+
return /* @__PURE__ */ jsx(CrmContextProvider, { config, provider, store, children: /* @__PURE__ */ jsx(CrmOnboarding, { onComplete: onboarding.complete }) });
|
|
10016
10070
|
}
|
|
10017
10071
|
if (isSettings && registries && registries.length > 0) {
|
|
10018
10072
|
return /* @__PURE__ */ jsx(CrmContextProvider, { config, provider, store, children: /* @__PURE__ */ jsx(PageTransition, { transitionKey: "settings", direction, children: /* @__PURE__ */ jsxs("div", { style: { padding: "24px", display: "flex", flexDirection: "column", gap: "20px" }, children: [
|
|
@@ -28891,6 +28945,12 @@ var en = {
|
|
|
28891
28945
|
"crm.followUp.nextStep": "Next step",
|
|
28892
28946
|
"crm.followUp.nextTitlePlaceholder": "What to do (e.g. call back)",
|
|
28893
28947
|
"crm.followUp.defaultNextTitle": "Follow up ({{type}})",
|
|
28948
|
+
"crm.followUp.futureContact": "Contact again in",
|
|
28949
|
+
"crm.followUp.inSevenDays": "7 days",
|
|
28950
|
+
"crm.followUp.inOneMonth": "1 month",
|
|
28951
|
+
"crm.followUp.inThreeMonths": "3 months",
|
|
28952
|
+
"crm.followUp.futureRequired": "Choose when to contact them again.",
|
|
28953
|
+
"crm.followUp.futureTaskTitle": "Contact again",
|
|
28894
28954
|
"crm.nav.dashboard": "Dashboard",
|
|
28895
28955
|
"crm.nav.new": "New",
|
|
28896
28956
|
"crm.nav.list": "List",
|
|
@@ -28925,6 +28985,7 @@ var en = {
|
|
|
28925
28985
|
"crm.outcome.left_message": "Left a message",
|
|
28926
28986
|
"crm.outcome.replied": "They replied",
|
|
28927
28987
|
"crm.outcome.scheduled": "Got it scheduled",
|
|
28988
|
+
"crm.outcome.not_now": "Not interested right now",
|
|
28928
28989
|
"crm.card.statusIsDerived": "Computed from the timeline \u2014 nobody sets this by hand.",
|
|
28929
28990
|
"crm.deals.colStatus": "Status",
|
|
28930
28991
|
"crm.card.markWon": "Won",
|
|
@@ -29729,6 +29790,12 @@ var ptBR = {
|
|
|
29729
29790
|
"crm.followUp.nextStep": "Pr\xF3ximo passo",
|
|
29730
29791
|
"crm.followUp.nextTitlePlaceholder": "O que fazer (ex.: retornar a liga\xE7\xE3o)",
|
|
29731
29792
|
"crm.followUp.defaultNextTitle": "Retornar o contato ({{type}})",
|
|
29793
|
+
"crm.followUp.futureContact": "Retomar contato em",
|
|
29794
|
+
"crm.followUp.inSevenDays": "7 dias",
|
|
29795
|
+
"crm.followUp.inOneMonth": "1 m\xEAs",
|
|
29796
|
+
"crm.followUp.inThreeMonths": "3 meses",
|
|
29797
|
+
"crm.followUp.futureRequired": "Escolha quando retomar o contato.",
|
|
29798
|
+
"crm.followUp.futureTaskTitle": "Retomar contato",
|
|
29732
29799
|
"crm.nav.dashboard": "Painel",
|
|
29733
29800
|
"crm.nav.new": "Novo",
|
|
29734
29801
|
"crm.nav.list": "Lista",
|
|
@@ -29763,6 +29830,7 @@ var ptBR = {
|
|
|
29763
29830
|
"crm.outcome.left_message": "Deixei recado",
|
|
29764
29831
|
"crm.outcome.replied": "A pessoa respondeu",
|
|
29765
29832
|
"crm.outcome.scheduled": "Ficou agendado",
|
|
29833
|
+
"crm.outcome.not_now": "N\xE3o tem interesse agora",
|
|
29766
29834
|
"crm.card.statusIsDerived": "Calculado a partir da linha do tempo \u2014 ningu\xE9m escolhe este status \xE0 m\xE3o.",
|
|
29767
29835
|
"crm.deals.colStatus": "Status",
|
|
29768
29836
|
"crm.card.markWon": "Ganho",
|