@credithub/harlan-components 1.84.0 → 1.84.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.
- package/dist/components/liminar/liminar.d.ts +1 -1
- package/dist/components/liminar/liminar.js +10 -9
- package/dist/components/liminar/useLiminarProtestosDoPassado.js +17 -32
- package/lib/cjs/index.js +12228 -112
- package/lib/esm/index.js +12228 -112
- package/package.json +3 -1
|
@@ -54,7 +54,7 @@ import { formatMoney } from '../../utils/number';
|
|
|
54
54
|
import { normalizeName, normalizeNameStrong, similarCompanyNames } from '../../utils/similarNames';
|
|
55
55
|
import { hasOneOfTags } from '../../utils/tags';
|
|
56
56
|
import { WarningCircle } from 'phosphor-react';
|
|
57
|
-
import
|
|
57
|
+
import { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
58
58
|
import Button from '../common/button';
|
|
59
59
|
import Modal from '../common/modal';
|
|
60
60
|
import { SummaryButton } from '../dossie/summary/styles';
|
|
@@ -63,6 +63,7 @@ import Section from '../section';
|
|
|
63
63
|
import { Queries, RequestStatus, useFetch } from '../webservice';
|
|
64
64
|
import { TitleWithTooltip, TooltipContainer, TooltipText } from './liminarStyles';
|
|
65
65
|
import useLiminarProtestosDoPassado from './useLiminarProtestosDoPassado';
|
|
66
|
+
import React from 'react';
|
|
66
67
|
/* ----------------------------------
|
|
67
68
|
* Constantes
|
|
68
69
|
* ---------------------------------*/
|
|
@@ -98,10 +99,7 @@ var Liminar = function (_a) {
|
|
|
98
99
|
var _s = useState(false), isTooltipVisible = _s[0], setTooltipVisible = _s[1];
|
|
99
100
|
var _t = useState(false), isEmailModalOpen = _t[0], setIsEmailModalOpen = _t[1];
|
|
100
101
|
var _u = useState(''), emailModalMessage = _u[0], setEmailModalMessage = _u[1];
|
|
101
|
-
var liminarMailPrice =
|
|
102
|
-
var isDiamanteNew = hasOneOfTags(tags, ['diamante-new']);
|
|
103
|
-
return isDiamanteNew ? 0 : 50000;
|
|
104
|
-
}, [tags]);
|
|
102
|
+
var liminarMailPrice = 50000;
|
|
105
103
|
var _v = useFetch("SELECT FROM 'LIMINAR'.'SENDMAIL'"), sendIndiciosEmail = _v.fetch, isEmailSending = _v.isLoading, emailError = _v.error;
|
|
106
104
|
var hideTt = useRef();
|
|
107
105
|
/*
|
|
@@ -315,7 +313,10 @@ var Liminar = function (_a) {
|
|
|
315
313
|
setEmailModalMessage("Falha ao enviar e-mail: ".concat(emailError.message));
|
|
316
314
|
}
|
|
317
315
|
else {
|
|
318
|
-
setEmailModalMessage(
|
|
316
|
+
setEmailModalMessage(React.createElement(React.Fragment, null,
|
|
317
|
+
"Os detalhes dos protestos ocultados foram enviados para seu e-mail. ",
|
|
318
|
+
React.createElement("br", null),
|
|
319
|
+
"R$ 50 foram debitados automaticamente do seu saldo para essa opera\u00E7\u00E3o."));
|
|
319
320
|
}
|
|
320
321
|
setIsEmailModalOpen(true);
|
|
321
322
|
return [2 /*return*/];
|
|
@@ -363,7 +364,7 @@ var Liminar = function (_a) {
|
|
|
363
364
|
actions: (React.createElement("div", { style: { textAlign: 'center' }, onClick: function (e) { return e.stopPropagation(); } }, isFinancial &&
|
|
364
365
|
((_c = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminarProtestosDoPassado) &&
|
|
365
366
|
/** mostra o botão apenas se existir ao menos 1 chave oculta */
|
|
366
|
-
((_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:
|
|
367
|
+
((_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: !isEmailSending
|
|
367
368
|
? formatMoney(liminarMailPrice / 1000)
|
|
368
369
|
: '' }, "Baixar Protestos Ocultos"))))
|
|
369
370
|
};
|
|
@@ -372,8 +373,8 @@ var Liminar = function (_a) {
|
|
|
372
373
|
React.createElement(Modal, { isOpen: isEmailModalOpen, onClose: function () {
|
|
373
374
|
setIsEmailModalOpen(false);
|
|
374
375
|
setEmailModalMessage('');
|
|
375
|
-
}, title: "
|
|
376
|
-
React.createElement("
|
|
376
|
+
}, title: "Protestos ocultos enviados por e-mail" },
|
|
377
|
+
React.createElement("div", { style: { textAlign: 'center', display: 'block', fontSize: 18, fontWeight: 400 } }, emailModalMessage),
|
|
377
378
|
React.createElement("div", { style: { textAlign: 'center', marginTop: '16px' } },
|
|
378
379
|
React.createElement(Button, { onClick: function () {
|
|
379
380
|
setIsEmailModalOpen(false);
|
|
@@ -34,11 +34,13 @@ 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 { eachLimit } from 'async';
|
|
37
38
|
import XPathUtils from '../../utils/xpath';
|
|
38
39
|
import { Client } from '@credithub/webservice';
|
|
39
40
|
import { useCallback, useContext } from 'react';
|
|
40
41
|
import { WebService } from '../webservice';
|
|
41
42
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
43
|
+
import { difference, uniq } from 'lodash';
|
|
42
44
|
/**
|
|
43
45
|
* Hook que identifica indícios de liminar de sustação de protesto.
|
|
44
46
|
*
|
|
@@ -50,6 +52,7 @@ import { useGlobalData } from '../../contexts/globalDataContext';
|
|
|
50
52
|
* timeout defensivo para cada requisição.
|
|
51
53
|
*/
|
|
52
54
|
var useLiminarProtestosDoPassado = function (_a) {
|
|
55
|
+
var _b;
|
|
53
56
|
var documento = _a.documento;
|
|
54
57
|
var client = useContext(WebService);
|
|
55
58
|
var globalData = useGlobalData().data;
|
|
@@ -87,22 +90,21 @@ var useLiminarProtestosDoPassado = function (_a) {
|
|
|
87
90
|
});
|
|
88
91
|
}); };
|
|
89
92
|
var fetch = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
|
-
var data, parsed, nodes, numerosChave, ocultos,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
var data, parsed, nodes, numerosChave, ocultos, launch;
|
|
94
|
+
var _a;
|
|
95
|
+
return __generator(this, function (_b) {
|
|
96
|
+
switch (_b.label) {
|
|
93
97
|
case 0: return [4 /*yield*/, client.request("SELECT FROM 'IEPTB'.'PASTQUERIES'", {
|
|
94
98
|
documento: documento
|
|
95
99
|
})];
|
|
96
100
|
case 1:
|
|
97
|
-
data =
|
|
101
|
+
data = _b.sent();
|
|
98
102
|
return [4 /*yield*/, Client.WebService.parse(data)];
|
|
99
103
|
case 2:
|
|
100
|
-
parsed = (
|
|
104
|
+
parsed = (_b.sent());
|
|
101
105
|
nodes = XPathUtils.selectArray('//protesto/nm_chave', parsed);
|
|
102
|
-
numerosChave =
|
|
106
|
+
numerosChave = difference(uniq(nodes.map(function (n) { return n.textContent || ''; })), ((_a = globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) === null || _a === void 0 ? void 0 : _a.nmChaves) || []);
|
|
103
107
|
ocultos = [];
|
|
104
|
-
idx = 0;
|
|
105
|
-
running = [];
|
|
106
108
|
launch = function (chave) { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
109
|
return __generator(this, function (_a) {
|
|
108
110
|
switch (_a.label) {
|
|
@@ -114,33 +116,16 @@ var useLiminarProtestosDoPassado = function (_a) {
|
|
|
114
116
|
}
|
|
115
117
|
});
|
|
116
118
|
}); };
|
|
117
|
-
|
|
119
|
+
return [4 /*yield*/, eachLimit(numerosChave, MAX_CONCURRENT, launch)];
|
|
118
120
|
case 3:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
running.splice(i, 1);
|
|
125
|
-
});
|
|
126
|
-
running.push(p);
|
|
127
|
-
};
|
|
128
|
-
while (idx < numerosChave.length && running.length < MAX_CONCURRENT) {
|
|
129
|
-
_loop_1();
|
|
130
|
-
}
|
|
131
|
-
if (!running.length) return [3 /*break*/, 5];
|
|
132
|
-
return [4 /*yield*/, Promise.race(running)];
|
|
133
|
-
case 4:
|
|
134
|
-
_a.sent();
|
|
135
|
-
_a.label = 5;
|
|
136
|
-
case 5: return [3 /*break*/, 3];
|
|
137
|
-
case 6: return [2 /*return*/, {
|
|
138
|
-
possuiIndiciosDeLiminarProtestosDoPassado: ocultos.length > 0,
|
|
139
|
-
protestosDoPassadoIds: ocultos
|
|
140
|
-
}];
|
|
121
|
+
_b.sent();
|
|
122
|
+
return [2 /*return*/, {
|
|
123
|
+
possuiIndiciosDeLiminarProtestosDoPassado: ocultos.length > 0,
|
|
124
|
+
protestosDoPassadoIds: ocultos
|
|
125
|
+
}];
|
|
141
126
|
}
|
|
142
127
|
});
|
|
143
|
-
}); }, [client, documento]);
|
|
128
|
+
}); }, [client, documento, (_b = globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) === null || _b === void 0 ? void 0 : _b.nmChaves]);
|
|
144
129
|
return { fetchLiminarProtestosDoPassado: fetch };
|
|
145
130
|
};
|
|
146
131
|
export default useLiminarProtestosDoPassado;
|