@fayz-ai/plugin-crm 0.18.0 → 0.19.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":"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"}
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,CAusElB"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import React, { useState, useEffect, useMemo, useCallback, 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
3
  import { createPluginContext, useUnitBootstrap, useUnitStore, createCrudPage, PluginSettingsPanel, registerTimelineSource, dedup, useModuleNavigation, createViewRouter, ModuleActionBar, usePermissionOptional, PageActions, useTenantPluginSettings, SettingsGroup, ToggleRow, adminNavigateTo, useLimitGuard, OrderFormSkeleton, OrderFormBlock, OrderFormView, OrderFormItemsCard, OrderFormItemRow, OrderFormAddItemStep, formatCurrency, OrderDetailSkeleton, OrderDetailBlock, OrderDetailView, PersonLink, RightRailPage, KanbanBoard, invalidateLimit, useAccessOptional, useOrganizationStore, getRailPage, ContactPicker } from '@fayz-ai/admin';
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, User, Building2, Download, Inbox, Play, Clock, Sparkles, Calendar, ArrowRight, ChevronDown, Printer, CircleCheckBig, Ban, Receipt, Package, CalendarClock, Loader2, Network, Link2, Star, MessageSquareQuote, Search, SignalHigh, CalendarRange, ChevronLeft, TrendingDown, ThumbsDown, UserCheck, AlertTriangle, Settings2, Repeat, Zap, Snowflake, Sun, Flame, Merge, Fingerprint, Paperclip, ImageOff, CircleAlert, CircleDashed, CheckCircle2, Clipboard, DollarSign, ThumbsUp } from 'lucide-react';
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, User, Building2, Download, Inbox, Play, Clock, Sparkles, Calendar, ArrowRight, ChevronDown, Printer, CircleCheckBig, Ban, Receipt, Package, CalendarClock, Loader2, Network, Fingerprint, Link2, Star, MessageSquareQuote, Search, SignalHigh, CalendarRange, ChevronLeft, TrendingDown, ThumbsDown, UserCheck, AlertTriangle, Settings2, Repeat, Zap, Snowflake, Sun, Flame, Merge, Paperclip, ImageOff, CircleAlert, CircleDashed, CheckCircle2, Clipboard, DollarSign, ThumbsUp } from 'lucide-react';
5
5
  import { Badge, Checkbox, toast, defineKpiWidget, defineChartWidget, defineCustomWidget, defineTableWidget, PageTransition, ModulePage, SubpageHeader, Button, TooltipProvider, Tooltip, TooltipTrigger, TooltipContent, Switch, ConfirmDialog, useIsWide, SegmentedControl, PageHeaderActions, FilterChip, MultiSelect, ListView, Modal, ModalContent, ModalHeader, ModalTitle, ModalBody, Input, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, ModalFooter, useSaveBar, SearchSelect, DatePicker, DataTable, Breadcrumb, PhoneLink, SheetBody, SheetFooter, DashboardCanvas, ModalDescription, Card, CurrencyInput, HeaderTabs, Dropdown, DropdownTrigger, DropdownContent, DropdownLabel, DropdownSeparator, DropdownItem, PageToolbar, ToolbarButton, RangeControl, Popover, PopoverTrigger, PopoverContent, getLucideIcon, DictateButton, normalizePhone, KpiCard, ChartWidget, CardHeader, CardTitle, CardContent, TableWidget } from '@fayz-ai/ui';
6
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
7
  import { createPortal } from 'react-dom';
@@ -254,7 +254,7 @@ function GroupRow({ g, onOpen, open, members, roll, onEdit, onAdd, onRemove, onD
254
254
  /* @__PURE__ */ jsx("span", { className: "font-medium", children: m.companyName }),
255
255
  m.companyLegalName && m.companyLegalName !== m.companyName && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: m.companyLegalName }),
256
256
  m.companyDocument && /* @__PURE__ */ jsx("span", { className: "tabular-nums text-muted-foreground", children: m.companyDocument }),
257
- m.source && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground/70", children: m.source === "cnpj_root" ? "pela raiz do CNPJ" : "declarado" }),
257
+ m.source && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground/70", children: m.source === "document_root" ? "pela raiz do CNPJ" : "declarado" }),
258
258
  editing && /* @__PURE__ */ jsx(
259
259
  "button",
260
260
  {
@@ -6269,6 +6269,7 @@ function CompanyDetailView({
6269
6269
  const archiveCompany = useCrmStore((s) => s.archiveCompany);
6270
6270
  const unlinkCompanyPerson = useCrmStore((s) => s.unlinkCompanyPerson);
6271
6271
  const [company, setCompany] = useState(null);
6272
+ const [receita, setReceita] = useState(null);
6272
6273
  const [people, setPeople] = useState([]);
6273
6274
  const [deals, setDeals] = useState([]);
6274
6275
  const [loading, setLoading] = useState(true);
@@ -6295,6 +6296,17 @@ function CompanyDetailView({
6295
6296
  useEffect(() => {
6296
6297
  void load();
6297
6298
  }, [load]);
6299
+ useEffect(() => {
6300
+ let vivo = true;
6301
+ provider.getCompanyReceita(companyId).then((r) => {
6302
+ if (vivo) setReceita(r);
6303
+ }).catch(() => {
6304
+ if (vivo) setReceita(null);
6305
+ });
6306
+ return () => {
6307
+ vivo = false;
6308
+ };
6309
+ }, [provider, companyId]);
6298
6310
  if (loading) return /* @__PURE__ */ jsx("div", { className: "p-6 text-sm text-muted-foreground", children: t2("common.loading") });
6299
6311
  if (!company) return /* @__PURE__ */ jsx("div", { className: "p-6 text-sm text-muted-foreground", children: t2("crm.companyDetail.notFound") });
6300
6312
  return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
@@ -6363,6 +6375,52 @@ function CompanyDetailView({
6363
6375
  ) })
6364
6376
  ] }) })
6365
6377
  ] }),
6378
+ receita && /* @__PURE__ */ jsxs("div", { children: [
6379
+ /* @__PURE__ */ jsxs("h3", { className: "mb-1 flex items-center gap-1.5 text-sm font-semibold text-foreground", children: [
6380
+ /* @__PURE__ */ jsx(Fingerprint, { className: "h-3.5 w-3.5 text-muted-foreground" }),
6381
+ t2("crm.companyDetail.receita"),
6382
+ receita.consultadoEm && /* @__PURE__ */ jsxs("span", { className: "text-xs font-normal text-muted-foreground", children: [
6383
+ "\xB7 ",
6384
+ t2("crm.companyDetail.receitaCheckedOn"),
6385
+ " ",
6386
+ receita.consultadoEm
6387
+ ] })
6388
+ ] }),
6389
+ /* @__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: [
6390
+ /* @__PURE__ */ jsx("div", { className: "px-5 md:border-b", children: /* @__PURE__ */ jsx(FieldRow2, { label: t2("crm.companyDetail.receitaSituacao"), value: receita.situacao ? (
6391
+ // "BAIXADA" não é um detalhe: é a empresa não existir mais.
6392
+ // Em cinzento ao lado de porte e capital, passa despercebida.
6393
+ /* @__PURE__ */ jsx("span", { className: receita.situacao === "ATIVA" ? void 0 : "font-medium text-destructive", children: receita.situacao })
6394
+ ) : null }) }),
6395
+ /* @__PURE__ */ jsx("div", { className: "px-5 md:border-b", children: /* @__PURE__ */ jsx(FieldRow2, { label: t2("crm.companyDetail.receitaLegalName"), value: receita.razaoSocial ?? null }) }),
6396
+ /* @__PURE__ */ jsx("div", { className: "px-5 md:border-b", children: /* @__PURE__ */ jsx(FieldRow2, { label: t2("crm.companyDetail.receitaPorte"), value: receita.porte ?? null }) }),
6397
+ /* @__PURE__ */ jsx("div", { className: "px-5 md:border-b", children: /* @__PURE__ */ jsx(
6398
+ FieldRow2,
6399
+ {
6400
+ label: t2("crm.companyDetail.receitaCapital"),
6401
+ value: receita.capitalSocial != null ? formatCurrency(receita.capitalSocial, currency) : null
6402
+ }
6403
+ ) }),
6404
+ /* @__PURE__ */ jsx("div", { className: "px-5 md:border-b", children: /* @__PURE__ */ jsx(FieldRow2, { label: t2("crm.companyDetail.receitaOpened"), value: receita.abertura ?? null }) }),
6405
+ /* @__PURE__ */ jsx("div", { className: "px-5 md:border-b", children: /* @__PURE__ */ jsx(
6406
+ FieldRow2,
6407
+ {
6408
+ label: t2("crm.companyDetail.receitaPartners"),
6409
+ value: receita.socios != null ? String(receita.socios) : null
6410
+ }
6411
+ ) }),
6412
+ /* @__PURE__ */ jsx("div", { className: "px-5 md:col-span-2 md:border-t", children: /* @__PURE__ */ jsx(
6413
+ FieldRow2,
6414
+ {
6415
+ label: t2("crm.companyDetail.receitaCnae"),
6416
+ value: receita.cnaeDescricao ? /* @__PURE__ */ jsxs("span", { children: [
6417
+ receita.cnaeDescricao,
6418
+ receita.cnae && /* @__PURE__ */ jsx("span", { className: "ml-1.5 tabular-nums text-muted-foreground", children: receita.cnae })
6419
+ ] }) : receita.cnae ?? null
6420
+ }
6421
+ ) })
6422
+ ] }) })
6423
+ ] }),
6366
6424
  (company.groupSiblings ?? 0) > 0 && /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
6367
6425
  /* @__PURE__ */ jsx(Link2, { className: "inline h-3 w-3 mr-1" }),
6368
6426
  t2("crm.companyDetail.groupHint", { count: String(company.groupSiblings) })
@@ -12014,10 +12072,17 @@ function createSupabaseCrmProvider(options) {
12014
12072
  tenant_id: tenantId,
12015
12073
  group_id: group.id,
12016
12074
  company_id: cid,
12017
- // `cnpj_root` e não `manual`: quem aceitou a proposta confirmou o que
12018
- // a raiz do CNPJ dizia. Guardar a PROCEDÊNCIA é o que deixa alguém,
12019
- // meses depois, saber se aquilo foi conferido ou deduzido.
12020
- source: documentRoot2 ? "cnpj_root" : "manual"
12075
+ // `document_root` e não `manual`: quem aceitou a proposta confirmou o
12076
+ // que a raiz do documento dizia. Guardar a PROCEDÊNCIA é o que deixa
12077
+ // alguém, meses depois, saber se aquilo foi conferido ou deduzido.
12078
+ //
12079
+ // O nome é o do CHECK da coluna (`manual, document_root,
12080
+ // shared_phone, email_domain, import`), não um sinónimo. Estava
12081
+ // `cnpj_root`, que a restrição recusa — e confirmar uma sugestão por
12082
+ // raiz de documento nunca chegou a funcionar: dava
12083
+ // `plg_crm_company_group_members_source_check` na cara de quem
12084
+ // clicava. O banco é quem define este vocabulário.
12085
+ source: documentRoot2 ? "document_root" : "manual"
12021
12086
  }))
12022
12087
  );
12023
12088
  if (e2) throw new Error(e2.message);
@@ -25610,6 +25675,15 @@ var en = {
25610
25675
  "crm.companyDetail.linkAlreadyAt": "already at",
25611
25676
  "crm.companyDetail.linkRole": "Role here",
25612
25677
  "crm.companyDetail.linkRolePlaceholder": "Owner / partner, manager\u2026",
25678
+ "crm.companyDetail.receita": "Federal tax registry",
25679
+ "crm.companyDetail.receitaCheckedOn": "checked on",
25680
+ "crm.companyDetail.receitaSituacao": "Registration status",
25681
+ "crm.companyDetail.receitaLegalName": "Legal name",
25682
+ "crm.companyDetail.receitaPorte": "Size",
25683
+ "crm.companyDetail.receitaCapital": "Share capital",
25684
+ "crm.companyDetail.receitaOpened": "Opened",
25685
+ "crm.companyDetail.receitaPartners": "Partners",
25686
+ "crm.companyDetail.receitaCnae": "Activity (CNAE)",
25613
25687
  "crm.companyDetail.identity": "Identification",
25614
25688
  "crm.companyDetail.email": "Email",
25615
25689
  "crm.companyDetail.phone": "Phone",
@@ -26390,6 +26464,15 @@ var ptBR = {
26390
26464
  "crm.companyDetail.linkAlreadyAt": "j\xE1 est\xE1 em",
26391
26465
  "crm.companyDetail.linkRole": "Cargo aqui",
26392
26466
  "crm.companyDetail.linkRolePlaceholder": "Propriet\xE1rio / s\xF3cio, ger\xEAncia\u2026",
26467
+ "crm.companyDetail.receita": "Receita Federal",
26468
+ "crm.companyDetail.receitaCheckedOn": "consultado em",
26469
+ "crm.companyDetail.receitaSituacao": "Situa\xE7\xE3o cadastral",
26470
+ "crm.companyDetail.receitaLegalName": "Raz\xE3o social",
26471
+ "crm.companyDetail.receitaPorte": "Porte",
26472
+ "crm.companyDetail.receitaCapital": "Capital social",
26473
+ "crm.companyDetail.receitaOpened": "Abertura",
26474
+ "crm.companyDetail.receitaPartners": "S\xF3cios",
26475
+ "crm.companyDetail.receitaCnae": "Atividade (CNAE)",
26393
26476
  "crm.companyDetail.identity": "Identifica\xE7\xE3o",
26394
26477
  "crm.companyDetail.email": "E-mail",
26395
26478
  "crm.companyDetail.phone": "Telefone",