@credithub/harlan-components 1.116.4 → 1.117.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.
@@ -132,7 +132,7 @@ var ConsultaSimplesSection = function (_a) {
132
132
  : 'Processos Jurídicos')
133
133
  : '', (_o = data.processosJuridicosData) === null || _o === void 0 ? void 0 : _o.error),
134
134
  makeItem('Liminar', (_p = data.liminar) === null || _p === void 0 ? void 0 : _p.isLoaded, ((_q = data.liminar) === null || _q === void 0 ? void 0 : _q.message) === 'Encontrado'
135
- ? '' //'Indício de Liminar'
135
+ ? 'Indício de Liminar'
136
136
  : '', (_r = data.liminar) === null || _r === void 0 ? void 0 : _r.error),
137
137
  makeItem('Potenciais Protestos Entrantes', true, ((_s = data.editalData) === null || _s === void 0 ? void 0 : _s.recentesCount)
138
138
  ? "".concat(data.editalData.recentesCount === 1 ? '1 Potencial Protesto Entrante' : "".concat(data.editalData.recentesCount, " Potenciais Protestos Entrantes"))
@@ -45,15 +45,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
47
  };
48
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
49
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
50
- if (ar || !(i in from)) {
51
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
52
- ar[i] = from[i];
53
- }
54
- }
55
- return to.concat(ar || Array.prototype.slice.call(from));
56
- };
57
48
  /* eslint-disable react-hooks/exhaustive-deps */
58
49
  import ProtestosIcon from '../../assets/icones/protestos';
59
50
  import { useGlobalData } from '../../contexts/globalDataContext';
@@ -93,6 +84,114 @@ var businessTypes = [
93
84
  'banco',
94
85
  'cooperativa'
95
86
  ];
87
+ /* ----------------------------------
88
+ * Funções Puras de Detecção
89
+ * ---------------------------------*/
90
+ /**
91
+ * Detecta liminar via API (Cenprot/Serasa)
92
+ */
93
+ function detectLiminarFromApi(ctxDocument, tiposDocumento) {
94
+ var indiciosApi = (ctxDocument === null || ctxDocument === void 0 ? void 0 : ctxDocument.indiciosDeLiminar) === true;
95
+ var origens = [];
96
+ if (indiciosApi) {
97
+ tiposDocumento.forEach(function (t) {
98
+ var m = {
99
+ cenprot: 'Liminar no Cenprot',
100
+ serasa: 'Liminar no Serasa',
101
+ judicial: 'Liminar no Judiciário'
102
+ };
103
+ if (m[t])
104
+ origens.push(m[t]);
105
+ });
106
+ }
107
+ return {
108
+ isActive: indiciosApi,
109
+ origem: origens.length > 0 ? origens : '',
110
+ contribuiParaIndicio: indiciosApi,
111
+ metadata: {
112
+ tiposDocumento: indiciosApi ? tiposDocumento : undefined
113
+ }
114
+ };
115
+ }
116
+ /**
117
+ * Detecta liminar via processos judiciais com assuntos válidos
118
+ */
119
+ function detectLiminarFromProcessosJudiciais(processosComAssuntoValido) {
120
+ var hasProcessos = processosComAssuntoValido.length > 0;
121
+ return {
122
+ isActive: hasProcessos,
123
+ origem: hasProcessos ? 'Liminar no Judiciário' : '',
124
+ contribuiParaIndicio: hasProcessos,
125
+ metadata: {
126
+ processosIds: hasProcessos
127
+ ? processosComAssuntoValido.map(function (p) { return p.id; })
128
+ : undefined
129
+ }
130
+ };
131
+ }
132
+ /**
133
+ * Detecta liminar via protestos do passado (sistema legado)
134
+ *
135
+ * NOTA: Esta fonte está temporariamente desabilitada devido a problemas
136
+ * no sistema legado que geravam falsos positivos. O fetch ainda é executado
137
+ * para manter histórico, mas a fonte não contribui para os cálculos principais.
138
+ *
139
+ * Para reativar: remova o early return abaixo.
140
+ */
141
+ function detectLiminarFromProtestosDoPassado(possuiIndicios, protestosIds) {
142
+ // Early return: sistema legado desabilitado temporariamente
143
+ // TODO: Reativar quando o sistema legado for corrigido/validado
144
+ return {
145
+ isActive: false,
146
+ origem: '',
147
+ contribuiParaIndicio: false,
148
+ metadata: {
149
+ protestosDoPassadoIds: possuiIndicios ? protestosIds.join(',') : undefined
150
+ }
151
+ };
152
+ // Código original (mantido para referência futura):
153
+ // return {
154
+ // isActive: possuiIndicios,
155
+ // origem: possuiIndicios ? 'Liminar no Cenprot' : '',
156
+ // contribuiParaIndicio: possuiIndicios,
157
+ // metadata: {
158
+ // protestosDoPassadoIds: possuiIndicios ? protestosIds.join(',') : undefined
159
+ // }
160
+ // };
161
+ }
162
+ /**
163
+ * Agrega múltiplas fontes de liminar em um resultado combinado
164
+ */
165
+ function combineLiminarSources(sources) {
166
+ var _a, _b, _c;
167
+ var activeSources = sources.filter(function (s) { return s.isActive && s.contribuiParaIndicio; });
168
+ var origensArray = activeSources
169
+ .map(function (s) { return (Array.isArray(s.origem) ? s.origem : [s.origem]); })
170
+ .flat()
171
+ .filter(Boolean);
172
+ var origens = Array.from(new Set(origensArray));
173
+ var indiciosDeLiminar = activeSources.length > 0;
174
+ var descricaoLiminar = origens.length
175
+ ? "Liminar encontrada ".concat(origens
176
+ .map(function (o) { return o.replace(/^Liminar (no|na) /, 'no '); })
177
+ .join(', '))
178
+ : 'Não encontrado';
179
+ var processosComLiminarIds = ((_b = (_a = sources
180
+ .find(function (s) { var _a; return (_a = s.metadata) === null || _a === void 0 ? void 0 : _a.processosIds; })) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.processosIds) || [];
181
+ var sourceProtestos = sources.find(function (s) { var _a; return (_a = s.metadata) === null || _a === void 0 ? void 0 : _a.protestosDoPassadoIds; });
182
+ var indiciosDeLiminarProtestosDoPassado = (sourceProtestos === null || sourceProtestos === void 0 ? void 0 : sourceProtestos.isActive) && (sourceProtestos === null || sourceProtestos === void 0 ? void 0 : sourceProtestos.contribuiParaIndicio)
183
+ ? true
184
+ : false;
185
+ var protestosDoPassadoIds = ((_c = sourceProtestos === null || sourceProtestos === void 0 ? void 0 : sourceProtestos.metadata) === null || _c === void 0 ? void 0 : _c.protestosDoPassadoIds) || '';
186
+ return {
187
+ indiciosDeLiminar: indiciosDeLiminar,
188
+ origens: origens,
189
+ descricaoLiminar: descricaoLiminar,
190
+ processosComLiminarIds: processosComLiminarIds,
191
+ indiciosDeLiminarProtestosDoPassado: indiciosDeLiminarProtestosDoPassado,
192
+ protestosDoPassadoIds: protestosDoPassadoIds
193
+ };
194
+ }
96
195
  var Liminar = function (_a) {
97
196
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
98
197
  var _t = _a.isFinancial, isFinancial = _t === void 0 ? false : _t, hasCredits = _a.hasCredits, _u = _a.tags, tags = _u === void 0 ? [] : _u;
@@ -152,25 +251,21 @@ var Liminar = function (_a) {
152
251
  */
153
252
  var _0 = useMemo(function () {
154
253
  var _a, _b;
155
- var labels = new Set();
156
- var indiciosApi = ((_a = ctx.document) === null || _a === void 0 ? void 0 : _a.indiciosDeLiminar) === true;
157
- if (indiciosApi) {
158
- tiposDocumento.forEach(function (t) {
159
- var m = {
160
- cenprot: 'Liminar no Cenprot',
161
- serasa: 'Liminar no Serasa',
162
- judicial: 'Liminar no Judiciário'
163
- };
164
- if (m[t])
165
- labels.add(m[t]);
166
- });
167
- }
168
- if ((_b = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _b === void 0 ? void 0 : _b.indiciosDeLiminarProtestosDoPassado) {
169
- labels.add('Liminar no Cenprot');
170
- }
171
- if (processosComAssuntoValido.length) {
172
- labels.add('Liminar no Judiciário');
173
- }
254
+ // Detecta liminar via API
255
+ var sourceApi = detectLiminarFromApi(ctx.document, tiposDocumento);
256
+ // Detecta liminar via processos judiciais
257
+ var sourceProcessos = detectLiminarFromProcessosJudiciais(processosComAssuntoValido);
258
+ // Detecta liminar via protestos do passado (desabilitado)
259
+ var sourceProtestos = ((_a = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _a === void 0 ? void 0 : _a.indiciosDeLiminarProtestosDoPassado)
260
+ ? detectLiminarFromProtestosDoPassado(true, (((_b = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _b === void 0 ? void 0 : _b.protestosDoPassadoIds) || '').split(','))
261
+ : detectLiminarFromProtestosDoPassado(false, []);
262
+ // Combina as fontes
263
+ var combined = combineLiminarSources([
264
+ sourceApi,
265
+ sourceProcessos,
266
+ sourceProtestos
267
+ ]);
268
+ // Verifica se há entidade de negócio nos processos
174
269
  var pj = processosComAssuntoValido.some(function (p) {
175
270
  var _a;
176
271
  return (_a = p.envolvidos_ultima_movimentacao) === null || _a === void 0 ? void 0 : _a.some(function (e) {
@@ -180,22 +275,26 @@ var Liminar = function (_a) {
180
275
  return businessTypes.some(function (t) { return n.includes(t); });
181
276
  });
182
277
  });
183
- return { origensDetectadas: Array.from(labels), foundBusinessEntity: pj };
278
+ return {
279
+ origensDetectadas: combined.origens,
280
+ foundBusinessEntity: pj
281
+ };
184
282
  }, [
185
283
  ctx.document,
186
284
  tiposDocumento,
187
285
  processosComAssuntoValido,
188
- (_f = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _f === void 0 ? void 0 : _f.indiciosDeLiminarProtestosDoPassado
286
+ (_f = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _f === void 0 ? void 0 : _f.indiciosDeLiminarProtestosDoPassado,
287
+ (_g = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _g === void 0 ? void 0 : _g.protestosDoPassadoIds
189
288
  ]), origensDetectadas = _0.origensDetectadas, foundBusinessEntity = _0.foundBusinessEntity;
190
- 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); }, [(_g = globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) === null || _g === void 0 ? void 0 : _g.isLoaded]);
289
+ 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); }, [(_h = globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) === null || _h === void 0 ? void 0 : _h.isLoaded]);
191
290
  useEffect(function () {
192
291
  if (!protestosIsReady)
193
292
  return;
194
293
  var fetch = function () { return __awaiter(void 0, void 0, void 0, function () {
195
- var dossie, processosJuridicos, depsLoaded, newIds, hash, indiciosApi, indiciosDeLiminarProtestosDoPassado, protestosDoPassadoIds, _a, possuiIndiciosDeLiminarProtestosDoPassado, protestosIds, origens, finalStatus, descricaoLiminar;
196
- var _b, _c;
197
- return __generator(this, function (_d) {
198
- switch (_d.label) {
294
+ var dossie, processosJuridicos, depsLoaded, newIds, hash, sourceApi, sourceProcessos, _a, possuiIndiciosDeLiminarProtestosDoPassado, protestosIds, sourceProtestos, combined, finalStatus;
295
+ var _b;
296
+ return __generator(this, function (_c) {
297
+ switch (_c.label) {
199
298
  case 0:
200
299
  dossie = globalData === null || globalData === void 0 ? void 0 : globalData.dossie;
201
300
  processosJuridicos = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData;
@@ -214,52 +313,40 @@ var Liminar = function (_a) {
214
313
  if (hash === dataHashRef.current)
215
314
  return [2 /*return*/];
216
315
  dataHashRef.current = hash;
217
- indiciosApi = ((_c = ctx.document) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminar) === true;
218
- indiciosDeLiminarProtestosDoPassado = false;
219
- protestosDoPassadoIds = '';
316
+ sourceApi = detectLiminarFromApi(ctx.document, tiposDocumento);
317
+ sourceProcessos = detectLiminarFromProcessosJudiciais(processosComAssuntoValido);
318
+ // Busca dados de protestos do passado (fetch ainda executa para histórico)
220
319
  setIsLoadingLiminarProtestosDoPassado(true);
221
320
  return [4 /*yield*/, fetchLiminarProtestosDoPassado()];
222
321
  case 1:
223
- _a = _d.sent(), possuiIndiciosDeLiminarProtestosDoPassado = _a.possuiIndiciosDeLiminarProtestosDoPassado, protestosIds = _a.protestosDoPassadoIds;
224
- origens = __spreadArray([], origensDetectadas, true);
225
- if (possuiIndiciosDeLiminarProtestosDoPassado) {
226
- if (!origens.includes('Liminar no Cenprot')) {
227
- origens.push('Liminar no Cenprot');
228
- }
229
- indiciosDeLiminarProtestosDoPassado =
230
- possuiIndiciosDeLiminarProtestosDoPassado;
231
- protestosDoPassadoIds = protestosIds.join(',');
232
- }
322
+ _a = _c.sent(), possuiIndiciosDeLiminarProtestosDoPassado = _a.possuiIndiciosDeLiminarProtestosDoPassado, protestosIds = _a.protestosDoPassadoIds;
233
323
  setIsLoadingLiminarProtestosDoPassado(false);
234
- finalStatus = indiciosApi ||
235
- processosComAssuntoValido.length ||
236
- indiciosDeLiminarProtestosDoPassado
324
+ sourceProtestos = detectLiminarFromProtestosDoPassado(possuiIndiciosDeLiminarProtestosDoPassado, protestosIds);
325
+ combined = combineLiminarSources([
326
+ sourceApi,
327
+ sourceProcessos,
328
+ sourceProtestos
329
+ ]);
330
+ invertedIdsRef.current = newIds;
331
+ finalStatus = combined.indiciosDeLiminar
237
332
  ? 'Encontrado'
238
333
  : 'Não encontrado';
239
- invertedIdsRef.current = newIds;
240
- descricaoLiminar = (origens.length
241
- ? "Liminar encontrada ".concat(origens
242
- .map(function (o) { return o.replace(/^Liminar (no|na) /, 'no '); })
243
- .join(', '))
244
- : 'Não encontrado');
245
334
  setData(function (prev) { return (__assign(__assign({}, prev), { liminar: {
246
335
  /* -------------------------------------------------------------
247
336
  * Há 3 fontes possíveis de indício de liminar:
248
- * 1) API (Cenprot/Serasa) ‑ indiciosApi
249
- * 2) Liminar detectada por protestos passados ‑ indiciosDeLiminarProtestosDoPassado
250
- * 3) Processos Judiciais com assuntos compatíveis ‑ processosComAssuntoValido
337
+ * 1) API (Cenprot/Serasa) ‑ sourceApi
338
+ * 2) Liminar detectada por protestos passados ‑ sourceProtestos (desabilitado)
339
+ * 3) Processos Judiciais com assuntos compatíveis ‑ sourceProcessos
251
340
  * ----------------------------------------------------------- */
252
- indiciosDeLiminar: indiciosApi ||
253
- indiciosDeLiminarProtestosDoPassado ||
254
- processosComAssuntoValido.length > 0,
341
+ indiciosDeLiminar: combined.indiciosDeLiminar,
255
342
  message: finalStatus,
256
343
  isLoaded: true,
257
- processosComLiminarIds: processosComAssuntoValido.map(function (p) { return p.id; }),
258
- indiciosDeLiminarProtestosDoPassado: indiciosDeLiminarProtestosDoPassado,
259
- protestosDoPassadoIds: protestosDoPassadoIds,
344
+ processosComLiminarIds: combined.processosComLiminarIds,
345
+ indiciosDeLiminarProtestosDoPassado: combined.indiciosDeLiminarProtestosDoPassado,
346
+ protestosDoPassadoIds: combined.protestosDoPassadoIds,
260
347
  invertedProcessos: newIds,
261
- origensLiminar: origens,
262
- descricaoLiminar: descricaoLiminar
348
+ origensLiminar: combined.origens,
349
+ descricaoLiminar: combined.descricaoLiminar
263
350
  } })); });
264
351
  processedRef.current = true;
265
352
  return [2 /*return*/];
@@ -301,8 +388,8 @@ var Liminar = function (_a) {
301
388
  protestosIsReady
302
389
  ]);
303
390
  var ready = processedRef.current &&
304
- !!((_h = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _h === void 0 ? void 0 : _h.isLoaded) &&
305
- !!((_j = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _j === void 0 ? void 0 : _j.carousel) &&
391
+ !!((_j = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _j === void 0 ? void 0 : _j.isLoaded) &&
392
+ !!((_k = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _k === void 0 ? void 0 : _k.carousel) &&
306
393
  !isLoadingLiminarProtestosDoPassado &&
307
394
  ctx.type !== RequestStatus.Loading;
308
395
  var ctxLoading = useMemo(function () { return (__assign(__assign({}, ctx), { type: RequestStatus.Loading })); }, [ctx]);
@@ -314,7 +401,7 @@ var Liminar = function (_a) {
314
401
  * marcou `indicioDeLiminar = true`.
315
402
  * ------------------------------------------------------------------*/
316
403
  var typesForHistory = useMemo(function () {
317
- var _a, _b, _c, _d;
404
+ var _a, _b, _c;
318
405
  var set = new Set();
319
406
  /* 1) API (Cenprot/Serasa) */
320
407
  var apiIndicio = ((_a = ctx.document) === null || _a === void 0 ? void 0 : _a.indiciosDeLiminar) === true;
@@ -326,9 +413,9 @@ var Liminar = function (_a) {
326
413
  .forEach(function (t) { return set.add(String(t).toLowerCase()); });
327
414
  }
328
415
  /* 2) Cenprot – detectado por protestos desaparecidos */
329
- if ((_d = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _d === void 0 ? void 0 : _d.indiciosDeLiminarProtestosDoPassado) {
330
- set.add('cenprot');
331
- }
416
+ /*if (globalData?.liminar?.indiciosDeLiminarProtestosDoPassado) {
417
+ set.add('cenprot');
418
+ }*/
332
419
  /* 3) Judicial */
333
420
  if (processosComAssuntoValido.length > 0) {
334
421
  set.add('judicial');
@@ -336,7 +423,7 @@ var Liminar = function (_a) {
336
423
  return Array.from(set);
337
424
  }, [
338
425
  ctx.document,
339
- (_k = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _k === void 0 ? void 0 : _k.indiciosDeLiminarProtestosDoPassado,
426
+ tiposDocumento,
340
427
  processosComAssuntoValido
341
428
  ]);
342
429
  // Se existem tipos que de fato contribuíram para o indício,
@@ -432,7 +519,6 @@ var Liminar = function (_a) {
432
519
  return [2 /*return*/];
433
520
  });
434
521
  }); };
435
- return null;
436
522
  if (!isFinancial || !shouldRender)
437
523
  return null;
438
524
  return (React.createElement(React.Fragment, null,
@@ -34,7 +34,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
34
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
35
  }
36
36
  };
37
- import { parseBpqlResponse } from '../../utils/bpqlResponse';
37
+ import { parseBpqlResponse } from '../../../utils/bpqlResponse';
38
38
  export function sendInstrumentoManualEmail(client, payload) {
39
39
  return __awaiter(this, void 0, void 0, function () {
40
40
  var response, parsed;
@@ -34,8 +34,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
34
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
35
  }
36
36
  };
37
- import { sendInstrumentoDiscoveryEmail, sendInstrumentoManualEmail } from '../../../adapters/instrumentoProtesto/ieptbInstrumento';
38
37
  import { useCallback, useState } from 'react';
38
+ import { sendInstrumentoDiscoveryEmail, sendInstrumentoManualEmail } from './ieptbInstrumento';
39
39
  /**
40
40
  * Hook para gerenciar o fluxo de instrumento de protesto (fase mockada)
41
41
  *