@credithub/harlan-components 1.64.3 → 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 +97 -100
- package/lib/cjs/index.js +98 -101
- package/lib/esm/index.js +98 -101
- package/package.json +1 -1
|
@@ -16,23 +16,36 @@ 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
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
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;
|
|
39
|
+
var tipoRaw = (_a = ctx.document) === null || _a === void 0 ? void 0 : _a.type;
|
|
40
|
+
if (Array.isArray(tipoRaw)) {
|
|
41
|
+
return tipoRaw.map(function (t) { return t.toLowerCase(); });
|
|
42
|
+
}
|
|
43
|
+
if (typeof tipoRaw === 'string') {
|
|
44
|
+
return [tipoRaw.toLowerCase()];
|
|
45
|
+
}
|
|
46
|
+
return [];
|
|
47
|
+
}, [ctx.document]);
|
|
48
|
+
var mapTipoToLabel = function (tipo) {
|
|
36
49
|
switch (tipo) {
|
|
37
50
|
case 'cenprot':
|
|
38
51
|
return 'Liminar no Cenprot';
|
|
@@ -41,116 +54,102 @@ var Liminar = function () {
|
|
|
41
54
|
case 'judicial':
|
|
42
55
|
return 'Liminar no Judiciário';
|
|
43
56
|
default:
|
|
44
|
-
return
|
|
57
|
+
return null;
|
|
45
58
|
}
|
|
46
|
-
}
|
|
47
|
-
//
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return __assign(__assign({}, ctx), { type: isProcessoNaoEncontrado ? RequestStatus.Success : ctx.type, document: isProcessoNaoEncontrado
|
|
59
|
-
? { indiciosDeLiminar: false }
|
|
60
|
-
: ctx.document });
|
|
61
|
-
}, [ctx, isProcessoNaoEncontrado]);
|
|
62
|
-
// Reset processing state when loading new data
|
|
63
|
-
useEffect(function () {
|
|
64
|
-
if (ctx.type === RequestStatus.Loading) {
|
|
65
|
-
processingRef.current = true;
|
|
66
|
-
processedRef.current = false;
|
|
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
|
+
});
|
|
67
71
|
}
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
// 2) Sempre verificar processos jurídicos
|
|
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) || '';
|
|
74
|
+
var empresas = (_d = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _d === void 0 ? void 0 : _d.empresa;
|
|
75
|
+
if (carouselName && Array.isArray(empresas)) {
|
|
76
|
+
var nomeEmpresaNorm_1 = normalizeName(carouselName);
|
|
77
|
+
var hasJudicial = empresas.some(function (processo) {
|
|
78
|
+
var _a;
|
|
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);
|
|
82
|
+
});
|
|
83
|
+
if (!ativoMatch)
|
|
84
|
+
return false;
|
|
85
|
+
var assuntos = Array.isArray(processo.assuntos)
|
|
86
|
+
? processo.assuntos
|
|
87
|
+
: [processo.assuntos];
|
|
88
|
+
return assuntos.some(function (a) {
|
|
89
|
+
return validAssuntos.includes(normalizeName(a));
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
if (hasJudicial) {
|
|
93
|
+
labels.add('Liminar no Judiciário');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return Array.from(labels);
|
|
97
|
+
}, [
|
|
98
|
+
ctx.document,
|
|
99
|
+
tiposDocumento,
|
|
100
|
+
(_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel,
|
|
101
|
+
(_b = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.empresa
|
|
102
|
+
]);
|
|
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
|
|
70
107
|
useEffect(function () {
|
|
71
|
-
var _a, _b, _c;
|
|
72
|
-
// Skip processing if we don't have the necessary data
|
|
108
|
+
var _a, _b, _c, _d;
|
|
73
109
|
if (!((_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel) ||
|
|
74
|
-
!((_b = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.isLoaded))
|
|
110
|
+
!((_b = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.isLoaded))
|
|
75
111
|
return;
|
|
76
|
-
}
|
|
77
|
-
// Skip if we're still loading
|
|
78
112
|
if (ctx.type === RequestStatus.Loading) {
|
|
113
|
+
processingRef.current = true;
|
|
79
114
|
return;
|
|
80
115
|
}
|
|
81
|
-
|
|
82
|
-
|
|
116
|
+
var hash = JSON.stringify({
|
|
117
|
+
tipo: ctx.type,
|
|
118
|
+
indicios: (_c = ctx.document) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminar,
|
|
83
119
|
carousel: globalData.dossie.carousel,
|
|
84
|
-
|
|
85
|
-
ctx: {
|
|
86
|
-
type: ctx.type,
|
|
87
|
-
document: ctx.document ? true : false,
|
|
88
|
-
error: ctx.error ? String(ctx.error) : null
|
|
89
|
-
}
|
|
120
|
+
empresas: globalData.processosJuridicosData.empresa
|
|
90
121
|
});
|
|
91
|
-
|
|
92
|
-
if (currentDataHash === dataHashRef.current && processedRef.current) {
|
|
122
|
+
if (hash === dataHashRef.current && processedRef.current)
|
|
93
123
|
return;
|
|
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');
|
|
94
128
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
var carousel = globalData.dossie.carousel;
|
|
98
|
-
var empresas = globalData.processosJuridicosData.empresa;
|
|
99
|
-
// Begin the actual data processing
|
|
100
|
-
var empresaNomeNormalizado = normalizeName((carousel === null || carousel === void 0 ? void 0 : carousel.name) || '');
|
|
101
|
-
var processosAtivo = empresas === null || empresas === void 0 ? void 0 : empresas.filter(function (processo) {
|
|
102
|
-
var _a;
|
|
103
|
-
var hasAtivoEnvolvido = (_a = processo.envolvidos_ultima_movimentacao) === null || _a === void 0 ? void 0 : _a.some(function (envolvido) {
|
|
104
|
-
var isAtivo = envolvido.envolvido_tipo === 'Ativo';
|
|
105
|
-
var isSimilar = similarNames(normalizeName(envolvido.nome_sem_filtro), empresaNomeNormalizado, 0.9);
|
|
106
|
-
return isAtivo && isSimilar;
|
|
107
|
-
});
|
|
108
|
-
var assuntos = Array.isArray(processo.assuntos)
|
|
109
|
-
? processo.assuntos
|
|
110
|
-
: [processo.assuntos];
|
|
111
|
-
var hasValidAssunto = assuntos.some(function (assunto) {
|
|
112
|
-
return validAssuntos.some(function (valid) {
|
|
113
|
-
return similarNames(normalizeName(assunto), valid, 0.9);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
return hasAtivoEnvolvido && hasValidAssunto;
|
|
117
|
-
});
|
|
118
|
-
if (ctx.type === RequestStatus.Error && !isProcessoNaoEncontrado) {
|
|
119
|
-
setData(function (prevState) { return (__assign(__assign({}, prevState), { liminar: { isLoaded: true } })); });
|
|
120
|
-
console.error('Erro na requisição de liminares:', ctx.error || 'Erro desconhecido');
|
|
121
|
-
}
|
|
122
|
-
// Determine final status
|
|
123
|
-
var isSuccess = ctx.type === RequestStatus.Success || isProcessoNaoEncontrado;
|
|
124
|
-
var indiciosDeLiminar = isSuccess
|
|
125
|
-
? ((_c = ctx.document) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminar) === true
|
|
126
|
-
: false;
|
|
127
|
-
var finalStatus = indiciosDeLiminar || (processosAtivo && processosAtivo.length > 0)
|
|
129
|
+
var indiciosApi = ((_d = ctx.document) === null || _d === void 0 ? void 0 : _d.indiciosDeLiminar) === true;
|
|
130
|
+
var finalStatus = indiciosApi || origensDetectadas.length > 0
|
|
128
131
|
? 'Encontrado'
|
|
129
132
|
: 'Não encontrado';
|
|
130
|
-
// Only update global state if the value has changed
|
|
131
133
|
setData(function (prev) {
|
|
132
134
|
var _a, _b;
|
|
133
135
|
if (((_a = prev.liminar) === null || _a === void 0 ? void 0 : _a.message) === finalStatus &&
|
|
134
|
-
((_b = prev.liminar) === null || _b === void 0 ? void 0 : _b.indiciosDeLiminar) ===
|
|
136
|
+
((_b = prev.liminar) === null || _b === void 0 ? void 0 : _b.indiciosDeLiminar) === indiciosApi) {
|
|
135
137
|
return prev;
|
|
136
138
|
}
|
|
137
|
-
return __assign(__assign({}, prev), { liminar: {
|
|
139
|
+
return __assign(__assign({}, prev), { liminar: {
|
|
140
|
+
indiciosDeLiminar: indiciosApi,
|
|
141
|
+
message: finalStatus,
|
|
142
|
+
isLoaded: true
|
|
143
|
+
} });
|
|
138
144
|
});
|
|
139
|
-
// Store the result in our ref
|
|
140
145
|
resultRef.current = finalStatus;
|
|
141
146
|
processingRef.current = false;
|
|
142
147
|
processedRef.current = true;
|
|
143
|
-
}, [
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
(_b = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.isLoaded,
|
|
147
|
-
(_c = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _c === void 0 ? void 0 : _c.empresa,
|
|
148
|
-
isProcessoNaoEncontrado,
|
|
149
|
-
setData
|
|
150
|
-
]);
|
|
151
|
-
// Don't render if no indications were found
|
|
152
|
-
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') {
|
|
153
151
|
return null;
|
|
152
|
+
}
|
|
154
153
|
return (React.createElement(Section, { title: "Liminares para Remo\u00E7\u00E3o de Protesto", subtitle: processingRef.current
|
|
155
154
|
? 'Carregando liminar...'
|
|
156
155
|
: 'Indícios de liminares para ocultação de registros.', icon: ProtestosIcon, ctx: processingRef.current
|
|
@@ -158,16 +157,14 @@ var Liminar = function () {
|
|
|
158
157
|
? undefined
|
|
159
158
|
: function (data, context) {
|
|
160
159
|
var _a;
|
|
161
|
-
var
|
|
162
|
-
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';
|
|
163
162
|
return {
|
|
164
163
|
children: React.createElement(React.Fragment, null),
|
|
165
164
|
variant: variant,
|
|
166
165
|
description: (React.createElement(React.Fragment, null,
|
|
167
|
-
React.createElement(StatusMessage, { type: variant },
|
|
168
|
-
|
|
169
|
-
' '),
|
|
170
|
-
origemLiminar && (React.createElement(StatusMessage, { type: variant }, origemLiminar))))
|
|
166
|
+
React.createElement(StatusMessage, { type: variant }, message),
|
|
167
|
+
origensDetectadas.map(function (o, i) { return (React.createElement(StatusMessage, { key: i, type: variant }, o)); })))
|
|
171
168
|
};
|
|
172
169
|
} }));
|
|
173
170
|
};
|