@credithub/harlan-components 1.81.6 → 1.81.7
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.
|
@@ -49,19 +49,19 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
49
|
import ProtestosIcon from '../../assets/icones/protestos';
|
|
50
50
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
51
51
|
import theme from '../../styles/theme';
|
|
52
|
+
import { formatMoney } from '../../utils/number';
|
|
52
53
|
import { normalizeName, similarNames } from '../../utils/similarNames';
|
|
54
|
+
import { hasOneOfTags } from '../../utils/tags';
|
|
53
55
|
import { WarningCircle } from 'phosphor-react';
|
|
54
56
|
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
55
57
|
import Button from '../common/button';
|
|
56
58
|
import Modal from '../common/modal';
|
|
59
|
+
import { SummaryButton } from '../dossie/summary/styles';
|
|
57
60
|
import StatusMessage from '../interface/statusMessage';
|
|
58
61
|
import Section from '../section';
|
|
59
62
|
import { Queries, RequestStatus, useFetch } from '../webservice';
|
|
60
63
|
import { TitleWithTooltip, TooltipContainer, TooltipText } from './liminarStyles';
|
|
61
64
|
import useLiminarProtestosDoPassado from './useLiminarProtestosDoPassado';
|
|
62
|
-
import { hasOneOfTags } from '../../utils/tags';
|
|
63
|
-
import { SummaryButton } from '../dossie/summary/styles';
|
|
64
|
-
import { formatMoney } from '../../utils/number';
|
|
65
65
|
/* ----------------------------------
|
|
66
66
|
* Constantes
|
|
67
67
|
* ---------------------------------*/
|
|
@@ -343,7 +343,7 @@ var Liminar = function (_a) {
|
|
|
343
343
|
color: '#007aff'
|
|
344
344
|
} }, p.id)); }))))))), subtitle: "Ind\u00EDcios de liminares para oculta\u00E7\u00E3o de registros.", icon: ProtestosIcon, ctx: ready ? ctx : ctxLoading, onSuccess: ready
|
|
345
345
|
? function (_data, _context) {
|
|
346
|
-
var _a, _b, _c, _d;
|
|
346
|
+
var _a, _b, _c, _d, _e, _f;
|
|
347
347
|
var msg = (_b = (_a = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'Não encontrado';
|
|
348
348
|
var variant = msg === 'Encontrado' ? 'error' : 'default';
|
|
349
349
|
return {
|
|
@@ -354,7 +354,10 @@ var Liminar = function (_a) {
|
|
|
354
354
|
origensDetectadas.map(function (o) { return (React.createElement(StatusMessage, { key: o, type: variant }, o)); }))),
|
|
355
355
|
actions: (React.createElement("div", { style: { textAlign: 'center' }, onClick: function (e) { return e.stopPropagation(); } }, isFinancial &&
|
|
356
356
|
((_c = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminarProtestosDoPassado) &&
|
|
357
|
-
|
|
357
|
+
/** mostra o botão apenas se existir ao menos 1 chave oculta */
|
|
358
|
+
((_f = (_e = (_d = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _d === void 0 ? void 0 : _d.protestosDoPassadoIds) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0) > 0 && (React.createElement(SummaryButton, { onClick: handleSendEmailIndicios, disabled: isEmailSending, smallContent: liminarMailPrice && !isEmailSending
|
|
359
|
+
? formatMoney(liminarMailPrice / 1000)
|
|
360
|
+
: '' }, "Baixar Protestos Ocultos"))))
|
|
358
361
|
};
|
|
359
362
|
}
|
|
360
363
|
: undefined }),
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
interface LiminarProtestosDoPassadoProps {
|
|
2
|
+
/** CNPJ/CPF analisado para detectar instrumentos de protesto que sumiram do CENPROT */
|
|
2
3
|
documento: string;
|
|
3
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* Hook que identifica indícios de liminar de sustação de protesto.
|
|
7
|
+
*
|
|
8
|
+
* Regras (2025‑07‑01)
|
|
9
|
+
* • Um instrumento é **oculto** se a consulta a `PDFPROTESTO.PDF` **não** retornar PDF.
|
|
10
|
+
* • Se todos ainda possuem PDF, não há indício de liminar.
|
|
11
|
+
*
|
|
12
|
+
* Esta versão limita a concorrência (10 chamadas em paralelo) e aplica
|
|
13
|
+
* timeout defensivo para cada requisição.
|
|
14
|
+
*/
|
|
4
15
|
declare const useLiminarProtestosDoPassado: ({ documento }: LiminarProtestosDoPassadoProps) => {
|
|
5
|
-
fetchLiminarProtestosDoPassado: () => Promise<{
|
|
6
|
-
possuiIndiciosDeLiminarProtestosDoPassado: boolean;
|
|
7
|
-
protestosDoPassadoIds: string[];
|
|
16
|
+
readonly fetchLiminarProtestosDoPassado: () => Promise<{
|
|
17
|
+
readonly possuiIndiciosDeLiminarProtestosDoPassado: boolean;
|
|
18
|
+
readonly protestosDoPassadoIds: string[];
|
|
8
19
|
}>;
|
|
9
20
|
};
|
|
10
21
|
export default useLiminarProtestosDoPassado;
|
|
@@ -38,55 +38,54 @@ import XPathUtils from '../../utils/xpath';
|
|
|
38
38
|
import { Client } from '@credithub/webservice';
|
|
39
39
|
import { useCallback, useContext } from 'react';
|
|
40
40
|
import { WebService } from '../webservice';
|
|
41
|
+
/**
|
|
42
|
+
* Hook que identifica indícios de liminar de sustação de protesto.
|
|
43
|
+
*
|
|
44
|
+
* Regras (2025‑07‑01)
|
|
45
|
+
* • Um instrumento é **oculto** se a consulta a `PDFPROTESTO.PDF` **não** retornar PDF.
|
|
46
|
+
* • Se todos ainda possuem PDF, não há indício de liminar.
|
|
47
|
+
*
|
|
48
|
+
* Esta versão limita a concorrência (10 chamadas em paralelo) e aplica
|
|
49
|
+
* timeout defensivo para cada requisição.
|
|
50
|
+
*/
|
|
41
51
|
var useLiminarProtestosDoPassado = function (_a) {
|
|
42
52
|
var documento = _a.documento;
|
|
43
53
|
var client = useContext(WebService);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
/** Máximo de requisições simultâneas ao endpoint de PDF. */
|
|
55
|
+
var MAX_CONCURRENT = 10;
|
|
56
|
+
/** Timeout (ms) por requisição individual ao PDF. */
|
|
57
|
+
var PDF_TIMEOUT = 8000;
|
|
58
|
+
/**
|
|
59
|
+
* Checa se um `nm_chave` ainda possui PDF no CENPROT.
|
|
60
|
+
* Retorna `true` quando há PDF, `false` caso contrário ou erro.
|
|
61
|
+
*/
|
|
62
|
+
var possuiPdf = function (nm_chave) { return __awaiter(void 0, void 0, void 0, function () {
|
|
63
|
+
var ctrl, timer, response, _a;
|
|
64
|
+
return __generator(this, function (_b) {
|
|
65
|
+
switch (_b.label) {
|
|
48
66
|
case 0:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
switch (_b.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
_b.trys.push([0, 3, , 4]);
|
|
55
|
-
return [4 /*yield*/, client.request("SELECT FROM 'PDFPROTESTO'.'PDF'", {
|
|
56
|
-
nm_chave: numeroChave,
|
|
57
|
-
documento: documento
|
|
58
|
-
})];
|
|
59
|
-
case 1:
|
|
60
|
-
response = _b.sent();
|
|
61
|
-
return [4 /*yield*/, response.json()];
|
|
62
|
-
case 2: return [2 /*return*/, !!(_b.sent())];
|
|
63
|
-
case 3:
|
|
64
|
-
_a = _b.sent();
|
|
65
|
-
return [2 /*return*/, false];
|
|
66
|
-
case 4: return [2 /*return*/];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}); };
|
|
70
|
-
i = 0;
|
|
71
|
-
_a.label = 1;
|
|
67
|
+
ctrl = new AbortController();
|
|
68
|
+
timer = setTimeout(function () { return ctrl.abort(); }, PDF_TIMEOUT);
|
|
69
|
+
_b.label = 1;
|
|
72
70
|
case 1:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return [4 /*yield*/, Promise.all(chunk.map(getNumeroChave))];
|
|
71
|
+
_b.trys.push([1, 4, 5, 6]);
|
|
72
|
+
return [4 /*yield*/, client.request("SELECT FROM 'PDFPROTESTO'.'PDF'", { nm_chave: nm_chave, documento: documento }, undefined, ctrl.signal)];
|
|
76
73
|
case 2:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
response = _b.sent();
|
|
75
|
+
return [4 /*yield*/, response.json()];
|
|
76
|
+
case 3: return [2 /*return*/, !!(_b.sent())];
|
|
77
|
+
case 4:
|
|
78
|
+
_a = _b.sent();
|
|
79
|
+
return [2 /*return*/, false]; // considera oculto se erro ou timeout
|
|
80
|
+
case 5:
|
|
81
|
+
clearTimeout(timer);
|
|
82
|
+
return [7 /*endfinally*/];
|
|
83
|
+
case 6: return [2 /*return*/];
|
|
85
84
|
}
|
|
86
85
|
});
|
|
87
86
|
}); };
|
|
88
87
|
var fetch = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
89
|
-
var data, parsed, nodes, numerosChave,
|
|
88
|
+
var data, parsed, nodes, numerosChave, ocultos, idx, running, launch, _loop_1;
|
|
90
89
|
return __generator(this, function (_a) {
|
|
91
90
|
switch (_a.label) {
|
|
92
91
|
case 0: return [4 /*yield*/, client.request("SELECT FROM 'IEPTB'.'PASTQUERIES'", {
|
|
@@ -98,17 +97,48 @@ var useLiminarProtestosDoPassado = function (_a) {
|
|
|
98
97
|
case 2:
|
|
99
98
|
parsed = (_a.sent());
|
|
100
99
|
nodes = XPathUtils.selectArray('//protesto/nm_chave', parsed);
|
|
101
|
-
numerosChave = Array.from(new Set(nodes.map(function (
|
|
102
|
-
|
|
100
|
+
numerosChave = Array.from(new Set(nodes.map(function (n) { return n.textContent || ''; })));
|
|
101
|
+
ocultos = [];
|
|
102
|
+
idx = 0;
|
|
103
|
+
running = [];
|
|
104
|
+
launch = function (chave) { return __awaiter(void 0, void 0, void 0, function () {
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
switch (_a.label) {
|
|
107
|
+
case 0: return [4 /*yield*/, possuiPdf(chave)];
|
|
108
|
+
case 1:
|
|
109
|
+
if (!(_a.sent()))
|
|
110
|
+
ocultos.push(chave);
|
|
111
|
+
return [2 /*return*/];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}); };
|
|
115
|
+
_a.label = 3;
|
|
103
116
|
case 3:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
117
|
+
if (!(idx < numerosChave.length || running.length)) return [3 /*break*/, 6];
|
|
118
|
+
_loop_1 = function () {
|
|
119
|
+
var p = launch(numerosChave[idx++]).finally(function () {
|
|
120
|
+
var i = running.indexOf(p);
|
|
121
|
+
if (i >= 0)
|
|
122
|
+
running.splice(i, 1);
|
|
123
|
+
});
|
|
124
|
+
running.push(p);
|
|
125
|
+
};
|
|
126
|
+
while (idx < numerosChave.length && running.length < MAX_CONCURRENT) {
|
|
127
|
+
_loop_1();
|
|
128
|
+
}
|
|
129
|
+
if (!running.length) return [3 /*break*/, 5];
|
|
130
|
+
return [4 /*yield*/, Promise.race(running)];
|
|
131
|
+
case 4:
|
|
132
|
+
_a.sent();
|
|
133
|
+
_a.label = 5;
|
|
134
|
+
case 5: return [3 /*break*/, 3];
|
|
135
|
+
case 6: return [2 /*return*/, {
|
|
136
|
+
possuiIndiciosDeLiminarProtestosDoPassado: ocultos.length > 0,
|
|
137
|
+
protestosDoPassadoIds: ocultos
|
|
138
|
+
}];
|
|
109
139
|
}
|
|
110
140
|
});
|
|
111
|
-
}); }, [documento]);
|
|
141
|
+
}); }, [client, documento]);
|
|
112
142
|
return { fetchLiminarProtestosDoPassado: fetch };
|
|
113
143
|
};
|
|
114
144
|
export default useLiminarProtestosDoPassado;
|