@fayz-ai/plugin-crm 0.33.3 → 0.34.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/{CrmPage-QR3MSBZP.js → CrmPage-Z2HRXNCW.js} +158 -5
- package/dist/CrmPage-Z2HRXNCW.js.map +1 -0
- package/dist/components/TagEditor.d.ts +11 -0
- package/dist/components/TagEditor.d.ts.map +1 -0
- package/dist/data/supabase.d.ts.map +1 -1
- package/dist/index.js +17 -2
- 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/DealCardModal.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/CrmPage-QR3MSBZP.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadTeamOrNull, loadMyUserId, DotChip, AssigneeName, formatDocument, humanizeTag, DEFAULT_ACTIVITY_TYPES,
|
|
1
|
+
import { loadTeamOrNull, loadMyUserId, DotChip, AssigneeName, formatDocument, humanizeTag, DEFAULT_ACTIVITY_TYPES, localPhoneKey, normalizeDocument, TagChips, isValidDocument } from './chunk-LDBCC67C.js';
|
|
2
2
|
import { CrmGeneralSettings } from './chunk-CA24LK57.js';
|
|
3
3
|
import { resolveSourceView } from './chunk-QJOLAGGN.js';
|
|
4
4
|
import { CrmContextProvider, useCrmProvider, useCrmStore, useCrmConfig, formatCurrency } from './chunk-7V46TYYX.js';
|
|
@@ -3313,6 +3313,148 @@ function TemperatureBadge({ score, size = "sm", className }) {
|
|
|
3313
3313
|
}
|
|
3314
3314
|
);
|
|
3315
3315
|
}
|
|
3316
|
+
function slugifyTag(text) {
|
|
3317
|
+
return text.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().trim().replace(/[^a-z0-9:]+/g, "-").replace(/^-+|-+$/g, "");
|
|
3318
|
+
}
|
|
3319
|
+
function dotColor(color) {
|
|
3320
|
+
return color && /^#[0-9a-f]{6}$/i.test(color) ? color : "#94A3B8";
|
|
3321
|
+
}
|
|
3322
|
+
function TagEditor({ tags, defs, onChange, disabled }) {
|
|
3323
|
+
const t = useTranslation();
|
|
3324
|
+
const [adding, setAdding] = useState(false);
|
|
3325
|
+
const [query, setQuery] = useState("");
|
|
3326
|
+
const inputRef = useRef(null);
|
|
3327
|
+
const label2 = (slug) => defs?.get(slug)?.name ?? humanizeTag(slug);
|
|
3328
|
+
const suggestions = useMemo(() => {
|
|
3329
|
+
const q = slugifyTag(query);
|
|
3330
|
+
const taken = new Set(tags);
|
|
3331
|
+
return [...defs?.values() ?? []].filter((d) => d.isActive && !taken.has(d.slug)).filter((d) => !q || d.slug.includes(q) || slugifyTag(d.name).includes(q)).sort((a, b) => a.name.localeCompare(b.name)).slice(0, 8);
|
|
3332
|
+
}, [defs, tags, query]);
|
|
3333
|
+
const add = (slug) => {
|
|
3334
|
+
if (!slug || tags.includes(slug)) return;
|
|
3335
|
+
onChange([...tags, slug]);
|
|
3336
|
+
setQuery("");
|
|
3337
|
+
inputRef.current?.focus();
|
|
3338
|
+
};
|
|
3339
|
+
const remove = (slug) => onChange(tags.filter((s) => s !== slug));
|
|
3340
|
+
const typed = slugifyTag(query);
|
|
3341
|
+
const canCreate = !!typed && !tags.includes(typed) && !defs?.has(typed);
|
|
3342
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
3343
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
3344
|
+
tags.map((slug) => /* @__PURE__ */ jsxs(
|
|
3345
|
+
"span",
|
|
3346
|
+
{
|
|
3347
|
+
title: label2(slug),
|
|
3348
|
+
className: "inline-flex max-w-[12rem] items-center gap-1 rounded-full border border-border bg-card px-2 py-0.5 text-[10px] font-medium text-foreground/80",
|
|
3349
|
+
children: [
|
|
3350
|
+
/* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full", style: { backgroundColor: dotColor(defs?.get(slug)?.color) } }),
|
|
3351
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: label2(slug) }),
|
|
3352
|
+
!disabled && /* @__PURE__ */ jsx(
|
|
3353
|
+
Button,
|
|
3354
|
+
{
|
|
3355
|
+
variant: "bare",
|
|
3356
|
+
size: "bare",
|
|
3357
|
+
type: "button",
|
|
3358
|
+
onClick: () => remove(slug),
|
|
3359
|
+
className: "shrink-0 opacity-50 hover:opacity-100",
|
|
3360
|
+
"aria-label": t("crm.tagEditor.remove", { tag: label2(slug) }),
|
|
3361
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
3362
|
+
}
|
|
3363
|
+
)
|
|
3364
|
+
]
|
|
3365
|
+
},
|
|
3366
|
+
slug
|
|
3367
|
+
)),
|
|
3368
|
+
!disabled && !adding && /* @__PURE__ */ jsxs(
|
|
3369
|
+
Button,
|
|
3370
|
+
{
|
|
3371
|
+
variant: "bare",
|
|
3372
|
+
size: "bare",
|
|
3373
|
+
type: "button",
|
|
3374
|
+
onClick: () => {
|
|
3375
|
+
setAdding(true);
|
|
3376
|
+
setTimeout(() => inputRef.current?.focus(), 0);
|
|
3377
|
+
},
|
|
3378
|
+
className: "inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] font-medium text-muted-foreground hover:text-foreground",
|
|
3379
|
+
children: [
|
|
3380
|
+
/* @__PURE__ */ jsx(Plus, { className: "h-3 w-3" }),
|
|
3381
|
+
" ",
|
|
3382
|
+
t("crm.tagEditor.add")
|
|
3383
|
+
]
|
|
3384
|
+
}
|
|
3385
|
+
)
|
|
3386
|
+
] }),
|
|
3387
|
+
adding && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
3388
|
+
/* @__PURE__ */ jsx(
|
|
3389
|
+
"input",
|
|
3390
|
+
{
|
|
3391
|
+
ref: inputRef,
|
|
3392
|
+
value: query,
|
|
3393
|
+
onChange: (e) => setQuery(e.target.value),
|
|
3394
|
+
onKeyDown: (e) => {
|
|
3395
|
+
if (e.key === "Enter") {
|
|
3396
|
+
e.preventDefault();
|
|
3397
|
+
if (suggestions[0] && !canCreate) add(suggestions[0].slug);
|
|
3398
|
+
else add(typed);
|
|
3399
|
+
} else if (e.key === "Escape") {
|
|
3400
|
+
e.stopPropagation();
|
|
3401
|
+
setAdding(false);
|
|
3402
|
+
setQuery("");
|
|
3403
|
+
}
|
|
3404
|
+
},
|
|
3405
|
+
placeholder: t("crm.tagEditor.placeholder"),
|
|
3406
|
+
className: "h-8 w-full rounded-md border border-border bg-background px-2 text-xs outline-none focus:border-primary"
|
|
3407
|
+
}
|
|
3408
|
+
),
|
|
3409
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
3410
|
+
canCreate && /* @__PURE__ */ jsxs(
|
|
3411
|
+
Button,
|
|
3412
|
+
{
|
|
3413
|
+
variant: "bare",
|
|
3414
|
+
size: "bare",
|
|
3415
|
+
type: "button",
|
|
3416
|
+
onClick: () => add(typed),
|
|
3417
|
+
className: "inline-flex items-center gap-1 rounded-full border border-dashed border-primary/50 px-2 py-0.5 text-[10px] font-medium text-primary",
|
|
3418
|
+
children: [
|
|
3419
|
+
/* @__PURE__ */ jsx(Plus, { className: "h-3 w-3" }),
|
|
3420
|
+
" ",
|
|
3421
|
+
t("crm.tagEditor.create", { tag: humanizeTag(typed) })
|
|
3422
|
+
]
|
|
3423
|
+
}
|
|
3424
|
+
),
|
|
3425
|
+
suggestions.map((d) => /* @__PURE__ */ jsxs(
|
|
3426
|
+
Button,
|
|
3427
|
+
{
|
|
3428
|
+
variant: "bare",
|
|
3429
|
+
size: "bare",
|
|
3430
|
+
type: "button",
|
|
3431
|
+
onClick: () => add(d.slug),
|
|
3432
|
+
className: "inline-flex items-center gap-1 rounded-full border border-border bg-card px-2 py-0.5 text-[10px] font-medium text-foreground/80 hover:bg-muted",
|
|
3433
|
+
children: [
|
|
3434
|
+
/* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 shrink-0 rounded-full", style: { backgroundColor: dotColor(d.color) } }),
|
|
3435
|
+
d.name
|
|
3436
|
+
]
|
|
3437
|
+
},
|
|
3438
|
+
d.slug
|
|
3439
|
+
))
|
|
3440
|
+
] }),
|
|
3441
|
+
/* @__PURE__ */ jsx(
|
|
3442
|
+
Button,
|
|
3443
|
+
{
|
|
3444
|
+
variant: "bare",
|
|
3445
|
+
size: "bare",
|
|
3446
|
+
type: "button",
|
|
3447
|
+
onClick: () => {
|
|
3448
|
+
setAdding(false);
|
|
3449
|
+
setQuery("");
|
|
3450
|
+
},
|
|
3451
|
+
className: "self-start text-[10px] text-muted-foreground hover:text-foreground",
|
|
3452
|
+
children: t("crm.tagEditor.done")
|
|
3453
|
+
}
|
|
3454
|
+
)
|
|
3455
|
+
] })
|
|
3456
|
+
] });
|
|
3457
|
+
}
|
|
3316
3458
|
function toLocalDate(value) {
|
|
3317
3459
|
const year = value.getFullYear();
|
|
3318
3460
|
const month = String(value.getMonth() + 1).padStart(2, "0");
|
|
@@ -3729,6 +3871,17 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
3729
3871
|
setMovingStage(false);
|
|
3730
3872
|
}
|
|
3731
3873
|
}
|
|
3874
|
+
async function saveTags(next) {
|
|
3875
|
+
if (!deal) return;
|
|
3876
|
+
const prev = deal.tags;
|
|
3877
|
+
setDeal({ ...deal, tags: next });
|
|
3878
|
+
try {
|
|
3879
|
+
await provider.updateDeal(deal.id, { tags: next });
|
|
3880
|
+
} catch {
|
|
3881
|
+
setDeal((d) => d && d.id === deal.id ? { ...d, tags: prev } : d);
|
|
3882
|
+
toast.error(t("crm.tagEditor.saveError"));
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3732
3885
|
async function close(outcome, reason) {
|
|
3733
3886
|
if (!deal || closing) return;
|
|
3734
3887
|
setClosing(true);
|
|
@@ -3846,7 +3999,7 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
3846
3999
|
/* @__PURE__ */ jsx(ThumbsDown, { className: "h-3 w-3" }),
|
|
3847
4000
|
" ",
|
|
3848
4001
|
t("crm.card.markLost")
|
|
3849
|
-
] }) : deal ? /* @__PURE__ */ jsxs(
|
|
4002
|
+
] }) : deal?.status === "won" ? /* @__PURE__ */ jsxs(
|
|
3850
4003
|
"span",
|
|
3851
4004
|
{
|
|
3852
4005
|
className: "inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[11px] font-medium " + (deal.status === "won" ? "bg-success-soft text-success-soft-foreground" : "bg-destructive-soft text-destructive-soft-foreground"),
|
|
@@ -4326,7 +4479,7 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
|
|
|
4326
4479
|
)) })
|
|
4327
4480
|
}
|
|
4328
4481
|
),
|
|
4329
|
-
deal &&
|
|
4482
|
+
deal && /* @__PURE__ */ jsx(Section, { title: t("crm.dealSidebar.tags"), children: /* @__PURE__ */ jsx(TagEditor, { tags: deal.tags, defs: tagDefs, onChange: saveTags }) }),
|
|
4330
4483
|
/* @__PURE__ */ jsx(FormAnswers, { lead })
|
|
4331
4484
|
] })
|
|
4332
4485
|
] }) })
|
|
@@ -10277,5 +10430,5 @@ function CrmPage({ config, provider, store, registries }) {
|
|
|
10277
10430
|
}
|
|
10278
10431
|
|
|
10279
10432
|
export { CrmPage };
|
|
10280
|
-
//# sourceMappingURL=CrmPage-
|
|
10281
|
-
//# sourceMappingURL=CrmPage-
|
|
10433
|
+
//# sourceMappingURL=CrmPage-Z2HRXNCW.js.map
|
|
10434
|
+
//# sourceMappingURL=CrmPage-Z2HRXNCW.js.map
|