@credithub/harlan-components 1.64.3 → 1.64.4
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 +67 -62
- package/lib/cjs/index.js +68 -63
- package/lib/esm/index.js +68 -63
- package/package.json +1 -1
|
@@ -27,107 +27,116 @@ var validAssuntos = [
|
|
|
27
27
|
'Inexequibilidade do Título / 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, _c;
|
|
30
|
+
var _a, _b, _c, _d, _e;
|
|
31
31
|
var ctx = useContext(Queries.LiminarCenprot);
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return 'Liminar no Judiciário';
|
|
43
|
-
default:
|
|
44
|
-
return undefined;
|
|
32
|
+
var _f = useGlobalData(), globalData = _f.data, setData = _f.setData;
|
|
33
|
+
// Detecta múltiplas origens de liminar
|
|
34
|
+
var origensDetectadas = useMemo(function () {
|
|
35
|
+
var _a, _b, _c, _d;
|
|
36
|
+
var sources = [];
|
|
37
|
+
// Trata tipo vindo como string ou array
|
|
38
|
+
var tipoRaw = (_a = ctx.document) === null || _a === void 0 ? void 0 : _a.type;
|
|
39
|
+
var tipos = [];
|
|
40
|
+
if (Array.isArray(tipoRaw)) {
|
|
41
|
+
tipos.push.apply(tipos, tipoRaw.map(function (t) { return t.toLowerCase(); }));
|
|
45
42
|
}
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
else if (typeof tipoRaw === 'string') {
|
|
44
|
+
tipos.push(tipoRaw.toLowerCase());
|
|
45
|
+
}
|
|
46
|
+
tipos.forEach(function (tipo) {
|
|
47
|
+
if (tipo === 'cenprot')
|
|
48
|
+
sources.push('Liminar no Cenprot');
|
|
49
|
+
else if (tipo === 'serasa')
|
|
50
|
+
sources.push('Liminar na Serasa');
|
|
51
|
+
else if (tipo === 'judicial')
|
|
52
|
+
sources.push('Liminar no Judiciário');
|
|
53
|
+
});
|
|
54
|
+
// Detecção via processos jurídicos
|
|
55
|
+
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
|
+
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 empresaNomeNormalizado_1 = normalizeName(carouselName);
|
|
59
|
+
var processosComLiminar = empresas.filter(function (processo) {
|
|
60
|
+
var _a;
|
|
61
|
+
var hasAtivoEnvolvido = (_a = processo.envolvidos_ultima_movimentacao) === null || _a === void 0 ? void 0 : _a.some(function (envolvido) {
|
|
62
|
+
return (envolvido.envolvido_tipo === 'Ativo' &&
|
|
63
|
+
similarNames(normalizeName(envolvido.nome_sem_filtro), empresaNomeNormalizado_1, 0.9));
|
|
64
|
+
});
|
|
65
|
+
var assuntos = Array.isArray(processo.assuntos)
|
|
66
|
+
? processo.assuntos
|
|
67
|
+
: [processo.assuntos];
|
|
68
|
+
var hasValidAssunto = assuntos.some(function (assunto) {
|
|
69
|
+
return validAssuntos.some(function (valid) {
|
|
70
|
+
return similarNames(normalizeName(assunto), valid, 0.9);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
return hasAtivoEnvolvido && hasValidAssunto;
|
|
74
|
+
});
|
|
75
|
+
if (processosComLiminar.length > 0) {
|
|
76
|
+
sources.push('Liminar no Judiciário');
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return sources;
|
|
80
|
+
}, [
|
|
81
|
+
ctx.document,
|
|
82
|
+
(_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel,
|
|
83
|
+
(_b = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.empresa
|
|
84
|
+
]);
|
|
85
|
+
// refs para controle de processamento
|
|
48
86
|
var processedRef = useRef(false);
|
|
49
87
|
var processingRef = useRef(true);
|
|
50
88
|
var resultRef = useRef(undefined);
|
|
51
89
|
var dataHashRef = useRef('');
|
|
52
|
-
// Determine if process was not found using API exception
|
|
53
90
|
var isProcessoNaoEncontrado = useMemo(function () {
|
|
54
91
|
return ctx.type === RequestStatus.Error && ctx.error;
|
|
55
92
|
}, [ctx.type, ctx.error]);
|
|
56
|
-
// Create derived context to handle not found exceptions
|
|
57
93
|
var derivedCtx = useMemo(function () {
|
|
58
94
|
return __assign(__assign({}, ctx), { type: isProcessoNaoEncontrado ? RequestStatus.Success : ctx.type, document: isProcessoNaoEncontrado
|
|
59
95
|
? { indiciosDeLiminar: false }
|
|
60
96
|
: ctx.document });
|
|
61
97
|
}, [ctx, isProcessoNaoEncontrado]);
|
|
62
|
-
// Reset processing state when loading new data
|
|
63
98
|
useEffect(function () {
|
|
64
99
|
if (ctx.type === RequestStatus.Loading) {
|
|
65
100
|
processingRef.current = true;
|
|
66
101
|
processedRef.current = false;
|
|
67
102
|
}
|
|
68
103
|
}, [ctx.type]);
|
|
69
|
-
// Process data once when context and global data are available
|
|
70
104
|
useEffect(function () {
|
|
71
105
|
var _a, _b, _c;
|
|
72
|
-
// Skip processing if we don't have the necessary data
|
|
73
106
|
if (!((_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel) ||
|
|
74
107
|
!((_b = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.isLoaded)) {
|
|
75
108
|
return;
|
|
76
109
|
}
|
|
77
|
-
|
|
78
|
-
if (ctx.type === RequestStatus.Loading) {
|
|
110
|
+
if (ctx.type === RequestStatus.Loading)
|
|
79
111
|
return;
|
|
80
|
-
}
|
|
81
|
-
// Create a hash of the current data state
|
|
82
112
|
var currentDataHash = JSON.stringify({
|
|
83
113
|
carousel: globalData.dossie.carousel,
|
|
84
114
|
empresa: globalData.processosJuridicosData.empresa,
|
|
85
115
|
ctx: {
|
|
86
116
|
type: ctx.type,
|
|
87
|
-
document: ctx.document
|
|
117
|
+
document: !!ctx.document,
|
|
88
118
|
error: ctx.error ? String(ctx.error) : null
|
|
89
119
|
}
|
|
90
120
|
});
|
|
91
|
-
|
|
92
|
-
if (currentDataHash === dataHashRef.current && processedRef.current) {
|
|
121
|
+
if (currentDataHash === dataHashRef.current && processedRef.current)
|
|
93
122
|
return;
|
|
94
|
-
}
|
|
95
|
-
// Update data hash reference
|
|
96
123
|
dataHashRef.current = currentDataHash;
|
|
97
|
-
|
|
124
|
+
// Processamento de dados
|
|
98
125
|
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
126
|
if (ctx.type === RequestStatus.Error && !isProcessoNaoEncontrado) {
|
|
119
127
|
setData(function (prevState) { return (__assign(__assign({}, prevState), { liminar: { isLoaded: true } })); });
|
|
120
128
|
console.error('Erro na requisição de liminares:', ctx.error || 'Erro desconhecido');
|
|
121
129
|
}
|
|
122
|
-
// Determine final status
|
|
123
130
|
var isSuccess = ctx.type === RequestStatus.Success || isProcessoNaoEncontrado;
|
|
124
131
|
var indiciosDeLiminar = isSuccess
|
|
125
132
|
? ((_c = ctx.document) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminar) === true
|
|
126
133
|
: false;
|
|
127
|
-
var finalStatus = indiciosDeLiminar ||
|
|
134
|
+
var finalStatus = indiciosDeLiminar ||
|
|
135
|
+
(empresas &&
|
|
136
|
+
empresas.length > 0 &&
|
|
137
|
+
resultRef.current !== 'Não encontrado')
|
|
128
138
|
? 'Encontrado'
|
|
129
139
|
: 'Não encontrado';
|
|
130
|
-
// Only update global state if the value has changed
|
|
131
140
|
setData(function (prev) {
|
|
132
141
|
var _a, _b;
|
|
133
142
|
if (((_a = prev.liminar) === null || _a === void 0 ? void 0 : _a.message) === finalStatus &&
|
|
@@ -136,19 +145,17 @@ var Liminar = function () {
|
|
|
136
145
|
}
|
|
137
146
|
return __assign(__assign({}, prev), { liminar: { indiciosDeLiminar: indiciosDeLiminar, message: finalStatus, isLoaded: true } });
|
|
138
147
|
});
|
|
139
|
-
// Store the result in our ref
|
|
140
148
|
resultRef.current = finalStatus;
|
|
141
149
|
processingRef.current = false;
|
|
142
150
|
processedRef.current = true;
|
|
143
151
|
}, [
|
|
144
152
|
ctx,
|
|
145
|
-
(
|
|
146
|
-
(
|
|
147
|
-
(
|
|
153
|
+
(_c = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _c === void 0 ? void 0 : _c.carousel,
|
|
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,
|
|
148
156
|
isProcessoNaoEncontrado,
|
|
149
157
|
setData
|
|
150
158
|
]);
|
|
151
|
-
// Don't render if no indications were found
|
|
152
159
|
if (processedRef.current && resultRef.current === 'Não encontrado')
|
|
153
160
|
return null;
|
|
154
161
|
return (React.createElement(Section, { title: "Liminares para Remo\u00E7\u00E3o de Protesto", subtitle: processingRef.current
|
|
@@ -164,10 +171,8 @@ var Liminar = function () {
|
|
|
164
171
|
children: React.createElement(React.Fragment, null),
|
|
165
172
|
variant: variant,
|
|
166
173
|
description: (React.createElement(React.Fragment, null,
|
|
167
|
-
React.createElement(StatusMessage, { type: variant },
|
|
168
|
-
|
|
169
|
-
' '),
|
|
170
|
-
origemLiminar && (React.createElement(StatusMessage, { type: variant }, origemLiminar))))
|
|
174
|
+
React.createElement(StatusMessage, { type: variant }, globalMessage),
|
|
175
|
+
origensDetectadas.map(function (origem, index) { return (React.createElement(StatusMessage, { key: index, type: variant }, origem)); })))
|
|
171
176
|
};
|
|
172
177
|
} }));
|
|
173
178
|
};
|