@credithub/harlan-components 1.89.0 → 1.91.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.
@@ -96,7 +96,8 @@ function deepCleanData(data) {
96
96
  // -----------------------------------------------------------------------------
97
97
  export var selectRelevantData = function (data) {
98
98
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
99
- var _l = data || {}, protestosNumero = _l.protestos, ccfNumero = _l.ccf, dividasPublicas = _l.dividasPublicas, contasBancarias = _l.bankAccounts, ccfData = _l.ccfData, dividas = _l.divida, _m = _l.dossie, dossie = _m === void 0 ? {} : _m, liminar = _l.liminar, socios = _l.partners, dadosPessoasExpostasPoliticamente = _l.pepData, detalhesProcessosJuridicos = _l.processosJuridicosData, dadosReclameAqui = _l.reclameAqui, refinBoaVista = _l.refinBoaVista, refinSerasa = _l.refinSerasa, dadosScore = _l.scoreData, _o = _l.scr, scr = _o === void 0 ? { isLoaded: false } : _o, _p = _l.veiculos, veiculos = _p === void 0 ? [] : _p, ResumoDosDados = _l.documentHistory;
99
+ var _l = data || {}, protestosNumero = _l.protestos, ccfNumero = _l.ccf, dividasPublicas = _l.dividasPublicas, contasBancarias = _l.bankAccounts, ccfData = _l.ccfData, dividas = _l.divida, _m = _l.dossie, dossie = _m === void 0 ? {} : _m, liminar = _l.liminar, socios = _l.partners, dadosPessoasExpostasPoliticamente = _l.pepData, detalhesProcessosJuridicos = _l.processosJuridicosData, dadosReclameAqui = _l.reclameAqui, refinBoaVista = _l.refinBoaVista, refinSerasa = _l.refinSerasa, dadosScore = _l.scoreData, _o = _l.scr, scr = _o === void 0 ? { isLoaded: false } : _o, _p = _l.veiculos, veiculos = _p === void 0 ? [] : _p, ResumoDosDados = _l.documentHistory, insolvencia = _l.insolvencia // ← novo
100
+ ;
100
101
  // ────────────────────────────────────────────────
101
102
  // 1. Protestos – somente a entrada mais recente
102
103
  // ────────────────────────────────────────────────
@@ -162,6 +163,12 @@ export var selectRelevantData = function (data) {
162
163
  });
163
164
  });
164
165
  // ────────────────────────────────────────────────
166
+ // 0‑bis. Falência / Insolvência
167
+ // ────────────────────────────────────────────────
168
+ var insolvenciaInfo = insolvencia
169
+ ? 'Registro de falência encontrado'
170
+ : undefined;
171
+ // ────────────────────────────────────────────────
165
172
  // 6. Construção final
166
173
  // ────────────────────────────────────────────────
167
174
  var dadosOrganizados = {
@@ -184,7 +191,8 @@ export var selectRelevantData = function (data) {
184
191
  dadosReclameAqui: dadosReclameAqui,
185
192
  dadosScore: dadosScore,
186
193
  ResumoDosDados: ResumoSafe,
187
- tipoPessoa: tipoPessoa
194
+ tipoPessoa: tipoPessoa,
195
+ insolvencia: insolvenciaInfo
188
196
  };
189
197
  var dadosFiltrados = deepCleanData(dadosOrganizados);
190
198
  return { dadosFiltrados: dadosFiltrados };
@@ -50,7 +50,6 @@ var Falencia = function (_a) {
50
50
  var documento = _a.documento;
51
51
  var setData = useGlobalData().setData;
52
52
  var _b = useState(false), dataUpdated = _b[0], setDataUpdated = _b[1];
53
- // ⬇️ 1. traga o loadingProgress
54
53
  var _c = useQuery("SELECT FROM 'ValorEconomico'.'Falencia'", { documento: documento }), response = _c.response, error = _c.error, isLoading = _c.isLoading, loadingProgress = _c.loadingProgress, refetch = _c.refetch;
55
54
  var items = useMemo(function () { return parseFalencia(response === null || response === void 0 ? void 0 : response.document); }, [response]);
56
55
  var insolvencia = useMemo(function () { return items.length > 0; }, [items]);
@@ -1,5 +1,5 @@
1
- import { HasCreditsType } from '../consultasComplementares';
2
1
  import React from 'react';
2
+ import { HasCreditsType } from '../consultasComplementares';
3
3
  interface LiminarProps {
4
4
  /**
5
5
  * Se verdadeiro, exibe ações exclusivas para instituições financeiras,
@@ -50,10 +50,10 @@ import ProtestosIcon from '../../assets/icones/protestos';
50
50
  import { useGlobalData } from '../../contexts/globalDataContext';
51
51
  import theme from '../../styles/theme';
52
52
  import { formatMoney } from '../../utils/number';
53
- import { normalizeName, normalizeNameStrong, similarCompanyNames } from '../../utils/similarNames';
53
+ import { normalizeName, similarCompanyNames } from '../../utils/similarNames';
54
54
  import { hasOneOfTags } from '../../utils/tags';
55
55
  import { WarningCircle } from 'phosphor-react';
56
- import { useContext, useEffect, useMemo, useRef, useState } from 'react';
56
+ import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
57
57
  import Button from '../common/button';
58
58
  import Modal from '../common/modal';
59
59
  import { SummaryButton } from '../dossie/summary/styles';
@@ -61,8 +61,8 @@ import StatusMessage from '../interface/statusMessage';
61
61
  import Section from '../section';
62
62
  import { Queries, RequestStatus, useFetch } from '../webservice';
63
63
  import { TitleWithTooltip, TooltipContainer, TooltipText } from './liminarStyles';
64
+ import { useLiminarHistory } from './useLiminarHistory';
64
65
  import useLiminarProtestosDoPassado from './useLiminarProtestosDoPassado';
65
- import React from 'react';
66
66
  /* ----------------------------------
67
67
  * Constantes
68
68
  * ---------------------------------*/
@@ -84,22 +84,22 @@ var businessTypes = [
84
84
  'cooperativa'
85
85
  ];
86
86
  var Liminar = function (_a) {
87
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
88
- var _o = _a.isFinancial, isFinancial = _o === void 0 ? false : _o, hasCredits = _a.hasCredits, _p = _a.tags, tags = _p === void 0 ? [] : _p;
87
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
88
+ var _u = _a.isFinancial, isFinancial = _u === void 0 ? false : _u, hasCredits = _a.hasCredits, _v = _a.tags, tags = _v === void 0 ? [] : _v;
89
89
  var ctx = useContext(Queries.LiminarCenprot);
90
- var _q = useGlobalData(), globalData = _q.data, setData = _q.setData;
90
+ var _w = useGlobalData(), globalData = _w.data, setData = _w.setData;
91
91
  var fetchLiminarProtestosDoPassado = useLiminarProtestosDoPassado({
92
92
  documento: ((_c = (_b = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _b === void 0 ? void 0 : _b.carousel) === null || _c === void 0 ? void 0 : _c.document) || ''
93
93
  }).fetchLiminarProtestosDoPassado;
94
- var _r = useState(false), isLoadingLiminarProtestosDoPassado = _r[0], setIsLoadingLiminarProtestosDoPassado = _r[1];
94
+ var _x = useState(false), isLoadingLiminarProtestosDoPassado = _x[0], setIsLoadingLiminarProtestosDoPassado = _x[1];
95
95
  var processedRef = useRef(false);
96
96
  var dataHashRef = useRef('');
97
97
  var invertedIdsRef = useRef([]);
98
- var _s = useState(false), isTooltipVisible = _s[0], setTooltipVisible = _s[1];
99
- var _t = useState(false), isEmailModalOpen = _t[0], setIsEmailModalOpen = _t[1];
100
- var _u = useState(''), emailModalMessage = _u[0], setEmailModalMessage = _u[1];
98
+ var _y = useState(false), isTooltipVisible = _y[0], setTooltipVisible = _y[1];
99
+ var _z = useState(false), isEmailModalOpen = _z[0], setIsEmailModalOpen = _z[1];
100
+ var _0 = useState(''), emailModalMessage = _0[0], setEmailModalMessage = _0[1];
101
101
  var liminarMailPrice = 50000;
102
- var _v = useFetch("SELECT FROM 'LIMINAR'.'SENDMAIL'"), sendIndiciosEmail = _v.fetch, isEmailSending = _v.isLoading, emailError = _v.error;
102
+ var _1 = useFetch("SELECT FROM 'LIMINAR'.'SENDMAIL'"), sendIndiciosEmail = _1.fetch, isEmailSending = _1.isLoading, emailError = _1.error;
103
103
  var hideTt = useRef();
104
104
  /*
105
105
  * Extrai e normaliza os tipos de documento presentes em ctx.document, retornando sempre um array de strings em minúsculo.
@@ -118,7 +118,6 @@ var Liminar = function (_a) {
118
118
  var _a, _b, _c, _d;
119
119
  var carouselName = (_c = (_b = (_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : '';
120
120
  var empresas = (_d = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _d === void 0 ? void 0 : _d.empresa;
121
- var nomeNormTokens = normalizeNameStrong(carouselName);
122
121
  if (!Array.isArray(empresas))
123
122
  return [];
124
123
  return empresas.filter(function (proc) {
@@ -143,7 +142,7 @@ var Liminar = function (_a) {
143
142
  /*
144
143
  * Identifica as origens de liminares detectadas e verifica se existe liminar de protesto invertida
145
144
  */
146
- var _w = useMemo(function () {
145
+ var _2 = useMemo(function () {
147
146
  var _a, _b;
148
147
  var labels = new Set();
149
148
  var indiciosApi = ((_a = ctx.document) === null || _a === void 0 ? void 0 : _a.indiciosDeLiminar) === true;
@@ -179,7 +178,7 @@ var Liminar = function (_a) {
179
178
  tiposDocumento,
180
179
  processosComAssuntoValido,
181
180
  (_f = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _f === void 0 ? void 0 : _f.indiciosDeLiminarProtestosDoPassado
182
- ]), origensDetectadas = _w.origensDetectadas, foundBusinessEntity = _w.foundBusinessEntity;
181
+ ]), origensDetectadas = _2.origensDetectadas, foundBusinessEntity = _2.foundBusinessEntity;
183
182
  var protestosIsReady = useMemo(function () { var _a; return (_a = globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) === null || _a === void 0 ? void 0 : _a.isLoaded; }, [globalData]);
184
183
  useEffect(function () {
185
184
  if (!protestosIsReady)
@@ -233,7 +232,15 @@ var Liminar = function (_a) {
233
232
  .join(', '))
234
233
  : 'Não encontrado';
235
234
  setData(function (prev) { return (__assign(__assign({}, prev), { liminar: {
236
- indiciosDeLiminar: indiciosApi || indiciosDeLiminarProtestosDoPassado,
235
+ /* -------------------------------------------------------------
236
+ * Há 3 fontes possíveis de indício de liminar:
237
+ * 1) API (Cenprot/Serasa) ‑ indiciosApi
238
+ * 2) Liminar detectada por protestos passados ‑ indiciosDeLiminarProtestosDoPassado
239
+ * 3) Processos Judiciais com assuntos compatíveis ‑ processosComAssuntoValido
240
+ * ----------------------------------------------------------- */
241
+ indiciosDeLiminar: indiciosApi ||
242
+ indiciosDeLiminarProtestosDoPassado ||
243
+ processosComAssuntoValido.length > 0,
237
244
  message: finalStatus,
238
245
  isLoaded: true,
239
246
  processosComLiminarIds: processosComAssuntoValido.map(function (p) { return p.id; }),
@@ -266,6 +273,55 @@ var Liminar = function (_a) {
266
273
  !isLoadingLiminarProtestosDoPassado &&
267
274
  ctx.type !== RequestStatus.Loading;
268
275
  var ctxLoading = useMemo(function () { return (__assign(__assign({}, ctx), { type: RequestStatus.Loading })); }, [ctx]);
276
+ /* ------------------------------------------------------------------
277
+ * ⬇️ PREPARA E PERSISTE o histórico (INSERT INTO 'LIMINAR'.'INTERFACE')
278
+ *
279
+ * A regra agora é:
280
+ * • Apenas adicionamos um “type” se ELE foi, de fato, a fonte que
281
+ * marcou `indicioDeLiminar = true`.
282
+ * ------------------------------------------------------------------*/
283
+ var typesForHistory = useMemo(function () {
284
+ var _a, _b, _c, _d;
285
+ var set = new Set();
286
+ /* 1) API (Cenprot/Serasa) */
287
+ var apiIndicio = ((_a = ctx.document) === null || _a === void 0 ? void 0 : _a.indiciosDeLiminar) === true;
288
+ if (apiIndicio) {
289
+ (Array.isArray((_b = ctx.document) === null || _b === void 0 ? void 0 : _b.type)
290
+ ? ctx.document.type
291
+ : [(_c = ctx.document) === null || _c === void 0 ? void 0 : _c.type])
292
+ .filter(Boolean)
293
+ .forEach(function (t) { return set.add(String(t).toLowerCase()); });
294
+ }
295
+ /* 2) Cenprot – detectado por protestos desaparecidos */
296
+ if ((_d = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _d === void 0 ? void 0 : _d.indiciosDeLiminarProtestosDoPassado) {
297
+ set.add('cenprot');
298
+ }
299
+ /* 3) Judicial */
300
+ if (processosComAssuntoValido.length > 0) {
301
+ set.add('judicial');
302
+ }
303
+ return Array.from(set);
304
+ }, [
305
+ ctx.document,
306
+ (_j = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _j === void 0 ? void 0 : _j.indiciosDeLiminarProtestosDoPassado,
307
+ processosComAssuntoValido
308
+ ]);
309
+ var protestKeysForHistory = useMemo(function () {
310
+ var _a;
311
+ return (((_a = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _a === void 0 ? void 0 : _a.protestosDoPassadoIds) || '')
312
+ .split(',')
313
+ .filter(Boolean);
314
+ }, [(_k = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _k === void 0 ? void 0 : _k.protestosDoPassadoIds]);
315
+ var processIdsForHistory = useMemo(function () { return processosComAssuntoValido.map(function (p) { return p.id; }); }, [processosComAssuntoValido]);
316
+ // 🔔 grava o histórico assim que todos os dados necessários existirem
317
+ useLiminarHistory({
318
+ documento: ((_m = (_l = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _l === void 0 ? void 0 : _l.carousel) === null || _m === void 0 ? void 0 : _m.document) || '',
319
+ indicioDeLiminar: (_p = (_o = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _o === void 0 ? void 0 : _o.indiciosDeLiminar) !== null && _p !== void 0 ? _p : false,
320
+ types: typesForHistory,
321
+ protestKeys: protestKeysForHistory,
322
+ processIds: processIdsForHistory,
323
+ enabled: ready
324
+ });
269
325
  var scrollToProcesso = function (id) {
270
326
  var el = document.getElementById(id);
271
327
  if (!el)
@@ -282,8 +338,8 @@ var Liminar = function (_a) {
282
338
  : 'Processos com indícios encontrados:';
283
339
  var shouldRender = isLoadingLiminarProtestosDoPassado ||
284
340
  (ready &&
285
- (((_j = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _j === void 0 ? void 0 : _j.indiciosDeLiminar) ||
286
- ((_m = (_l = (_k = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _k === void 0 ? void 0 : _k.processosComLiminarIds) === null || _l === void 0 ? void 0 : _l.length) !== null && _m !== void 0 ? _m : 0) > 0));
341
+ (((_q = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _q === void 0 ? void 0 : _q.indiciosDeLiminar) ||
342
+ ((_t = (_s = (_r = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _r === void 0 ? void 0 : _r.processosComLiminarIds) === null || _s === void 0 ? void 0 : _s.length) !== null && _t !== void 0 ? _t : 0) > 0));
287
343
  // Função para disparar o envio do e-mail e configurar a mensagem do modal
288
344
  var handleSendEmailIndicios = function (e) { return __awaiter(void 0, void 0, void 0, function () {
289
345
  var callback;
@@ -311,7 +367,8 @@ var Liminar = function (_a) {
311
367
  }
312
368
  else {
313
369
  setEmailModalMessage(React.createElement(React.Fragment, null,
314
- "Os detalhes dos protestos ocultados foram enviados para seu e-mail. ",
370
+ "Os detalhes dos protestos ocultados foram enviados para seu e-mail.",
371
+ ' ',
315
372
  React.createElement("br", null),
316
373
  "R$ 50 foram debitados automaticamente do seu saldo para essa opera\u00E7\u00E3o."));
317
374
  }
@@ -371,7 +428,12 @@ var Liminar = function (_a) {
371
428
  setIsEmailModalOpen(false);
372
429
  setEmailModalMessage('');
373
430
  }, title: "Protestos ocultos enviados por e-mail" },
374
- React.createElement("div", { style: { textAlign: 'center', display: 'block', fontSize: 18, fontWeight: 400 } }, emailModalMessage),
431
+ React.createElement("div", { style: {
432
+ textAlign: 'center',
433
+ display: 'block',
434
+ fontSize: 18,
435
+ fontWeight: 400
436
+ } }, emailModalMessage),
375
437
  React.createElement("div", { style: { textAlign: 'center', marginTop: '16px' } },
376
438
  React.createElement(Button, { onClick: function () {
377
439
  setIsEmailModalOpen(false);
@@ -0,0 +1,9 @@
1
+ export interface LiminarHistoryParams {
2
+ documento: string;
3
+ indicioDeLiminar: boolean;
4
+ types: string[];
5
+ protestKeys?: string[];
6
+ processIds?: string[];
7
+ enabled?: boolean;
8
+ }
9
+ export declare function useLiminarHistory({ documento, indicioDeLiminar, types, protestKeys, processIds, enabled }: LiminarHistoryParams): void;
@@ -0,0 +1,49 @@
1
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
+ if (ar || !(i in from)) {
4
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
+ ar[i] = from[i];
6
+ }
7
+ }
8
+ return to.concat(ar || Array.prototype.slice.call(from));
9
+ };
10
+ import { useEffect, useRef } from 'react';
11
+ import { useFetch } from '../webservice';
12
+ export function useLiminarHistory(_a) {
13
+ var documento = _a.documento, indicioDeLiminar = _a.indicioDeLiminar, types = _a.types, _b = _a.protestKeys, protestKeys = _b === void 0 ? [] : _b, _c = _a.processIds, processIds = _c === void 0 ? [] : _c, _d = _a.enabled, enabled = _d === void 0 ? true : _d;
14
+ var insertHistory = useFetch("INSERT INTO 'LIMINAR'.'INTERFACE'").fetch;
15
+ var lastFingerprint = useRef();
16
+ useEffect(function () {
17
+ if (!enabled || !documento)
18
+ return;
19
+ var effectiveTypes = indicioDeLiminar ? types : [];
20
+ var fingerprint = JSON.stringify({
21
+ documento: documento,
22
+ indicioDeLiminar: indicioDeLiminar,
23
+ types: __spreadArray([], effectiveTypes, true).sort(),
24
+ protestKeys: protestKeys,
25
+ processIds: processIds
26
+ });
27
+ if (fingerprint === lastFingerprint.current)
28
+ return;
29
+ var payload = {
30
+ documento: documento,
31
+ indicioDeLiminar: indicioDeLiminar ? 'true' : 'false',
32
+ types: JSON.stringify(effectiveTypes)
33
+ };
34
+ if (protestKeys.length)
35
+ payload.protestKeys = JSON.stringify(protestKeys);
36
+ if (processIds.length)
37
+ payload.processIds = JSON.stringify(processIds);
38
+ insertHistory(payload);
39
+ lastFingerprint.current = fingerprint;
40
+ // eslint-disable-next-line react-hooks/exhaustive-deps
41
+ }, [
42
+ documento,
43
+ indicioDeLiminar,
44
+ types.join(','),
45
+ protestKeys.join(','),
46
+ processIds.join(','),
47
+ enabled
48
+ ]);
49
+ }