@credithub/harlan-components 1.90.0 → 1.91.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/dossie/generativeAi/generativeAi.js +1 -6
- package/dist/components/liminar/liminar.d.ts +1 -1
- package/dist/components/liminar/liminar.js +81 -19
- package/dist/components/liminar/useLiminarHistory.d.ts +9 -0
- package/dist/components/liminar/useLiminarHistory.js +49 -0
- package/lib/cjs/index.js +161 -56
- package/lib/esm/index.js +161 -56
- package/package.json +1 -1
|
@@ -95,9 +95,6 @@ var GenerativeAI = function (_a) {
|
|
|
95
95
|
? isGlobalReady(globalData) // clientes financeiros
|
|
96
96
|
: isDocumentHistoryReady(globalData); // demais clientes
|
|
97
97
|
}, [globalData, isFinancial]);
|
|
98
|
-
/*const isGlobalDataReady = useMemo(() => {
|
|
99
|
-
return !!globalData.documentHistory; // verificação direta
|
|
100
|
-
}, [globalData]);*/
|
|
101
98
|
// Atualiza o payload serializado sempre que os dados globais mudarem
|
|
102
99
|
useEffect(function () {
|
|
103
100
|
if (globalData && documento && isGlobalDataReady) {
|
|
@@ -242,9 +239,7 @@ var GenerativeAI = function (_a) {
|
|
|
242
239
|
React.createElement(InitialMessageContent, null,
|
|
243
240
|
React.createElement("div", { className: "icon-and-text" },
|
|
244
241
|
React.createElement(Credithub, { size: 18, className: "initial-icon" }),
|
|
245
|
-
React.createElement("span", null, streamMode === 'summary' &&
|
|
246
|
-
summaryLoading &&
|
|
247
|
-
!((_c = messageHistory[0]) === null || _c === void 0 ? void 0 : _c.content) ? (React.createElement(LoadingDots, null)) : (React.createElement(ReactMarkdown, { remarkPlugins: [remarkGfm] }, ((_d = messageHistory[0]) === null || _d === void 0 ? void 0 : _d.content) || '')))),
|
|
242
|
+
React.createElement("span", null, streamMode === 'summary' && !((_c = messageHistory[0]) === null || _c === void 0 ? void 0 : _c.content) ? (React.createElement(LoadingDots, null)) : (React.createElement(ReactMarkdown, { remarkPlugins: [remarkGfm] }, ((_d = messageHistory[0]) === null || _d === void 0 ? void 0 : _d.content) || '')))),
|
|
248
243
|
React.createElement("div", { className: "additional-message" },
|
|
249
244
|
React.createElement("p", null, "Voc\u00EA pode fazer perguntas como:"),
|
|
250
245
|
React.createElement("p", { className: "blue-text" }, "\u00C9 seguro oferecer um cr\u00E9dito de R$ 15.000,00 a uma taxa de 3% em 12x?")),
|
|
@@ -50,10 +50,10 @@ import ProtestosIcon from '../../assets/icones/protestos';
|
|
|
50
50
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
51
51
|
import theme from '../../styles/theme';
|
|
52
52
|
import { formatMoney } from '../../utils/number';
|
|
53
|
-
import { normalizeName,
|
|
53
|
+
import { normalizeName, similarCompanyNames } from '../../utils/similarNames';
|
|
54
54
|
import { hasOneOfTags } from '../../utils/tags';
|
|
55
55
|
import { WarningCircle } from 'phosphor-react';
|
|
56
|
-
import { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
56
|
+
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
57
57
|
import Button from '../common/button';
|
|
58
58
|
import Modal from '../common/modal';
|
|
59
59
|
import { SummaryButton } from '../dossie/summary/styles';
|
|
@@ -61,8 +61,8 @@ import StatusMessage from '../interface/statusMessage';
|
|
|
61
61
|
import Section from '../section';
|
|
62
62
|
import { Queries, RequestStatus, useFetch } from '../webservice';
|
|
63
63
|
import { TitleWithTooltip, TooltipContainer, TooltipText } from './liminarStyles';
|
|
64
|
+
import { useLiminarHistory } from './useLiminarHistory';
|
|
64
65
|
import useLiminarProtestosDoPassado from './useLiminarProtestosDoPassado';
|
|
65
|
-
import React from 'react';
|
|
66
66
|
/* ----------------------------------
|
|
67
67
|
* Constantes
|
|
68
68
|
* ---------------------------------*/
|
|
@@ -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;
|
|
88
|
-
var
|
|
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;
|
|
89
89
|
var ctx = useContext(Queries.LiminarCenprot);
|
|
90
|
-
var
|
|
90
|
+
var _w = useGlobalData(), globalData = _w.data, setData = _w.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
|
|
94
|
+
var _x = useState(false), isLoadingLiminarProtestosDoPassado = _x[0], setIsLoadingLiminarProtestosDoPassado = _x[1];
|
|
95
95
|
var processedRef = useRef(false);
|
|
96
96
|
var dataHashRef = useRef('');
|
|
97
97
|
var invertedIdsRef = useRef([]);
|
|
98
|
-
var
|
|
99
|
-
var
|
|
100
|
-
var
|
|
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];
|
|
101
101
|
var liminarMailPrice = 50000;
|
|
102
|
-
var
|
|
102
|
+
var _1 = useFetch("SELECT FROM 'LIMINAR'.'SENDMAIL'"), sendIndiciosEmail = _1.fetch, isEmailSending = _1.isLoading, emailError = _1.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.
|
|
@@ -118,7 +118,6 @@ var Liminar = function (_a) {
|
|
|
118
118
|
var _a, _b, _c, _d;
|
|
119
119
|
var carouselName = (_c = (_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.name) !== null && _c !== void 0 ? _c : '';
|
|
120
120
|
var empresas = (_d = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _d === void 0 ? void 0 : _d.empresa;
|
|
121
|
-
var nomeNormTokens = normalizeNameStrong(carouselName);
|
|
122
121
|
if (!Array.isArray(empresas))
|
|
123
122
|
return [];
|
|
124
123
|
return empresas.filter(function (proc) {
|
|
@@ -143,7 +142,7 @@ var Liminar = function (_a) {
|
|
|
143
142
|
/*
|
|
144
143
|
* Identifica as origens de liminares detectadas e verifica se existe liminar de protesto invertida
|
|
145
144
|
*/
|
|
146
|
-
var
|
|
145
|
+
var _2 = useMemo(function () {
|
|
147
146
|
var _a, _b;
|
|
148
147
|
var labels = new Set();
|
|
149
148
|
var indiciosApi = ((_a = ctx.document) === null || _a === void 0 ? void 0 : _a.indiciosDeLiminar) === true;
|
|
@@ -179,7 +178,7 @@ var Liminar = function (_a) {
|
|
|
179
178
|
tiposDocumento,
|
|
180
179
|
processosComAssuntoValido,
|
|
181
180
|
(_f = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _f === void 0 ? void 0 : _f.indiciosDeLiminarProtestosDoPassado
|
|
182
|
-
]), origensDetectadas =
|
|
181
|
+
]), origensDetectadas = _2.origensDetectadas, foundBusinessEntity = _2.foundBusinessEntity;
|
|
183
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]);
|
|
184
183
|
useEffect(function () {
|
|
185
184
|
if (!protestosIsReady)
|
|
@@ -233,7 +232,15 @@ var Liminar = function (_a) {
|
|
|
233
232
|
.join(', '))
|
|
234
233
|
: 'Não encontrado';
|
|
235
234
|
setData(function (prev) { return (__assign(__assign({}, prev), { liminar: {
|
|
236
|
-
|
|
235
|
+
/* -------------------------------------------------------------
|
|
236
|
+
* Há 3 fontes possíveis de indício de liminar:
|
|
237
|
+
* 1) API (Cenprot/Serasa) ‑ indiciosApi
|
|
238
|
+
* 2) Liminar detectada por protestos passados ‑ indiciosDeLiminarProtestosDoPassado
|
|
239
|
+
* 3) Processos Judiciais com assuntos compatíveis ‑ processosComAssuntoValido
|
|
240
|
+
* ----------------------------------------------------------- */
|
|
241
|
+
indiciosDeLiminar: indiciosApi ||
|
|
242
|
+
indiciosDeLiminarProtestosDoPassado ||
|
|
243
|
+
processosComAssuntoValido.length > 0,
|
|
237
244
|
message: finalStatus,
|
|
238
245
|
isLoaded: true,
|
|
239
246
|
processosComLiminarIds: processosComAssuntoValido.map(function (p) { return p.id; }),
|
|
@@ -266,6 +273,55 @@ var Liminar = function (_a) {
|
|
|
266
273
|
!isLoadingLiminarProtestosDoPassado &&
|
|
267
274
|
ctx.type !== RequestStatus.Loading;
|
|
268
275
|
var ctxLoading = useMemo(function () { return (__assign(__assign({}, ctx), { type: RequestStatus.Loading })); }, [ctx]);
|
|
276
|
+
/* ------------------------------------------------------------------
|
|
277
|
+
* ⬇️ PREPARA E PERSISTE o histórico (INSERT INTO 'LIMINAR'.'INTERFACE')
|
|
278
|
+
*
|
|
279
|
+
* A regra agora é:
|
|
280
|
+
* • Apenas adicionamos um “type” se ELE foi, de fato, a fonte que
|
|
281
|
+
* marcou `indicioDeLiminar = true`.
|
|
282
|
+
* ------------------------------------------------------------------*/
|
|
283
|
+
var typesForHistory = useMemo(function () {
|
|
284
|
+
var _a, _b, _c, _d;
|
|
285
|
+
var set = new Set();
|
|
286
|
+
/* 1) API (Cenprot/Serasa) */
|
|
287
|
+
var apiIndicio = ((_a = ctx.document) === null || _a === void 0 ? void 0 : _a.indiciosDeLiminar) === true;
|
|
288
|
+
if (apiIndicio) {
|
|
289
|
+
(Array.isArray((_b = ctx.document) === null || _b === void 0 ? void 0 : _b.type)
|
|
290
|
+
? ctx.document.type
|
|
291
|
+
: [(_c = ctx.document) === null || _c === void 0 ? void 0 : _c.type])
|
|
292
|
+
.filter(Boolean)
|
|
293
|
+
.forEach(function (t) { return set.add(String(t).toLowerCase()); });
|
|
294
|
+
}
|
|
295
|
+
/* 2) Cenprot – detectado por protestos desaparecidos */
|
|
296
|
+
if ((_d = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _d === void 0 ? void 0 : _d.indiciosDeLiminarProtestosDoPassado) {
|
|
297
|
+
set.add('cenprot');
|
|
298
|
+
}
|
|
299
|
+
/* 3) Judicial */
|
|
300
|
+
if (processosComAssuntoValido.length > 0) {
|
|
301
|
+
set.add('judicial');
|
|
302
|
+
}
|
|
303
|
+
return Array.from(set);
|
|
304
|
+
}, [
|
|
305
|
+
ctx.document,
|
|
306
|
+
(_j = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _j === void 0 ? void 0 : _j.indiciosDeLiminarProtestosDoPassado,
|
|
307
|
+
processosComAssuntoValido
|
|
308
|
+
]);
|
|
309
|
+
var protestKeysForHistory = useMemo(function () {
|
|
310
|
+
var _a;
|
|
311
|
+
return (((_a = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _a === void 0 ? void 0 : _a.protestosDoPassadoIds) || '')
|
|
312
|
+
.split(',')
|
|
313
|
+
.filter(Boolean);
|
|
314
|
+
}, [(_k = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _k === void 0 ? void 0 : _k.protestosDoPassadoIds]);
|
|
315
|
+
var processIdsForHistory = useMemo(function () { return processosComAssuntoValido.map(function (p) { return p.id; }); }, [processosComAssuntoValido]);
|
|
316
|
+
// 🔔 grava o histórico assim que todos os dados necessários existirem
|
|
317
|
+
useLiminarHistory({
|
|
318
|
+
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,
|
|
320
|
+
types: typesForHistory,
|
|
321
|
+
protestKeys: protestKeysForHistory,
|
|
322
|
+
processIds: processIdsForHistory,
|
|
323
|
+
enabled: ready
|
|
324
|
+
});
|
|
269
325
|
var scrollToProcesso = function (id) {
|
|
270
326
|
var el = document.getElementById(id);
|
|
271
327
|
if (!el)
|
|
@@ -282,8 +338,8 @@ var Liminar = function (_a) {
|
|
|
282
338
|
: 'Processos com indícios encontrados:';
|
|
283
339
|
var shouldRender = isLoadingLiminarProtestosDoPassado ||
|
|
284
340
|
(ready &&
|
|
285
|
-
(((
|
|
286
|
-
((
|
|
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));
|
|
287
343
|
// Função para disparar o envio do e-mail e configurar a mensagem do modal
|
|
288
344
|
var handleSendEmailIndicios = function (e) { return __awaiter(void 0, void 0, void 0, function () {
|
|
289
345
|
var callback;
|
|
@@ -311,7 +367,8 @@ var Liminar = function (_a) {
|
|
|
311
367
|
}
|
|
312
368
|
else {
|
|
313
369
|
setEmailModalMessage(React.createElement(React.Fragment, null,
|
|
314
|
-
"Os detalhes dos protestos ocultados foram enviados para seu e-mail.
|
|
370
|
+
"Os detalhes dos protestos ocultados foram enviados para seu e-mail.",
|
|
371
|
+
' ',
|
|
315
372
|
React.createElement("br", null),
|
|
316
373
|
"R$ 50 foram debitados automaticamente do seu saldo para essa opera\u00E7\u00E3o."));
|
|
317
374
|
}
|
|
@@ -371,7 +428,12 @@ var Liminar = function (_a) {
|
|
|
371
428
|
setIsEmailModalOpen(false);
|
|
372
429
|
setEmailModalMessage('');
|
|
373
430
|
}, title: "Protestos ocultos enviados por e-mail" },
|
|
374
|
-
React.createElement("div", { style: {
|
|
431
|
+
React.createElement("div", { style: {
|
|
432
|
+
textAlign: 'center',
|
|
433
|
+
display: 'block',
|
|
434
|
+
fontSize: 18,
|
|
435
|
+
fontWeight: 400
|
|
436
|
+
} }, emailModalMessage),
|
|
375
437
|
React.createElement("div", { style: { textAlign: 'center', marginTop: '16px' } },
|
|
376
438
|
React.createElement(Button, { onClick: function () {
|
|
377
439
|
setIsEmailModalOpen(false);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface LiminarHistoryParams {
|
|
2
|
+
documento: string;
|
|
3
|
+
indicioDeLiminar: boolean;
|
|
4
|
+
types: string[];
|
|
5
|
+
protestKeys?: string[];
|
|
6
|
+
processIds?: string[];
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function useLiminarHistory({ documento, indicioDeLiminar, types, protestKeys, processIds, enabled }: LiminarHistoryParams): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
10
|
+
import { useEffect, useRef } from 'react';
|
|
11
|
+
import { useFetch } from '../webservice';
|
|
12
|
+
export function useLiminarHistory(_a) {
|
|
13
|
+
var documento = _a.documento, indicioDeLiminar = _a.indicioDeLiminar, types = _a.types, _b = _a.protestKeys, protestKeys = _b === void 0 ? [] : _b, _c = _a.processIds, processIds = _c === void 0 ? [] : _c, _d = _a.enabled, enabled = _d === void 0 ? true : _d;
|
|
14
|
+
var insertHistory = useFetch("INSERT INTO 'LIMINAR'.'INTERFACE'").fetch;
|
|
15
|
+
var lastFingerprint = useRef();
|
|
16
|
+
useEffect(function () {
|
|
17
|
+
if (!enabled || !documento)
|
|
18
|
+
return;
|
|
19
|
+
var effectiveTypes = indicioDeLiminar ? types : [];
|
|
20
|
+
var fingerprint = JSON.stringify({
|
|
21
|
+
documento: documento,
|
|
22
|
+
indicioDeLiminar: indicioDeLiminar,
|
|
23
|
+
types: __spreadArray([], effectiveTypes, true).sort(),
|
|
24
|
+
protestKeys: protestKeys,
|
|
25
|
+
processIds: processIds
|
|
26
|
+
});
|
|
27
|
+
if (fingerprint === lastFingerprint.current)
|
|
28
|
+
return;
|
|
29
|
+
var payload = {
|
|
30
|
+
documento: documento,
|
|
31
|
+
indicioDeLiminar: indicioDeLiminar ? 'true' : 'false',
|
|
32
|
+
types: JSON.stringify(effectiveTypes)
|
|
33
|
+
};
|
|
34
|
+
if (protestKeys.length)
|
|
35
|
+
payload.protestKeys = JSON.stringify(protestKeys);
|
|
36
|
+
if (processIds.length)
|
|
37
|
+
payload.processIds = JSON.stringify(processIds);
|
|
38
|
+
insertHistory(payload);
|
|
39
|
+
lastFingerprint.current = fingerprint;
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
+
}, [
|
|
42
|
+
documento,
|
|
43
|
+
indicioDeLiminar,
|
|
44
|
+
types.join(','),
|
|
45
|
+
protestKeys.join(','),
|
|
46
|
+
processIds.join(','),
|
|
47
|
+
enabled
|
|
48
|
+
]);
|
|
49
|
+
}
|