@fayz-ai/plugin-crm 0.17.0 → 0.18.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.
@@ -1 +1 @@
1
- {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/data/mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AA2K9C,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE;IAC9C,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACxE,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACvE,GAAG,eAAe,CA0pClB"}
1
+ {"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/data/mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AA2K9C,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE;IAC9C,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACxE,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACvE,GAAG,eAAe,CAiqClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../../src/data/supabase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAwQ9C,wBAAgB,yBAAyB,CAAC,OAAO,CAAC,EAAE;IAClD,gBAAgB,CAAC,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;IACtF,kFAAkF;IAClF,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACvE,GAAG,eAAe,CA2qElB"}
1
+ {"version":3,"file":"supabase.d.ts","sourceRoot":"","sources":["../../src/data/supabase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AA+Q9C,wBAAgB,yBAAyB,CAAC,OAAO,CAAC,EAAE;IAClD,gBAAgB,CAAC,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;IACtF,kFAAkF;IAClF,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACvE,GAAG,eAAe,CAgsElB"}
package/dist/index.js CHANGED
@@ -1180,6 +1180,11 @@ function PipelineView({ onDealClick, onAddLead, onOpenSettings }) {
1180
1180
  const [customTo, setCustomTo] = useState(() => localDate());
1181
1181
  const [selectedTags, setSelectedTags] = useState([]);
1182
1182
  const [search, setSearch] = useState("");
1183
+ const [searchNoBanco, setSearchNoBanco] = useState("");
1184
+ useEffect(() => {
1185
+ const t3 = setTimeout(() => setSearchNoBanco(search.trim()), 300);
1186
+ return () => clearTimeout(t3);
1187
+ }, [search]);
1183
1188
  const [dragOverStageId, setDragOverStageId] = useState(null);
1184
1189
  const [savingDealIds, setSavingDealIds] = useState(/* @__PURE__ */ new Set());
1185
1190
  const [optimisticBoard, setOptimisticBoard] = useState(null);
@@ -1189,8 +1194,13 @@ function PipelineView({ onDealClick, onAddLead, onOpenSettings }) {
1189
1194
  savingRef.current = savingDealIds;
1190
1195
  const boardFilter = useMemo(() => ({
1191
1196
  ...selectedTags.length ? { tags: selectedTags } : {},
1197
+ ...searchNoBanco ? {
1198
+ search: searchNoBanco,
1199
+ // O de-para nome→slug vive aqui porque é aqui que o cadastro está.
1200
+ searchTags: [...tagDefs?.values() ?? []].filter((d) => d.name.toLowerCase().includes(searchNoBanco.toLowerCase())).map((d) => d.slug)
1201
+ } : {},
1192
1202
  ...periodToRange(period, customFrom, customTo)
1193
- }), [selectedTags, period, customFrom, customTo]);
1203
+ }), [selectedTags, searchNoBanco, tagDefs, period, customFrom, customTo]);
1194
1204
  const filterKey = JSON.stringify(boardFilter);
1195
1205
  const availableTags = useMemo(() => [...tagDefs.keys()], [tagDefs]);
1196
1206
  const tenantId = useActiveTenantId();
@@ -3439,18 +3449,12 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
3439
3449
  ]
3440
3450
  }
3441
3451
  ) : null,
3442
- onCreateQuote && lead && /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outline", onClick: () => {
3443
- onCreateQuote(lead.id);
3444
- onClose();
3445
- }, children: [
3452
+ onCreateQuote && lead && /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outline", onClick: () => onCreateQuote(lead.id), children: [
3446
3453
  /* @__PURE__ */ jsx(FileText, { className: "h-3 w-3" }),
3447
3454
  " ",
3448
3455
  t2("crm.leadDetail.createQuote")
3449
3456
  ] }),
3450
- onViewLead && lead && /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "ghost", onClick: () => {
3451
- onViewLead(lead.id);
3452
- onClose();
3453
- }, children: [
3457
+ onViewLead && lead && /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "ghost", onClick: () => onViewLead(lead.id), children: [
3454
3458
  t2("crm.dealSidebar.viewLeadProfile"),
3455
3459
  " ",
3456
3460
  /* @__PURE__ */ jsx(ArrowRight, { className: "h-3 w-3" })
@@ -3536,10 +3540,7 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
3536
3540
  "button",
3537
3541
  {
3538
3542
  type: "button",
3539
- onClick: () => {
3540
- onViewCompany?.(company.id);
3541
- onClose();
3542
- },
3543
+ onClick: () => onViewCompany?.(company.id),
3543
3544
  disabled: !onViewCompany,
3544
3545
  className: "flex w-full items-center gap-3 rounded-card border bg-card px-4 py-3 text-left shadow-sm transition-colors enabled:hover:bg-muted/20",
3545
3546
  children: [
@@ -3614,10 +3615,7 @@ function DealCardModal({ dealId, open, onClose, onViewLead, onViewQuote, onViewC
3614
3615
  quotes2.length > 0 && /* @__PURE__ */ jsx(Section, { title: t2("crm.dealSidebar.quotes"), children: /* @__PURE__ */ jsx("div", { className: "divide-y rounded-card border", children: quotes2.map((q) => /* @__PURE__ */ jsxs(
3615
3616
  "div",
3616
3617
  {
3617
- onClick: () => {
3618
- onViewQuote?.(q.id);
3619
- onClose();
3620
- },
3618
+ onClick: () => onViewQuote?.(q.id),
3621
3619
  className: "flex cursor-pointer items-center justify-between px-4 py-2.5 transition-colors hover:bg-muted/20",
3622
3620
  children: [
3623
3621
  /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
@@ -9116,6 +9114,13 @@ function createMockCrmProvider(options) {
9116
9114
  const stages = knownStages ?? store.stages.filter((s) => s.pipelineId === pipelineId).sort((a, b) => a.order - b.order);
9117
9115
  const matches2 = (d) => {
9118
9116
  if (filter?.tags?.length && !filter.tags.some((t2) => (d.tags ?? []).includes(t2))) return false;
9117
+ if (filter?.search) {
9118
+ const t2 = filter.search.toLowerCase();
9119
+ const campos = [d.title, d.contactName, d.notes, d.lostReason, d.stageName, d.contactStatusName];
9120
+ const porTexto = campos.some((c) => (c ?? "").toLowerCase().includes(t2));
9121
+ const porTag = filter.searchTags?.some((slug) => (d.tags ?? []).includes(slug)) ?? false;
9122
+ if (!porTexto && !porTag) return false;
9123
+ }
9119
9124
  if (filter?.createdFrom && d.createdAt < filter.createdFrom) return false;
9120
9125
  if (filter?.createdTo && d.createdAt > filter.createdTo) return false;
9121
9126
  return true;
@@ -10251,6 +10256,7 @@ function snakeToCamel(obj) {
10251
10256
  return result;
10252
10257
  }
10253
10258
  var DEALS_POR_ETAPA = 100;
10259
+ var BUSCA_NO_QUADRO = ["title", "contact_name", "notes", "lost_reason", "stage_name", "contact_status_name"];
10254
10260
  async function callBacklog(limit, dryRun) {
10255
10261
  const supabase = getSupabaseClientOptional();
10256
10262
  if (!supabase) throw new Error("Supabase not initialized");
@@ -10543,6 +10549,14 @@ function createSupabaseCrmProvider(options) {
10543
10549
  const montar = async (stageId) => {
10544
10550
  let qb = pub.from("v_deals").select("*", { count: "exact" }).eq("pipeline_id", pipelineId).eq("stage_id", stageId).not("status", "in", "(lost,archived)");
10545
10551
  if (filter?.tags?.length) qb = qb.overlaps("tags", filter.tags);
10552
+ if (filter?.search) {
10553
+ const t2 = filter.search.replace(/[(),]/g, " ").trim();
10554
+ if (t2) {
10555
+ const ramos = BUSCA_NO_QUADRO.map((c) => `${c}.ilike.*${t2}*`);
10556
+ if (filter.searchTags?.length) ramos.push(`tags.ov.{${filter.searchTags.join(",")}}`);
10557
+ qb = qb.or(ramos.join(","));
10558
+ }
10559
+ }
10546
10560
  if (filter?.createdFrom) qb = qb.gte("created_at", filter.createdFrom);
10547
10561
  if (filter?.createdTo) qb = qb.lte("created_at", filter.createdTo);
10548
10562
  const teto = limits?.[stageId] ?? DEALS_POR_ETAPA;