@credithub/harlan-components 1.64.4 → 1.64.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 +88 -96
- package/lib/cjs/index.js +92 -100
- package/lib/esm/index.js +92 -100
- package/package.json +1 -1
|
@@ -16,148 +16,140 @@ import React, { useContext, useEffect, useMemo, useRef } from 'react';
|
|
|
16
16
|
import StatusMessage from '../interface/statusMessage';
|
|
17
17
|
import Section from '../section';
|
|
18
18
|
import { Queries, RequestStatus } from '../webservice';
|
|
19
|
+
// Lista de assuntos válidos para identificação de liminares
|
|
19
20
|
var validAssuntos = [
|
|
20
21
|
'protesto indevido de título',
|
|
21
22
|
'protesto indevido de títulos',
|
|
22
23
|
'inclusão indevida em cadastro de inadimplentes',
|
|
23
24
|
'liminar',
|
|
24
|
-
'sustação de
|
|
25
|
+
'sustação de protesto',
|
|
25
26
|
'inexequibilidade do titulo / inexequibilidade da obrigação',
|
|
26
|
-
'
|
|
27
|
-
'Inexequibilidade do Título / Inexequibilidade da Obrigação | Tutela de Urgência | Protesto Indevido de Título'
|
|
27
|
+
'inexequibilidade do titulo / inexequibilidade da obrigação | tutela de urgência | protesto indevido de título'
|
|
28
28
|
].map(normalizeName);
|
|
29
29
|
var Liminar = function () {
|
|
30
|
-
var _a, _b
|
|
30
|
+
var _a, _b;
|
|
31
31
|
var ctx = useContext(Queries.LiminarCenprot);
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
var _c = useGlobalData(), globalData = _c.data, setData = _c.setData;
|
|
33
|
+
var processedRef = useRef(false);
|
|
34
|
+
var processingRef = useRef(true);
|
|
35
|
+
var resultRef = useRef('Não encontrado');
|
|
36
|
+
var dataHashRef = useRef('');
|
|
37
|
+
var tiposDocumento = useMemo(function () {
|
|
38
|
+
var _a;
|
|
38
39
|
var tipoRaw = (_a = ctx.document) === null || _a === void 0 ? void 0 : _a.type;
|
|
39
|
-
var tipos = [];
|
|
40
40
|
if (Array.isArray(tipoRaw)) {
|
|
41
|
-
|
|
41
|
+
return tipoRaw.map(function (t) { return t.toLowerCase(); });
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
if (typeof tipoRaw === 'string') {
|
|
44
|
+
return [tipoRaw.toLowerCase()];
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
return [];
|
|
47
|
+
}, [ctx.document]);
|
|
48
|
+
var mapTipoToLabel = function (tipo) {
|
|
49
|
+
switch (tipo) {
|
|
50
|
+
case 'cenprot':
|
|
51
|
+
return 'Liminar no Cenprot';
|
|
52
|
+
case 'serasa':
|
|
53
|
+
return 'Liminar na Serasa';
|
|
54
|
+
case 'judicial':
|
|
55
|
+
return 'Liminar no Judiciário';
|
|
56
|
+
default:
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
// Detecta origens de liminar: tipos + processos
|
|
61
|
+
var origensDetectadas = useMemo(function () {
|
|
62
|
+
var _a, _b, _c, _d;
|
|
63
|
+
var labels = new Set();
|
|
64
|
+
var indiciosApi = ((_a = ctx.document) === null || _a === void 0 ? void 0 : _a.indiciosDeLiminar) === true;
|
|
65
|
+
if (indiciosApi) {
|
|
66
|
+
tiposDocumento.forEach(function (tipo) {
|
|
67
|
+
var label = mapTipoToLabel(tipo);
|
|
68
|
+
if (label)
|
|
69
|
+
labels.add(label);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// 2) Sempre verificar processos jurídicos
|
|
55
73
|
var carouselName = ((_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.name) || '';
|
|
56
74
|
var empresas = (_d = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _d === void 0 ? void 0 : _d.empresa;
|
|
57
|
-
if (Array.isArray(empresas)) {
|
|
58
|
-
var
|
|
59
|
-
var
|
|
75
|
+
if (carouselName && Array.isArray(empresas)) {
|
|
76
|
+
var nomeEmpresaNorm_1 = normalizeName(carouselName);
|
|
77
|
+
var hasJudicial = empresas.some(function (processo) {
|
|
60
78
|
var _a;
|
|
61
|
-
var
|
|
62
|
-
return
|
|
63
|
-
similarNames(normalizeName(
|
|
79
|
+
var ativoMatch = (_a = processo.envolvidos_ultima_movimentacao) === null || _a === void 0 ? void 0 : _a.some(function (e) {
|
|
80
|
+
return e.envolvido_tipo === 'Ativo' &&
|
|
81
|
+
similarNames(normalizeName(e.nome_sem_filtro), nomeEmpresaNorm_1, 0.9);
|
|
64
82
|
});
|
|
83
|
+
if (!ativoMatch)
|
|
84
|
+
return false;
|
|
65
85
|
var assuntos = Array.isArray(processo.assuntos)
|
|
66
86
|
? processo.assuntos
|
|
67
87
|
: [processo.assuntos];
|
|
68
|
-
|
|
69
|
-
return validAssuntos.
|
|
70
|
-
return similarNames(normalizeName(assunto), valid, 0.9);
|
|
71
|
-
});
|
|
88
|
+
return assuntos.some(function (a) {
|
|
89
|
+
return validAssuntos.includes(normalizeName(a));
|
|
72
90
|
});
|
|
73
|
-
return hasAtivoEnvolvido && hasValidAssunto;
|
|
74
91
|
});
|
|
75
|
-
if (
|
|
76
|
-
|
|
92
|
+
if (hasJudicial) {
|
|
93
|
+
labels.add('Liminar no Judiciário');
|
|
77
94
|
}
|
|
78
95
|
}
|
|
79
|
-
return
|
|
96
|
+
return Array.from(labels);
|
|
80
97
|
}, [
|
|
81
98
|
ctx.document,
|
|
99
|
+
tiposDocumento,
|
|
82
100
|
(_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel,
|
|
83
101
|
(_b = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.empresa
|
|
84
102
|
]);
|
|
85
|
-
//
|
|
86
|
-
var
|
|
87
|
-
var
|
|
88
|
-
|
|
89
|
-
var dataHashRef = useRef('');
|
|
90
|
-
var isProcessoNaoEncontrado = useMemo(function () {
|
|
91
|
-
return ctx.type === RequestStatus.Error && ctx.error;
|
|
92
|
-
}, [ctx.type, ctx.error]);
|
|
93
|
-
var derivedCtx = useMemo(function () {
|
|
94
|
-
return __assign(__assign({}, ctx), { type: isProcessoNaoEncontrado ? RequestStatus.Success : ctx.type, document: isProcessoNaoEncontrado
|
|
95
|
-
? { indiciosDeLiminar: false }
|
|
96
|
-
: ctx.document });
|
|
97
|
-
}, [ctx, isProcessoNaoEncontrado]);
|
|
103
|
+
// Indica se houve erro 404 (processo não encontrado)
|
|
104
|
+
var isErro404 = useMemo(function () { return ctx.type === RequestStatus.Error && !!ctx.error; }, [ctx.type, ctx.error]);
|
|
105
|
+
var derivedCtx = useMemo(function () { return (__assign(__assign({}, ctx), { type: isErro404 ? RequestStatus.Success : ctx.type, document: isErro404 ? { indiciosDeLiminar: false } : ctx.document })); }, [ctx, isErro404]);
|
|
106
|
+
// Efeito principal: atualiza estado global e resultados
|
|
98
107
|
useEffect(function () {
|
|
108
|
+
var _a, _b, _c, _d;
|
|
109
|
+
if (!((_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel) ||
|
|
110
|
+
!((_b = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.isLoaded))
|
|
111
|
+
return;
|
|
99
112
|
if (ctx.type === RequestStatus.Loading) {
|
|
100
113
|
processingRef.current = true;
|
|
101
|
-
processedRef.current = false;
|
|
102
|
-
}
|
|
103
|
-
}, [ctx.type]);
|
|
104
|
-
useEffect(function () {
|
|
105
|
-
var _a, _b, _c;
|
|
106
|
-
if (!((_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel) ||
|
|
107
|
-
!((_b = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.isLoaded)) {
|
|
108
114
|
return;
|
|
109
115
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
116
|
+
var hash = JSON.stringify({
|
|
117
|
+
tipo: ctx.type,
|
|
118
|
+
indicios: (_c = ctx.document) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminar,
|
|
113
119
|
carousel: globalData.dossie.carousel,
|
|
114
|
-
|
|
115
|
-
ctx: {
|
|
116
|
-
type: ctx.type,
|
|
117
|
-
document: !!ctx.document,
|
|
118
|
-
error: ctx.error ? String(ctx.error) : null
|
|
119
|
-
}
|
|
120
|
+
empresas: globalData.processosJuridicosData.empresa
|
|
120
121
|
});
|
|
121
|
-
if (
|
|
122
|
+
if (hash === dataHashRef.current && processedRef.current)
|
|
122
123
|
return;
|
|
123
|
-
dataHashRef.current =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
setData(function (prevState) { return (__assign(__assign({}, prevState), { liminar: { isLoaded: true } })); });
|
|
128
|
-
console.error('Erro na requisição de liminares:', ctx.error || 'Erro desconhecido');
|
|
124
|
+
dataHashRef.current = hash;
|
|
125
|
+
if (ctx.type === RequestStatus.Error && !isErro404) {
|
|
126
|
+
setData(function (prev) { return (__assign(__assign({}, prev), { liminar: { isLoaded: true } })); });
|
|
127
|
+
console.error('Erro na requisição de liminares:', ctx.error || 'desconhecido');
|
|
129
128
|
}
|
|
130
|
-
var
|
|
131
|
-
var
|
|
132
|
-
? ((_c = ctx.document) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminar) === true
|
|
133
|
-
: false;
|
|
134
|
-
var finalStatus = indiciosDeLiminar ||
|
|
135
|
-
(empresas &&
|
|
136
|
-
empresas.length > 0 &&
|
|
137
|
-
resultRef.current !== 'Não encontrado')
|
|
129
|
+
var indiciosApi = ((_d = ctx.document) === null || _d === void 0 ? void 0 : _d.indiciosDeLiminar) === true;
|
|
130
|
+
var finalStatus = indiciosApi || origensDetectadas.length > 0
|
|
138
131
|
? 'Encontrado'
|
|
139
132
|
: 'Não encontrado';
|
|
140
133
|
setData(function (prev) {
|
|
141
134
|
var _a, _b;
|
|
142
135
|
if (((_a = prev.liminar) === null || _a === void 0 ? void 0 : _a.message) === finalStatus &&
|
|
143
|
-
((_b = prev.liminar) === null || _b === void 0 ? void 0 : _b.indiciosDeLiminar) ===
|
|
136
|
+
((_b = prev.liminar) === null || _b === void 0 ? void 0 : _b.indiciosDeLiminar) === indiciosApi) {
|
|
144
137
|
return prev;
|
|
145
138
|
}
|
|
146
|
-
return __assign(__assign({}, prev), { liminar: {
|
|
139
|
+
return __assign(__assign({}, prev), { liminar: {
|
|
140
|
+
indiciosDeLiminar: indiciosApi,
|
|
141
|
+
message: finalStatus,
|
|
142
|
+
isLoaded: true
|
|
143
|
+
} });
|
|
147
144
|
});
|
|
148
145
|
resultRef.current = finalStatus;
|
|
149
146
|
processingRef.current = false;
|
|
150
147
|
processedRef.current = true;
|
|
151
|
-
}, [
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
(_d = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _d === void 0 ? void 0 : _d.isLoaded,
|
|
155
|
-
(_e = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _e === void 0 ? void 0 : _e.empresa,
|
|
156
|
-
isProcessoNaoEncontrado,
|
|
157
|
-
setData
|
|
158
|
-
]);
|
|
159
|
-
if (processedRef.current && resultRef.current === 'Não encontrado')
|
|
148
|
+
}, [ctx, globalData, origensDetectadas, setData, isErro404]);
|
|
149
|
+
// Se nada encontrado, não renderiza componente
|
|
150
|
+
if (processedRef.current && resultRef.current === 'Não encontrado') {
|
|
160
151
|
return null;
|
|
152
|
+
}
|
|
161
153
|
return (React.createElement(Section, { title: "Liminares para Remo\u00E7\u00E3o de Protesto", subtitle: processingRef.current
|
|
162
154
|
? 'Carregando liminar...'
|
|
163
155
|
: 'Indícios de liminares para ocultação de registros.', icon: ProtestosIcon, ctx: processingRef.current
|
|
@@ -165,14 +157,14 @@ var Liminar = function () {
|
|
|
165
157
|
? undefined
|
|
166
158
|
: function (data, context) {
|
|
167
159
|
var _a;
|
|
168
|
-
var
|
|
169
|
-
var variant =
|
|
160
|
+
var message = ((_a = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _a === void 0 ? void 0 : _a.message) || 'Não encontrado';
|
|
161
|
+
var variant = message === 'Encontrado' ? 'error' : 'default';
|
|
170
162
|
return {
|
|
171
163
|
children: React.createElement(React.Fragment, null),
|
|
172
164
|
variant: variant,
|
|
173
165
|
description: (React.createElement(React.Fragment, null,
|
|
174
|
-
React.createElement(StatusMessage, { type: variant },
|
|
175
|
-
origensDetectadas.map(function (
|
|
166
|
+
React.createElement(StatusMessage, { type: variant }, message),
|
|
167
|
+
origensDetectadas.map(function (o, i) { return (React.createElement(StatusMessage, { key: i, type: variant }, o)); })))
|
|
176
168
|
};
|
|
177
169
|
} }));
|
|
178
170
|
};
|