@credithub/harlan-components 1.59.3 → 1.59.5
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.js +35 -72
- package/dist/components/protestos/protestos.js +2 -2
- package/lib/cjs/index.js +38 -75
- package/lib/esm/index.js +38 -75
- package/package.json +1 -1
|
@@ -16,51 +16,23 @@ import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
16
16
|
import StatusMessage from '../interface/statusMessage';
|
|
17
17
|
import Section from '../section';
|
|
18
18
|
import { Queries, RequestStatus } from '../webservice';
|
|
19
|
-
function useStableValue(value) {
|
|
20
|
-
var _a = useState(value), stableValue = _a[0], setStableValue = _a[1];
|
|
21
|
-
var lastValueRef = useRef(value);
|
|
22
|
-
var consecutiveFramesRef = useRef(0);
|
|
23
|
-
useEffect(function () {
|
|
24
|
-
lastValueRef.current = value;
|
|
25
|
-
consecutiveFramesRef.current = 0;
|
|
26
|
-
var frame;
|
|
27
|
-
function check() {
|
|
28
|
-
if (lastValueRef.current === value) {
|
|
29
|
-
consecutiveFramesRef.current++;
|
|
30
|
-
if (consecutiveFramesRef.current >= 2) {
|
|
31
|
-
setStableValue(value);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
consecutiveFramesRef.current = 0;
|
|
37
|
-
lastValueRef.current = value;
|
|
38
|
-
}
|
|
39
|
-
frame = requestAnimationFrame(check);
|
|
40
|
-
}
|
|
41
|
-
frame = requestAnimationFrame(check);
|
|
42
|
-
return function () { return cancelAnimationFrame(frame); };
|
|
43
|
-
}, [value]);
|
|
44
|
-
return stableValue;
|
|
45
|
-
}
|
|
46
19
|
var Liminar = function () {
|
|
47
20
|
var _a, _b, _c;
|
|
48
21
|
var ctx = useContext(Queries.LiminarCenprot);
|
|
49
22
|
var _d = useGlobalData(), globalData = _d.data, setData = _d.setData;
|
|
50
23
|
var _e = useState(undefined), liminarResult = _e[0], setLiminarResult = _e[1];
|
|
51
|
-
var
|
|
24
|
+
var didRunRef = useRef(false);
|
|
52
25
|
var carousel = (_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel;
|
|
53
26
|
var isPJDataLoaded = (_b = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.isLoaded;
|
|
54
27
|
var empresas = (_c = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _c === void 0 ? void 0 : _c.empresa;
|
|
55
|
-
var dataHash = useMemo(function () { return JSON.stringify({ carousel: carousel, isPJDataLoaded: isPJDataLoaded, empresas: empresas }); }, [carousel, isPJDataLoaded, empresas]);
|
|
56
|
-
var stableDataHash = useStableValue(dataHash);
|
|
57
28
|
useEffect(function () {
|
|
58
29
|
var _a;
|
|
59
|
-
if (
|
|
30
|
+
if (didRunRef.current)
|
|
60
31
|
return;
|
|
61
32
|
if (!carousel || !isPJDataLoaded)
|
|
62
33
|
return;
|
|
63
|
-
var
|
|
34
|
+
var empresaNome = carousel.name || '';
|
|
35
|
+
var empresaNomeNormalizado = normalizeName(empresaNome);
|
|
64
36
|
var validAssuntos = [
|
|
65
37
|
'protesto indevido de títulos',
|
|
66
38
|
'inclusão indevida em cadastro de inadimplentes',
|
|
@@ -73,63 +45,54 @@ var Liminar = function () {
|
|
|
73
45
|
var processosAtivo = empresas === null || empresas === void 0 ? void 0 : empresas.filter(function (processo) {
|
|
74
46
|
var _a;
|
|
75
47
|
var hasAtivoEnvolvido = (_a = processo.envolvidos_ultima_movimentacao) === null || _a === void 0 ? void 0 : _a.some(function (envolvido) {
|
|
76
|
-
|
|
77
|
-
|
|
48
|
+
var nomeEnvolvidoNormalizado = normalizeName(envolvido.nome_sem_filtro);
|
|
49
|
+
return (envolvido.envolvido_tipo === 'Ativo' &&
|
|
50
|
+
similarNames(nomeEnvolvidoNormalizado, empresaNomeNormalizado));
|
|
78
51
|
});
|
|
79
52
|
var assuntos = Array.isArray(processo.assuntos)
|
|
80
53
|
? processo.assuntos
|
|
81
54
|
: [processo.assuntos];
|
|
82
55
|
var hasValidAssunto = assuntos.some(function (assunto) {
|
|
56
|
+
var assuntoNormalizado = normalizeName(assunto);
|
|
83
57
|
return validAssuntos.some(function (valid) {
|
|
84
|
-
return similarNames(
|
|
58
|
+
return similarNames(assuntoNormalizado, valid);
|
|
85
59
|
});
|
|
86
60
|
});
|
|
87
61
|
return hasAtivoEnvolvido && hasValidAssunto;
|
|
88
62
|
});
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
if (ctx.type === RequestStatus.Error && !isProcessoNaoEncontrado) {
|
|
63
|
+
var indiciosDeLiminar = false;
|
|
64
|
+
if (ctx.type === RequestStatus.Error) {
|
|
92
65
|
console.error('Erro na requisição de liminares:', ctx.error || 'Erro desconhecido');
|
|
93
66
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
: false;
|
|
67
|
+
else if (ctx.type === RequestStatus.Success) {
|
|
68
|
+
indiciosDeLiminar = ((_a = ctx.document) === null || _a === void 0 ? void 0 : _a.indiciosDeLiminar) === true;
|
|
69
|
+
}
|
|
98
70
|
var finalStatus = indiciosDeLiminar || (processosAtivo && processosAtivo.length > 0)
|
|
99
71
|
? 'Encontrado'
|
|
100
72
|
: 'Não encontrado';
|
|
101
73
|
setData(function (prev) { return (__assign(__assign({}, prev), { liminar: { indiciosDeLiminar: indiciosDeLiminar, message: finalStatus } })); });
|
|
102
74
|
setLiminarResult(finalStatus);
|
|
103
|
-
|
|
104
|
-
}, [
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
]);
|
|
113
|
-
|
|
114
|
-
String(ctx.error).includes('Processo(s) não encontrado(s).');
|
|
115
|
-
var derivedCtx = useMemo(function () { return (__assign(__assign({}, ctx), { type: isProcessoNaoEncontrado ? RequestStatus.Success : ctx.type, document: isProcessoNaoEncontrado
|
|
116
|
-
? { indiciosDeLiminar: false }
|
|
117
|
-
: ctx.document })); }, [ctx, isProcessoNaoEncontrado]);
|
|
118
|
-
if (!isProcessing && liminarResult === 'Não encontrado')
|
|
75
|
+
didRunRef.current = true;
|
|
76
|
+
}, [carousel, isPJDataLoaded, empresas, ctx.type, setData]);
|
|
77
|
+
var derivedCtx = useMemo(function () {
|
|
78
|
+
if (liminarResult === undefined) {
|
|
79
|
+
return __assign(__assign({}, ctx), { type: RequestStatus.Loading });
|
|
80
|
+
}
|
|
81
|
+
return __assign(__assign({}, ctx), { type: ctx.type === RequestStatus.Error ? RequestStatus.Success : ctx.type, document: ctx.type === RequestStatus.Error
|
|
82
|
+
? { indiciosDeLiminar: false }
|
|
83
|
+
: ctx.document });
|
|
84
|
+
}, [liminarResult, ctx]);
|
|
85
|
+
if (liminarResult === 'Não encontrado') {
|
|
119
86
|
return null;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
?
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
variant: variant,
|
|
131
|
-
description: (React.createElement(StatusMessage, { type: variant }, globalMessage))
|
|
132
|
-
};
|
|
133
|
-
} }));
|
|
87
|
+
}
|
|
88
|
+
return (React.createElement(Section, { title: "Liminares para Remo\u00E7\u00E3o de Protesto", subtitle: "Ind\u00EDcios de liminares para oculta\u00E7\u00E3o de registros.", icon: ProtestosIcon, ctx: derivedCtx, onSuccess: function (doc) {
|
|
89
|
+
var _a;
|
|
90
|
+
var globalMessage = ((_a = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _a === void 0 ? void 0 : _a.message) || 'Não encontrado';
|
|
91
|
+
return {
|
|
92
|
+
children: React.createElement(React.Fragment, null),
|
|
93
|
+
variant: globalMessage === 'Encontrado' ? 'error' : 'default',
|
|
94
|
+
description: (React.createElement(StatusMessage, { type: globalMessage === 'Encontrado' ? 'error' : 'default' }, globalMessage))
|
|
95
|
+
};
|
|
96
|
+
} }));
|
|
134
97
|
};
|
|
135
98
|
export default Liminar;
|
|
@@ -117,9 +117,9 @@ var Protestos = function () {
|
|
|
117
117
|
.map(function (protestoElement, index) { return (React.createElement(ProtestoItem, { protesto: protestoElement, key: index })); })))
|
|
118
118
|
}
|
|
119
119
|
].sort(function (a, b) { return b.total - a.total; });
|
|
120
|
-
var children = registros ? (React.createElement(ResultProtestos, null, elements.map(function (_a) {
|
|
120
|
+
var children = registros ? (React.createElement(ResultProtestos, null, elements.map(function (_a, i) {
|
|
121
121
|
var element = _a.element;
|
|
122
|
-
return element;
|
|
122
|
+
return React.createElement(React.Fragment, { key: i }, element);
|
|
123
123
|
}))) : null;
|
|
124
124
|
return {
|
|
125
125
|
children: children,
|