@credithub/harlan-components 1.97.6 → 1.97.8

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,3 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  var __rest = (this && this.__rest) || function (s, e) {
2
13
  var t = {};
3
14
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -102,17 +113,24 @@ export var selectRelevantData = function (data) {
102
113
  // ────────────────────────────────────────────────
103
114
  var _r = ResumoDosDados !== null && ResumoDosDados !== void 0 ? ResumoDosDados : {}, _omit = _r.protestoLiminar, ResumoSafe = __rest(_r, ["protestoLiminar"]);
104
115
  var protestosData = [];
116
+ var ultimaOcorrenciaProtestos = ResumoSafe === null || ResumoSafe === void 0 ? void 0 : ResumoSafe.ultimaOcorrenciaProtestos;
105
117
  if (Array.isArray(ResumoSafe === null || ResumoSafe === void 0 ? void 0 : ResumoSafe.protestoHistory) &&
106
118
  ResumoSafe.protestoHistory.length) {
107
119
  var latest = __spreadArray([], ResumoSafe.protestoHistory, true).sort(function (a, b) { return new Date(b.data).getTime() - new Date(a.data).getTime(); })[0];
108
- protestosData = [latest];
120
+ var latestWithCorrectDate = ultimaOcorrenciaProtestos
121
+ ? __assign(__assign({}, latest), { data: ultimaOcorrenciaProtestos }) : latest;
122
+ protestosData = [latestWithCorrectDate];
109
123
  // 💡 mantém histórico enxuto também em ResumoSafe
110
- ResumoSafe.protestoHistory = [latest];
124
+ ResumoSafe.protestoHistory = [latestWithCorrectDate];
111
125
  }
112
126
  if (!protestosData.length &&
113
127
  typeof protestosNumero === 'number' &&
114
128
  protestosNumero > 0) {
115
- protestosData = [{ quantidade: protestosNumero }];
129
+ protestosData = [
130
+ ultimaOcorrenciaProtestos
131
+ ? { quantidade: protestosNumero, data: ultimaOcorrenciaProtestos }
132
+ : { quantidade: protestosNumero }
133
+ ];
116
134
  }
117
135
  // ────────────────────────────────────────────────
118
136
  // 2. Processos jurídicos – ativos + passivos
@@ -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, _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;
87
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
88
+ var _s = _a.isFinancial, isFinancial = _s === void 0 ? false : _s, hasCredits = _a.hasCredits, _t = _a.tags, tags = _t === void 0 ? [] : _t;
89
89
  var ctx = useContext(Queries.LiminarCenprot);
90
- var _w = useGlobalData(), globalData = _w.data, setData = _w.setData;
90
+ var _u = useGlobalData(), globalData = _u.data, setData = _u.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 _x = useState(false), isLoadingLiminarProtestosDoPassado = _x[0], setIsLoadingLiminarProtestosDoPassado = _x[1];
94
+ var _v = useState(false), isLoadingLiminarProtestosDoPassado = _v[0], setIsLoadingLiminarProtestosDoPassado = _v[1];
95
95
  var processedRef = useRef(false);
96
96
  var dataHashRef = useRef('');
97
97
  var invertedIdsRef = useRef([]);
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];
98
+ var _w = useState(false), isTooltipVisible = _w[0], setTooltipVisible = _w[1];
99
+ var _x = useState(false), isEmailModalOpen = _x[0], setIsEmailModalOpen = _x[1];
100
+ var _y = useState(''), emailModalMessage = _y[0], setEmailModalMessage = _y[1];
101
101
  var liminarMailPrice = 50000;
102
- var _1 = useFetch("SELECT FROM 'LIMINAR'.'SENDMAIL'"), sendIndiciosEmail = _1.fetch, isEmailSending = _1.isLoading, emailError = _1.error;
102
+ var _z = useFetch("SELECT FROM 'LIMINAR'.'SENDMAIL'"), sendIndiciosEmail = _z.fetch, isEmailSending = _z.isLoading, emailError = _z.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.
@@ -142,7 +142,7 @@ var Liminar = function (_a) {
142
142
  /*
143
143
  * Identifica as origens de liminares detectadas e verifica se existe liminar de protesto invertida
144
144
  */
145
- var _2 = useMemo(function () {
145
+ var _0 = useMemo(function () {
146
146
  var _a, _b;
147
147
  var labels = new Set();
148
148
  var indiciosApi = ((_a = ctx.document) === null || _a === void 0 ? void 0 : _a.indiciosDeLiminar) === true;
@@ -178,7 +178,7 @@ var Liminar = function (_a) {
178
178
  tiposDocumento,
179
179
  processosComAssuntoValido,
180
180
  (_f = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _f === void 0 ? void 0 : _f.indiciosDeLiminarProtestosDoPassado
181
- ]), origensDetectadas = _2.origensDetectadas, foundBusinessEntity = _2.foundBusinessEntity;
181
+ ]), origensDetectadas = _0.origensDetectadas, foundBusinessEntity = _0.foundBusinessEntity;
182
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]);
183
183
  useEffect(function () {
184
184
  if (!protestosIsReady)
@@ -306,6 +306,10 @@ var Liminar = function (_a) {
306
306
  (_j = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _j === void 0 ? void 0 : _j.indiciosDeLiminarProtestosDoPassado,
307
307
  processosComAssuntoValido
308
308
  ]);
309
+ console.log('typesForHistory', typesForHistory);
310
+ // Se existem tipos que de fato contribuíram para o indício,
311
+ // então o indício é verdadeiro para fins de histórico.
312
+ var indicioDeLiminarForHistory = typesForHistory.length > 0;
309
313
  var protestKeysForHistory = useMemo(function () {
310
314
  var _a;
311
315
  return (((_a = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _a === void 0 ? void 0 : _a.protestosDoPassadoIds) || '')
@@ -316,7 +320,9 @@ var Liminar = function (_a) {
316
320
  // 🔔 grava o histórico assim que todos os dados necessários existirem
317
321
  useLiminarHistory({
318
322
  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,
323
+ // Garantimos que o histórico registra "true" quando houve fonte real,
324
+ // evitando falso-positivos vindos do estado agregado da UI.
325
+ indicioDeLiminar: indicioDeLiminarForHistory,
320
326
  types: typesForHistory,
321
327
  protestKeys: protestKeysForHistory,
322
328
  processIds: processIdsForHistory,
@@ -338,8 +344,8 @@ var Liminar = function (_a) {
338
344
  : 'Processos com indícios encontrados:';
339
345
  var shouldRender = isLoadingLiminarProtestosDoPassado ||
340
346
  (ready &&
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));
347
+ (((_o = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _o === void 0 ? void 0 : _o.indiciosDeLiminar) ||
348
+ ((_r = (_q = (_p = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _p === void 0 ? void 0 : _p.processosComLiminarIds) === null || _q === void 0 ? void 0 : _q.length) !== null && _r !== void 0 ? _r : 0) > 0));
343
349
  // Função para disparar o envio do e-mail e configurar a mensagem do modal
344
350
  var handleSendEmailIndicios = function (e) { return __awaiter(void 0, void 0, void 0, function () {
345
351
  var callback;
@@ -16,8 +16,6 @@ export function useLiminarHistory(_a) {
16
16
  useEffect(function () {
17
17
  if (!enabled || !documento)
18
18
  return;
19
- if (!indicioDeLiminar)
20
- return;
21
19
  var effectiveTypes = indicioDeLiminar ? types : [];
22
20
  var fingerprint = JSON.stringify({
23
21
  documento: documento,
@@ -37,6 +35,7 @@ export function useLiminarHistory(_a) {
37
35
  payload.protestKeys = JSON.stringify(protestKeys);
38
36
  if (processIds.length)
39
37
  payload.processIds = JSON.stringify(processIds);
38
+ console.log('payload', payload);
40
39
  insertHistory(payload);
41
40
  lastFingerprint.current = fingerprint;
42
41
  // eslint-disable-next-line react-hooks/exhaustive-deps