@fayz-ai/plugin-crm 0.29.0 → 0.29.2

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.
@@ -28,7 +28,7 @@ export declare const T: {
28
28
  readonly people: "people";
29
29
  readonly personMerges: "person_merges";
30
30
  readonly companies: "plg_crm_companies";
31
- readonly companiesView: "v_crm_companies";
31
+ readonly companiesView: "v_crm_companies_enriched";
32
32
  readonly companyPeople: "plg_crm_company_people";
33
33
  readonly companyPeopleView: "v_crm_company_people";
34
34
  readonly personPhones: "plg_crm_person_phones";
@@ -1 +1 @@
1
- {"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../src/data/tables.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwDJ,CAAA"}
1
+ {"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../src/data/tables.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DJ,CAAA"}
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
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
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
- 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
- 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';
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, MoreHorizontal, ChevronDown, Printer, CircleCheckBig, Ban, Receipt, Package, CalendarClock, Loader2, Network, Fingerprint, Link2, Star, MessageSquareQuote, UserRound, CalendarDays, Search, SignalHigh, CalendarRange, ChevronLeft, TrendingDown, ThumbsDown, UserCheck, AlertTriangle, Settings2, Repeat, Zap, Snowflake, Sun, Flame, Merge, Paperclip, ImageOff, CircleAlert, CircleDashed, CheckCircle2, SlidersHorizontal, ExternalLink, Clipboard, DollarSign, ThumbsUp, UserRoundPlus } from 'lucide-react';
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, Dropdown, DropdownTrigger, DropdownContent, DropdownItem, PhoneLink, SheetBody, SheetFooter, DashboardCanvas, ModalDescription, Card, 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';
7
7
  import { createPortal } from 'react-dom';
8
8
  import { createStore as createStore$1 } from 'zustand/vanilla';
@@ -3221,7 +3221,9 @@ var T = {
3221
3221
  companies: "plg_crm_companies",
3222
3222
  // The read model: the table plus people_count, open_deals, won_value and how
3223
3223
  // many siblings share the CNPJ root. Reads go here, writes to `companies`.
3224
- companiesView: "v_crm_companies",
3224
+ // A enriquecida (059). A 013 continua dona de `v_crm_companies`, que não pode
3225
+ // crescer sem quebrar o replay da cadeia — o porquê está escrito na 059.
3226
+ companiesView: "v_crm_companies_enriched",
3225
3227
  companyPeople: "plg_crm_company_people",
3226
3228
  companyPeopleView: "v_crm_company_people",
3227
3229
  personPhones: "plg_crm_person_phones",
@@ -5848,18 +5850,22 @@ function useQuoteColumns(currency, onEditQuote, onArchive) {
5848
5850
  children: /* @__PURE__ */ jsx(Pencil, { className: "h-3.5 w-3.5" })
5849
5851
  }
5850
5852
  ),
5851
- onArchive && /* @__PURE__ */ jsx(
5852
- "button",
5853
- {
5854
- onClick: (e) => {
5855
- e.stopPropagation();
5856
- onArchive(row.original.id);
5857
- },
5858
- className: "inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",
5859
- title: t2("crm.quotes.archive"),
5860
- children: /* @__PURE__ */ jsx(Archive, { className: "h-3.5 w-3.5" })
5861
- }
5862
- )
5853
+ onArchive && /* @__PURE__ */ jsxs(Dropdown, { children: [
5854
+ /* @__PURE__ */ jsx(DropdownTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
5855
+ "button",
5856
+ {
5857
+ onClick: (e) => e.stopPropagation(),
5858
+ "aria-label": t2("crm.quotes.moreActions"),
5859
+ className: "inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
5860
+ children: /* @__PURE__ */ jsx(MoreHorizontal, { className: "h-3.5 w-3.5" })
5861
+ }
5862
+ ) }),
5863
+ /* @__PURE__ */ jsx(DropdownContent, { align: "end", children: /* @__PURE__ */ jsxs(DropdownItem, { onSelect: () => onArchive(row.original.id), children: [
5864
+ /* @__PURE__ */ jsx(Archive, { className: "h-3.5 w-3.5" }),
5865
+ " ",
5866
+ t2("crm.quotes.archive")
5867
+ ] }) })
5868
+ ] })
5863
5869
  ] })
5864
5870
  });
5865
5871
  }
@@ -5876,9 +5882,8 @@ function QuoteListView({ onNew, onEdit, onEditQuote }) {
5876
5882
  useEffect(() => {
5877
5883
  fetchQuotes({});
5878
5884
  }, []);
5879
- const columns = useQuoteColumns(currency, onEditQuote, canArchive ? (id) => {
5880
- void archiveQuote(id);
5881
- } : void 0);
5885
+ const [alvoArquivo, setAlvoArquivo] = useState(null);
5886
+ const columns = useQuoteColumns(currency, onEditQuote, canArchive ? setAlvoArquivo : void 0);
5882
5887
  const exportRows = useCallback(() => {
5883
5888
  exportCSV(
5884
5889
  [
@@ -5933,6 +5938,21 @@ function QuoteListView({ onNew, onEdit, onEditQuote }) {
5933
5938
  )
5934
5939
  ] })
5935
5940
  }
5941
+ ),
5942
+ /* @__PURE__ */ jsx(
5943
+ ConfirmDialog,
5944
+ {
5945
+ open: alvoArquivo !== null,
5946
+ onCancel: () => setAlvoArquivo(null),
5947
+ variant: "destructive",
5948
+ title: t2("crm.quotes.archiveTitle"),
5949
+ description: t2("crm.quotes.archiveDescription"),
5950
+ confirmLabel: t2("crm.quotes.archive"),
5951
+ onConfirm: async () => {
5952
+ if (alvoArquivo) await archiveQuote(alvoArquivo);
5953
+ setAlvoArquivo(null);
5954
+ }
5955
+ }
5936
5956
  )
5937
5957
  ] });
5938
5958
  }
@@ -7049,6 +7069,7 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote, onOpenComp
7049
7069
  const archiveLead = useCrmStore((s) => s.archiveLead);
7050
7070
  const canArchive = useCanArchive();
7051
7071
  const [archiving, setArchiving] = useState(false);
7072
+ const [confirmandoArquivo, setConfirmandoArquivo] = useState(false);
7052
7073
  const [lead, setLead] = useState(null);
7053
7074
  useRecordVisit(lead ? {
7054
7075
  id: lead.id,
@@ -7152,23 +7173,22 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote, onOpenComp
7152
7173
  }
7153
7174
  ),
7154
7175
  /* @__PURE__ */ jsx(TalkToPerson, { personId: leadId, name: lead.name, phone: lead.phone }),
7155
- canArchive && /* @__PURE__ */ jsxs(
7156
- "button",
7157
- {
7158
- onClick: () => {
7159
- setArchiving(true);
7160
- archiveLead(leadId).then(onBack).catch(() => setArchiving(false));
7161
- },
7162
- disabled: archiving,
7163
- title: t2("crm.leadDetail.archive"),
7164
- className: "inline-flex items-center gap-1.5 rounded-lg border px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground bg-card shadow-button active:shadow-button-inset transition-colors disabled:opacity-60",
7165
- children: [
7166
- /* @__PURE__ */ jsx(Archive, { className: "h-3 w-3" }),
7167
- " ",
7168
- t2("crm.leadDetail.archive")
7169
- ]
7170
- }
7171
- ),
7176
+ canArchive && /* @__PURE__ */ jsxs(Dropdown, { children: [
7177
+ /* @__PURE__ */ jsx(DropdownTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
7178
+ "button",
7179
+ {
7180
+ "aria-label": t2("crm.leadDetail.moreActions"),
7181
+ disabled: archiving,
7182
+ className: "inline-flex h-[30px] w-[30px] items-center justify-center rounded-lg border bg-card text-muted-foreground shadow-button transition-colors hover:bg-muted hover:text-foreground disabled:opacity-60",
7183
+ children: /* @__PURE__ */ jsx(MoreHorizontal, { className: "h-4 w-4" })
7184
+ }
7185
+ ) }),
7186
+ /* @__PURE__ */ jsx(DropdownContent, { align: "end", children: /* @__PURE__ */ jsxs(DropdownItem, { onSelect: () => setConfirmandoArquivo(true), children: [
7187
+ /* @__PURE__ */ jsx(Archive, { className: "h-3.5 w-3.5" }),
7188
+ " ",
7189
+ t2("crm.leadDetail.archive")
7190
+ ] }) })
7191
+ ] }),
7172
7192
  onCreateQuote && lead.status !== "converted" && lead.status !== "lost" && /* @__PURE__ */ jsxs(
7173
7193
  "button",
7174
7194
  {
@@ -7380,7 +7400,28 @@ function LeadDetailView({ leadId, onBack, onCreateQuote, onViewQuote, onOpenComp
7380
7400
  lead.notes && /* @__PURE__ */ jsxs("div", { children: [
7381
7401
  /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-foreground mb-1", children: t2("crm.leadDetail.notes") }),
7382
7402
  /* @__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 }) })
7383
- ] })
7403
+ ] }),
7404
+ /* @__PURE__ */ jsx(
7405
+ ConfirmDialog,
7406
+ {
7407
+ open: confirmandoArquivo,
7408
+ onCancel: () => setConfirmandoArquivo(false),
7409
+ variant: "destructive",
7410
+ title: t2("crm.leadDetail.archiveTitle"),
7411
+ description: t2("crm.leadDetail.archiveDescription"),
7412
+ confirmLabel: t2("crm.leadDetail.archive"),
7413
+ onConfirm: async () => {
7414
+ setArchiving(true);
7415
+ try {
7416
+ await archiveLead(leadId);
7417
+ setConfirmandoArquivo(false);
7418
+ onBack?.();
7419
+ } catch {
7420
+ setArchiving(false);
7421
+ }
7422
+ }
7423
+ }
7424
+ )
7384
7425
  ] });
7385
7426
  }
7386
7427
  var buildColumns2 = (t2) => [
@@ -8022,6 +8063,11 @@ function CompanyDetailView({
8022
8063
  const [unlinkTarget, setUnlinkTarget] = useState(null);
8023
8064
  const [archiving, setArchiving] = useState(false);
8024
8065
  const [linking, setLinking] = useState(false);
8066
+ const negocioDoFunil = useMemo(() => {
8067
+ const abertos = deals.filter((d) => d.status === "open");
8068
+ if (abertos.length === 0) return null;
8069
+ return abertos.reduce((a, b) => (b.updatedAt ?? b.createdAt ?? "") > (a.updatedAt ?? a.createdAt ?? "") ? b : a);
8070
+ }, [deals]);
8025
8071
  const load = useCallback(async () => {
8026
8072
  setLoading(true);
8027
8073
  try {
@@ -8063,26 +8109,42 @@ function CompanyDetailView({
8063
8109
  /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-foreground", children: company.name }),
8064
8110
  company.legalName && company.legalName !== company.name && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: company.legalName })
8065
8111
  ] }),
8066
- /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
8067
- /* @__PURE__ */ jsx(
8112
+ /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [
8113
+ negocioDoFunil && onOpenDeal && /* @__PURE__ */ jsxs(
8068
8114
  "button",
8069
8115
  {
8070
- onClick: () => onEdit?.(company.id),
8071
- className: "rounded-button border bg-card px-3 py-1.5 text-xs font-medium shadow-button hover:bg-muted",
8072
- children: t2("common.edit")
8116
+ onClick: () => onOpenDeal(negocioDoFunil.id),
8117
+ className: "inline-flex items-center gap-1.5 rounded-button bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-button transition-opacity hover:opacity-90",
8118
+ children: [
8119
+ /* @__PURE__ */ jsx(Filter, { className: "h-3 w-3" }),
8120
+ " ",
8121
+ t2("crm.companyDetail.openInPipeline")
8122
+ ]
8073
8123
  }
8074
8124
  ),
8075
- canArchive && /* @__PURE__ */ jsxs(
8125
+ /* @__PURE__ */ jsx(
8076
8126
  "button",
8077
8127
  {
8078
- onClick: () => setArchiving(true),
8128
+ onClick: () => onEdit?.(company.id),
8079
8129
  className: "rounded-button border bg-card px-3 py-1.5 text-xs font-medium shadow-button hover:bg-muted",
8080
- children: [
8081
- /* @__PURE__ */ jsx(Archive, { className: "inline h-3 w-3 mr-1" }),
8082
- t2("crm.companies.archive")
8083
- ]
8130
+ children: t2("common.edit")
8084
8131
  }
8085
- )
8132
+ ),
8133
+ canArchive && /* @__PURE__ */ jsxs(Dropdown, { children: [
8134
+ /* @__PURE__ */ jsx(DropdownTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
8135
+ "button",
8136
+ {
8137
+ "aria-label": t2("crm.companyDetail.moreActions"),
8138
+ className: "inline-flex h-[30px] w-[30px] items-center justify-center rounded-button border bg-card text-muted-foreground shadow-button transition-colors hover:bg-muted hover:text-foreground",
8139
+ children: /* @__PURE__ */ jsx(MoreHorizontal, { className: "h-4 w-4" })
8140
+ }
8141
+ ) }),
8142
+ /* @__PURE__ */ jsx(DropdownContent, { align: "end", children: /* @__PURE__ */ jsxs(DropdownItem, { onSelect: () => setArchiving(true), children: [
8143
+ /* @__PURE__ */ jsx(Archive, { className: "h-3.5 w-3.5" }),
8144
+ " ",
8145
+ t2("crm.companies.archive")
8146
+ ] }) })
8147
+ ] })
8086
8148
  ] })
8087
8149
  ] }),
8088
8150
  /* @__PURE__ */ jsxs("div", { children: [
@@ -28624,6 +28686,83 @@ CREATE OR REPLACE VIEW public.v_deals WITH (security_invoker = true) AS
28624
28686
  GRANT SELECT ON public.v_deals TO authenticated;
28625
28687
  GRANT SELECT ON public.v_deals TO service_role;
28626
28688
  `;
28689
+ var MIGRATION_059_A_EMPRESA_MOSTRA_O_INSTAGRAM_QUE_ELA_GUARDA = `-- 059 \u2014 The company screen shows the Instagram it already stores.
28690
+ --
28691
+ -- \`plg_crm_companies.instagram\` is written by the edit form, and the plugin
28692
+ -- ships \`instagramUrl\`/\`normalizeInstagram\` to render it \u2014 but the read model
28693
+ -- never carried it, so every screen painted a dash beside a filled column.
28694
+ -- Measured on 2026-09-28 with VILA PAULIST\xC2NIA: \`instagram = 'vilapaulistania'\`
28695
+ -- in the table, "\u2014" on the screen. Write-only data.
28696
+ --
28697
+ -- \u2500\u2500 Why a NEW NAME and not a wider \`v_crm_companies\` \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
28698
+ --
28699
+ -- Because the chain is replayed, and 013 owns that name.
28700
+ --
28701
+ -- Widening it with CREATE OR REPLACE applies fine ONCE. On the second pass of
28702
+ -- the chain, 013 runs again \u2014 before this file \u2014 and recreates the view from
28703
+ -- its own narrower column list, over a view that is now wider. Postgres refuses
28704
+ -- outright: \xABcannot drop columns from view\xBB. The bench caught exactly that, and
28705
+ -- no amount of dropping HERE fixes it, because 013 runs first.
28706
+ --
28707
+ -- Editing 013 is not the answer either: it is applied, its checksum is in
28708
+ -- \`public._migrations\`, and the ledger treats a changed checksum as a hard stop.
28709
+ --
28710
+ -- So the enriched read model gets its own name and 013 keeps owning its own,
28711
+ -- untouched and replay-safe. This is the same move the inventory chain already
28712
+ -- made for \`v_inventory_consumption_audit\`, and for the same reason.
28713
+ --
28714
+ -- \`v_crm_companies\` is left in place: it costs nothing, and anything still
28715
+ -- pointing at it keeps working rather than breaking on deploy order.
28716
+
28717
+ CREATE OR REPLACE VIEW public.v_crm_companies_enriched WITH (security_invoker = true) AS
28718
+ SELECT c.id,
28719
+ c.tenant_id,
28720
+ c.name,
28721
+ c.legal_name,
28722
+ c.document_number,
28723
+ c.document_kind,
28724
+ c.document_root,
28725
+ c.document_valid,
28726
+ c.email,
28727
+ c.phone,
28728
+ c.website,
28729
+ c.address,
28730
+ c.city,
28731
+ c.state,
28732
+ c.country,
28733
+ c.postal_code,
28734
+ c.tags,
28735
+ c.notes,
28736
+ c.metadata,
28737
+ c.custom_fields,
28738
+ c.owner_id,
28739
+ c.is_active,
28740
+ c.created_at,
28741
+ c.updated_at,
28742
+ COALESCE(p.people_count, 0) AS people_count,
28743
+ COALESCE(d.open_deals, 0) AS open_deals,
28744
+ COALESCE(d.won_value, 0::numeric) AS won_value,
28745
+ CASE
28746
+ WHEN c.document_root IS NULL THEN 0
28747
+ ELSE COALESCE(g.group_size, 1) - 1
28748
+ END AS group_siblings,
28749
+ c.instagram
28750
+ FROM plg_crm_companies c
28751
+ LEFT JOIN LATERAL ( SELECT count(*)::integer AS people_count
28752
+ FROM plg_crm_company_people cp
28753
+ JOIN people pe ON pe.id = cp.person_id
28754
+ WHERE cp.company_id = c.id) p ON true
28755
+ LEFT JOIN LATERAL ( SELECT count(*) FILTER (WHERE dl.status = 'open'::text)::integer AS open_deals,
28756
+ COALESCE(sum(dl.value) FILTER (WHERE dl.status = 'won'::text), 0::numeric) AS won_value
28757
+ FROM plg_crm_deals dl
28758
+ WHERE dl.company_id = c.id) d ON true
28759
+ LEFT JOIN LATERAL ( SELECT count(*)::integer AS group_size
28760
+ FROM plg_crm_companies s
28761
+ WHERE s.tenant_id = c.tenant_id AND s.document_root = c.document_root) g ON true;
28762
+
28763
+ GRANT SELECT ON public.v_crm_companies_enriched TO authenticated;
28764
+ GRANT SELECT ON public.v_crm_companies_enriched TO service_role;
28765
+ `;
28627
28766
  var MIGRATIONS = [
28628
28767
  { id: "000_baseline", sql: MIGRATION_000_BASELINE },
28629
28768
  { id: "001_de_onde_veio_e_quem_indicou", sql: MIGRATION_001_DE_ONDE_VEIO_E_QUEM_INDICOU },
@@ -28682,7 +28821,8 @@ var MIGRATIONS = [
28682
28821
  { id: "055_a_cesta_do_interesse_tem_onde_morar", sql: MIGRATION_055_A_CESTA_DO_INTERESSE_TEM_ONDE_MORAR },
28683
28822
  { id: "056_o_interesse_entra_pelo_agendamento", sql: MIGRATION_056_O_INTERESSE_ENTRA_PELO_AGENDAMENTO },
28684
28823
  { id: "057_o_negocio_e_do_grupo_nao_do_cnpj", sql: MIGRATION_057_O_NEGOCIO_E_DO_GRUPO_NAO_DO_CNPJ },
28685
- { id: "058_o_card_diz_o_nome_do_grupo", sql: MIGRATION_058_O_CARD_DIZ_O_NOME_DO_GRUPO }
28824
+ { id: "058_o_card_diz_o_nome_do_grupo", sql: MIGRATION_058_O_CARD_DIZ_O_NOME_DO_GRUPO },
28825
+ { id: "059_a_empresa_mostra_o_instagram_que_ela_guarda", sql: MIGRATION_059_A_EMPRESA_MOSTRA_O_INSTAGRAM_QUE_ELA_GUARDA }
28686
28826
  ];
28687
28827
 
28688
28828
  // src/locales/en.ts
@@ -28751,6 +28891,9 @@ var en = {
28751
28891
  "crm.dealSidebar.viewLeadProfile": "View Full Lead Profile",
28752
28892
  "crm.leadDetail.assignedTo": "Assigned to",
28753
28893
  "crm.leadDetail.archive": "Archive",
28894
+ "crm.leadDetail.archiveTitle": "Archive this lead?",
28895
+ "crm.leadDetail.archiveDescription": "It leaves the lists and the pipeline, and its history is kept. The deal linked to it is not archived with it.",
28896
+ "crm.leadDetail.moreActions": "More actions",
28754
28897
  "crm.leadDetail.backToList": "Back to list",
28755
28898
  "crm.leadDetail.formAnswers": "Form answers",
28756
28899
  "crm.leadDetail.attachments": "Attachments",
@@ -29097,6 +29240,9 @@ var en = {
29097
29240
  "crm.quoteForm.validUntil": "Valid Until",
29098
29241
  "crm.quotes.amount": "Amount",
29099
29242
  "crm.quotes.archive": "Archive",
29243
+ "crm.quotes.archiveTitle": "Archive this quote?",
29244
+ "crm.quotes.archiveDescription": "It leaves the list and its history is kept. The deal and the lead linked to it do not change.",
29245
+ "crm.quotes.moreActions": "More actions",
29100
29246
  "crm.quotes.contact": "Contact",
29101
29247
  "crm.quotes.createFirst": "Create your first quote",
29102
29248
  "crm.quotes.date": "Date",
@@ -29192,6 +29338,8 @@ var en = {
29192
29338
  "crm.companies.noCompanies": "No companies yet",
29193
29339
  "crm.companies.createFirst": "Add the first one",
29194
29340
  "crm.companies.archive": "Archive",
29341
+ "crm.companyDetail.openInPipeline": "View in pipeline",
29342
+ "crm.companyDetail.moreActions": "More actions",
29195
29343
  "crm.companies.archiveTitle": "Archive company?",
29196
29344
  "crm.companies.archiveDescription": "It leaves the list and keeps its history. Deals already stamped with it are untouched.",
29197
29345
  "crm.companyDetail.link": "Link contact",
@@ -29596,6 +29744,9 @@ var ptBR = {
29596
29744
  "crm.dealSidebar.viewLeadProfile": "Ver Perfil Completo do Lead",
29597
29745
  "crm.leadDetail.assignedTo": "Atribu\xEDdo a",
29598
29746
  "crm.leadDetail.archive": "Arquivar",
29747
+ "crm.leadDetail.archiveTitle": "Arquivar este lead?",
29748
+ "crm.leadDetail.archiveDescription": "Sai das listas e do funil, e o hist\xF3rico fica guardado. O neg\xF3cio ligado a ele n\xE3o \xE9 arquivado junto.",
29749
+ "crm.leadDetail.moreActions": "Mais a\xE7\xF5es",
29599
29750
  "crm.leadDetail.backToList": "Voltar \xE0 lista",
29600
29751
  "crm.leadDetail.formAnswers": "Dados do formul\xE1rio",
29601
29752
  "crm.leadDetail.attachments": "Anexos",
@@ -29942,6 +30093,9 @@ var ptBR = {
29942
30093
  "crm.quoteForm.validUntil": "V\xE1lido At\xE9",
29943
30094
  "crm.quotes.amount": "Valor",
29944
30095
  "crm.quotes.archive": "Arquivar",
30096
+ "crm.quotes.archiveTitle": "Arquivar este or\xE7amento?",
30097
+ "crm.quotes.archiveDescription": "Sai da lista e o hist\xF3rico fica guardado. O neg\xF3cio e o lead ligados a ele n\xE3o mudam.",
30098
+ "crm.quotes.moreActions": "Mais a\xE7\xF5es",
29945
30099
  "crm.quotes.contact": "Contato",
29946
30100
  "crm.quotes.createFirst": "Crie seu primeiro or\xE7amento",
29947
30101
  "crm.quotes.date": "Data",
@@ -30037,6 +30191,8 @@ var ptBR = {
30037
30191
  "crm.companies.noCompanies": "Nenhuma empresa ainda",
30038
30192
  "crm.companies.createFirst": "Cadastrar a primeira",
30039
30193
  "crm.companies.archive": "Arquivar",
30194
+ "crm.companyDetail.openInPipeline": "Ver no funil",
30195
+ "crm.companyDetail.moreActions": "Mais a\xE7\xF5es",
30040
30196
  "crm.companies.archiveTitle": "Arquivar empresa?",
30041
30197
  "crm.companies.archiveDescription": "Sai da lista e mant\xE9m o hist\xF3rico. Neg\xF3cios j\xE1 carimbados com ela n\xE3o mudam.",
30042
30198
  "crm.companyDetail.link": "Vincular contato",