@credithub/harlan-components 1.74.0 → 1.75.1
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.
|
@@ -52,9 +52,11 @@ import theme from '../../styles/theme';
|
|
|
52
52
|
import { normalizeName, similarNames } from '../../utils/similarNames';
|
|
53
53
|
import { WarningCircle } from 'phosphor-react';
|
|
54
54
|
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
55
|
+
import Button from '../common/button';
|
|
56
|
+
import Modal from '../common/modal';
|
|
55
57
|
import StatusMessage from '../interface/statusMessage';
|
|
56
58
|
import Section from '../section';
|
|
57
|
-
import { Queries, RequestStatus } from '../webservice';
|
|
59
|
+
import { Queries, RequestStatus, useFetch } from '../webservice';
|
|
58
60
|
import { TitleWithTooltip, TooltipContainer, TooltipText } from './liminarStyles';
|
|
59
61
|
import useLiminarProtestosDoPassado from './useLiminarProtestosDoPassado';
|
|
60
62
|
/* ----------------------------------
|
|
@@ -89,6 +91,9 @@ var Liminar = function () {
|
|
|
89
91
|
var dataHashRef = useRef('');
|
|
90
92
|
var invertedIdsRef = useRef([]);
|
|
91
93
|
var _p = useState(false), isTooltipVisible = _p[0], setTooltipVisible = _p[1];
|
|
94
|
+
var _q = useState(false), isEmailModalOpen = _q[0], setIsEmailModalOpen = _q[1];
|
|
95
|
+
var _r = useState(''), emailModalMessage = _r[0], setEmailModalMessage = _r[1];
|
|
96
|
+
var _s = useFetch("SELECT FROM 'LIMINAR'.'SENDMAIL'"), sendIndiciosEmail = _s.fetch, isEmailSending = _s.isLoading, emailError = _s.error;
|
|
92
97
|
var hideTt = useRef();
|
|
93
98
|
/*
|
|
94
99
|
* Extrai e normaliza os tipos de documento presentes em ctx.document, retornando sempre um array de strings em minúsculo.
|
|
@@ -132,7 +137,7 @@ var Liminar = function () {
|
|
|
132
137
|
/*
|
|
133
138
|
* Identifica as origens de liminares detectadas e verifica se existe liminar de protesto invertida
|
|
134
139
|
*/
|
|
135
|
-
var
|
|
140
|
+
var _t = useMemo(function () {
|
|
136
141
|
var _a, _b;
|
|
137
142
|
var labels = new Set();
|
|
138
143
|
var indiciosApi = ((_a = ctx.document) === null || _a === void 0 ? void 0 : _a.indiciosDeLiminar) === true;
|
|
@@ -168,13 +173,13 @@ var Liminar = function () {
|
|
|
168
173
|
tiposDocumento,
|
|
169
174
|
processosComAssuntoValido,
|
|
170
175
|
(_e = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _e === void 0 ? void 0 : _e.indiciosDeLiminarProtestosDoPassado
|
|
171
|
-
]), origensDetectadas =
|
|
176
|
+
]), origensDetectadas = _t.origensDetectadas, foundBusinessEntity = _t.foundBusinessEntity;
|
|
172
177
|
useEffect(function () {
|
|
173
178
|
var fetch = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
174
|
-
var dossie, processosJuridicos, depsLoaded, newIds, hash, indiciosApi, indiciosDeLiminarProtestosDoPassado, finalStatus;
|
|
175
|
-
var
|
|
176
|
-
return __generator(this, function (
|
|
177
|
-
switch (
|
|
179
|
+
var dossie, processosJuridicos, depsLoaded, newIds, hash, indiciosApi, indiciosDeLiminarProtestosDoPassado, protestosDoPassadoIds, _a, possuiIndiciosDeLiminarProtestosDoPassado, protestosIds, finalStatus;
|
|
180
|
+
var _b, _c, _d;
|
|
181
|
+
return __generator(this, function (_e) {
|
|
182
|
+
switch (_e.label) {
|
|
178
183
|
case 0:
|
|
179
184
|
dossie = globalData === null || globalData === void 0 ? void 0 : globalData.dossie;
|
|
180
185
|
processosJuridicos = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData;
|
|
@@ -186,27 +191,32 @@ var Liminar = function () {
|
|
|
186
191
|
: [];
|
|
187
192
|
hash = JSON.stringify({
|
|
188
193
|
t: ctx.type,
|
|
189
|
-
indicios: (
|
|
194
|
+
indicios: (_b = ctx.document) === null || _b === void 0 ? void 0 : _b.indiciosDeLiminar,
|
|
190
195
|
carousel: dossie.carousel,
|
|
191
196
|
empresas: processosJuridicos.empresa
|
|
192
197
|
});
|
|
193
198
|
if (hash === dataHashRef.current)
|
|
194
199
|
return [2 /*return*/];
|
|
195
200
|
dataHashRef.current = hash;
|
|
196
|
-
indiciosApi = ((
|
|
201
|
+
indiciosApi = ((_c = ctx.document) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminar) === true;
|
|
197
202
|
indiciosDeLiminarProtestosDoPassado = false;
|
|
203
|
+
protestosDoPassadoIds = '';
|
|
198
204
|
if (!(!indiciosApi &&
|
|
199
205
|
!processosComAssuntoValido.length &&
|
|
200
|
-
((
|
|
206
|
+
((_d = globalData === null || globalData === void 0 ? void 0 : globalData.documentHistory) === null || _d === void 0 ? void 0 : _d.protestoLiminar))) return [3 /*break*/, 2];
|
|
201
207
|
setIsLoadingLiminarProtestosDoPassado(true);
|
|
202
208
|
return [4 /*yield*/, fetchLiminarProtestosDoPassado()];
|
|
203
209
|
case 1:
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (
|
|
210
|
+
_a = _e.sent(), possuiIndiciosDeLiminarProtestosDoPassado = _a.possuiIndiciosDeLiminarProtestosDoPassado, protestosIds = _a.protestosDoPassadoIds;
|
|
211
|
+
console.log('possuiIndiciosDeLiminarProtestosDoPassado', possuiIndiciosDeLiminarProtestosDoPassado);
|
|
212
|
+
if (possuiIndiciosDeLiminarProtestosDoPassado) {
|
|
207
213
|
origensDetectadas.push('Liminar no Cenprot');
|
|
214
|
+
indiciosDeLiminarProtestosDoPassado =
|
|
215
|
+
possuiIndiciosDeLiminarProtestosDoPassado;
|
|
216
|
+
protestosDoPassadoIds = protestosIds.join(',');
|
|
217
|
+
}
|
|
208
218
|
setIsLoadingLiminarProtestosDoPassado(false);
|
|
209
|
-
|
|
219
|
+
_e.label = 2;
|
|
210
220
|
case 2:
|
|
211
221
|
finalStatus = indiciosApi ||
|
|
212
222
|
processosComAssuntoValido.length ||
|
|
@@ -220,6 +230,7 @@ var Liminar = function () {
|
|
|
220
230
|
isLoaded: true,
|
|
221
231
|
processosComLiminarIds: processosComAssuntoValido.map(function (p) { return p.id; }),
|
|
222
232
|
indiciosDeLiminarProtestosDoPassado: indiciosDeLiminarProtestosDoPassado,
|
|
233
|
+
protestosDoPassadoIds: protestosDoPassadoIds,
|
|
223
234
|
invertedProcessos: newIds
|
|
224
235
|
} })); });
|
|
225
236
|
processedRef.current = true;
|
|
@@ -261,38 +272,76 @@ var Liminar = function () {
|
|
|
261
272
|
(ready &&
|
|
262
273
|
(((_h = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _h === void 0 ? void 0 : _h.indiciosDeLiminar) ||
|
|
263
274
|
((_l = (_k = (_j = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _j === void 0 ? void 0 : _j.processosComLiminarIds) === null || _k === void 0 ? void 0 : _k.length) !== null && _l !== void 0 ? _l : 0) > 0));
|
|
275
|
+
// Função para disparar o envio do e-mail e configurar a mensagem do modal
|
|
276
|
+
var handleSendEmailIndicios = function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
277
|
+
var documento, ids;
|
|
278
|
+
var _a, _b, _c;
|
|
279
|
+
return __generator(this, function (_d) {
|
|
280
|
+
switch (_d.label) {
|
|
281
|
+
case 0:
|
|
282
|
+
e.preventDefault();
|
|
283
|
+
e.stopPropagation();
|
|
284
|
+
documento = ((_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.document) || '';
|
|
285
|
+
ids = ((_c = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _c === void 0 ? void 0 : _c.protestosDoPassadoIds) || '';
|
|
286
|
+
return [4 /*yield*/, sendIndiciosEmail({ documento: documento, nm_chave: ids })];
|
|
287
|
+
case 1:
|
|
288
|
+
_d.sent();
|
|
289
|
+
if (emailError) {
|
|
290
|
+
setEmailModalMessage("Falha ao enviar e-mail: ".concat(emailError.message));
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
setEmailModalMessage('Você deve ter recebido um e-mail nosso com os detalhes que encontramos sobre esse indício.');
|
|
294
|
+
}
|
|
295
|
+
setIsEmailModalOpen(true);
|
|
296
|
+
return [2 /*return*/];
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}); };
|
|
264
300
|
if (!shouldRender)
|
|
265
301
|
return null;
|
|
266
|
-
return (React.createElement(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
React.createElement(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
React.createElement(
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
302
|
+
return (React.createElement(React.Fragment, null,
|
|
303
|
+
React.createElement(Section, { title: React.createElement(TitleWithTooltip, null,
|
|
304
|
+
"Liminares para Remo\u00E7\u00E3o de Protesto",
|
|
305
|
+
!!processosComAssuntoValido.length && ready && (React.createElement(TooltipContainer, { onMouseEnter: function () {
|
|
306
|
+
clearTimeout(hideTt.current);
|
|
307
|
+
setTooltipVisible(true);
|
|
308
|
+
}, onMouseLeave: function () {
|
|
309
|
+
hideTt.current = setTimeout(function () { return setTooltipVisible(false); }, 300);
|
|
310
|
+
} },
|
|
311
|
+
renderTooltipIcon(),
|
|
312
|
+
React.createElement(TooltipText, { visible: isTooltipVisible },
|
|
313
|
+
React.createElement(React.Fragment, null,
|
|
314
|
+
tooltipMessage,
|
|
315
|
+
React.createElement("ul", { style: { marginTop: 6, paddingLeft: 18 } }, processosComAssuntoValido.map(function (p) { return (React.createElement("li", { key: p.id, onClick: function () { return scrollToProcesso(p.id); }, style: {
|
|
316
|
+
fontSize: 13,
|
|
317
|
+
cursor: 'pointer',
|
|
318
|
+
textDecoration: 'underline',
|
|
319
|
+
color: '#007aff'
|
|
320
|
+
} }, p.id)); }))))))), subtitle: "Ind\u00EDcios de liminares para oculta\u00E7\u00E3o de registros.", icon: ProtestosIcon, ctx: ready ? ctx : ctxLoading, onSuccess: ready
|
|
321
|
+
? function (_data, _context) {
|
|
322
|
+
var _a, _b, _c, _d;
|
|
323
|
+
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';
|
|
324
|
+
var variant = msg === 'Encontrado' ? 'error' : 'default';
|
|
325
|
+
return {
|
|
326
|
+
children: React.createElement(React.Fragment, null),
|
|
327
|
+
variant: variant,
|
|
328
|
+
description: (React.createElement(React.Fragment, null,
|
|
329
|
+
React.createElement(StatusMessage, { type: variant }, msg),
|
|
330
|
+
origensDetectadas.map(function (o) { return (React.createElement(StatusMessage, { key: o, type: variant }, o)); }))),
|
|
331
|
+
actions: (React.createElement("div", { style: { textAlign: 'center' }, onClick: function (e) { return e.stopPropagation(); } }, ((_c = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminarProtestosDoPassado) &&
|
|
332
|
+
((_d = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _d === void 0 ? void 0 : _d.protestosDoPassadoIds) && (React.createElement(Button, { onClick: handleSendEmailIndicios }, "Enviar Ind\u00EDcios por Email"))))
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
: undefined }),
|
|
336
|
+
React.createElement(Modal, { isOpen: isEmailModalOpen, onClose: function () {
|
|
337
|
+
setIsEmailModalOpen(false);
|
|
338
|
+
setEmailModalMessage('');
|
|
339
|
+
}, title: "Detalhes enviados por e-mail" },
|
|
340
|
+
React.createElement("p", null, emailModalMessage),
|
|
341
|
+
React.createElement("div", { style: { textAlign: 'center', marginTop: '16px' } },
|
|
342
|
+
React.createElement(Button, { onClick: function () {
|
|
343
|
+
setIsEmailModalOpen(false);
|
|
344
|
+
setEmailModalMessage('');
|
|
345
|
+
} }, "Fechar")))));
|
|
297
346
|
};
|
|
298
347
|
export default Liminar;
|
|
@@ -2,6 +2,9 @@ interface LiminarProtestosDoPassadoProps {
|
|
|
2
2
|
documento: string;
|
|
3
3
|
}
|
|
4
4
|
declare const useLiminarProtestosDoPassado: ({ documento }: LiminarProtestosDoPassadoProps) => {
|
|
5
|
-
fetchLiminarProtestosDoPassado: () => Promise<
|
|
5
|
+
fetchLiminarProtestosDoPassado: () => Promise<{
|
|
6
|
+
possuiIndiciosDeLiminarProtestosDoPassado: boolean;
|
|
7
|
+
protestosDoPassadoIds: string[];
|
|
8
|
+
}>;
|
|
6
9
|
};
|
|
7
10
|
export default useLiminarProtestosDoPassado;
|
|
@@ -83,7 +83,7 @@ var useLiminarProtestosDoPassado = function (_a) {
|
|
|
83
83
|
});
|
|
84
84
|
}); };
|
|
85
85
|
var fetch = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
86
|
-
var data, parsed, nodes, numerosChave;
|
|
86
|
+
var data, parsed, nodes, numerosChave, possuiIndiciosDeLiminarProtestosDoPassado;
|
|
87
87
|
return __generator(this, function (_a) {
|
|
88
88
|
switch (_a.label) {
|
|
89
89
|
case 0: return [4 /*yield*/, client.request("SELECT FROM 'IEPTB'.'PASTQUERIES'", {
|
|
@@ -96,7 +96,13 @@ var useLiminarProtestosDoPassado = function (_a) {
|
|
|
96
96
|
parsed = _a.sent();
|
|
97
97
|
nodes = XPathUtils.selectArray('//protesto/nm_chave', parsed);
|
|
98
98
|
numerosChave = Array.from(new Set(nodes.map(function (node) { return node.textContent || ''; })));
|
|
99
|
-
return [
|
|
99
|
+
return [4 /*yield*/, getAlgumInstrumentoPossuiPDF(numerosChave)];
|
|
100
|
+
case 3:
|
|
101
|
+
possuiIndiciosDeLiminarProtestosDoPassado = _a.sent();
|
|
102
|
+
return [2 /*return*/, {
|
|
103
|
+
possuiIndiciosDeLiminarProtestosDoPassado: possuiIndiciosDeLiminarProtestosDoPassado,
|
|
104
|
+
protestosDoPassadoIds: numerosChave
|
|
105
|
+
}];
|
|
100
106
|
}
|
|
101
107
|
});
|
|
102
108
|
}); }, [documento]);
|