@credithub/harlan-components 1.69.0 → 1.69.2
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 +128 -119
- package/lib/cjs/index.js +129 -120
- package/lib/esm/index.js +129 -120
- package/package.json +1 -1
|
@@ -19,6 +19,9 @@ import StatusMessage from '../interface/statusMessage';
|
|
|
19
19
|
import Section from '../section';
|
|
20
20
|
import { Queries, RequestStatus } from '../webservice';
|
|
21
21
|
import { TitleWithTooltip, TooltipContainer, TooltipText } from './liminarStyles';
|
|
22
|
+
/* ----------------------------------
|
|
23
|
+
* Constantes auxiliares
|
|
24
|
+
* ---------------------------------*/
|
|
22
25
|
var validAssuntos = [
|
|
23
26
|
'protesto indevido de título',
|
|
24
27
|
'protesto indevido de títulos',
|
|
@@ -36,55 +39,58 @@ var businessTypes = [
|
|
|
36
39
|
'banco',
|
|
37
40
|
'cooperativa'
|
|
38
41
|
];
|
|
42
|
+
/* ----------------------------------
|
|
43
|
+
* Componente
|
|
44
|
+
* ---------------------------------*/
|
|
39
45
|
var Liminar = function () {
|
|
40
|
-
var _a, _b;
|
|
46
|
+
var _a, _b, _c, _d, _e;
|
|
47
|
+
/* -------- Contextos -------- */
|
|
41
48
|
var ctx = useContext(Queries.LiminarCenprot);
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
var
|
|
49
|
+
var _f = useGlobalData(), globalData = _f.data, setData = _f.setData;
|
|
50
|
+
/* -------- Refs de controle de efeitos -------- */
|
|
51
|
+
var processedRef = useRef(false); // já finalizou pipeline principal
|
|
52
|
+
var dataHashRef = useRef(''); // detecção de repetição
|
|
53
|
+
var invertedIdsRef = useRef([]); // cache ids já gravados
|
|
54
|
+
/* -------- Tooltip -------- */
|
|
55
|
+
var _g = useState(false), isTooltipVisible = _g[0], setTooltipVisible = _g[1];
|
|
56
|
+
var hideTooltipTimeout = useRef();
|
|
49
57
|
var showTooltip = function () {
|
|
50
58
|
if (hideTooltipTimeout.current)
|
|
51
59
|
clearTimeout(hideTooltipTimeout.current);
|
|
52
60
|
setTooltipVisible(true);
|
|
53
61
|
};
|
|
54
62
|
var hideTooltip = function () {
|
|
55
|
-
hideTooltipTimeout.current = setTimeout(function () {
|
|
56
|
-
setTooltipVisible(false);
|
|
57
|
-
}, 300);
|
|
63
|
+
hideTooltipTimeout.current = setTimeout(function () { return setTooltipVisible(false); }, 300);
|
|
58
64
|
};
|
|
65
|
+
/* -------- Tipos de documento vindos da API -------- */
|
|
59
66
|
var tiposDocumento = useMemo(function () {
|
|
60
67
|
var _a;
|
|
61
|
-
var
|
|
62
|
-
if (Array.isArray(
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return [tipoRaw.toLowerCase()];
|
|
67
|
-
}
|
|
68
|
+
var raw = (_a = ctx.document) === null || _a === void 0 ? void 0 : _a.type;
|
|
69
|
+
if (Array.isArray(raw))
|
|
70
|
+
return raw.map(function (t) { return t.toLowerCase(); });
|
|
71
|
+
if (typeof raw === 'string')
|
|
72
|
+
return [raw.toLowerCase()];
|
|
68
73
|
return [];
|
|
69
74
|
}, [ctx.document]);
|
|
75
|
+
/* -------- Processos com assunto relevante -------- */
|
|
70
76
|
var processosComAssuntoValido = useMemo(function () {
|
|
71
77
|
var _a, _b, _c;
|
|
72
78
|
var carouselName = ((_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) || '';
|
|
73
79
|
var empresas = (_c = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _c === void 0 ? void 0 : _c.empresa;
|
|
74
|
-
var
|
|
80
|
+
var nomeNorm = normalizeName(carouselName);
|
|
75
81
|
if (!Array.isArray(empresas))
|
|
76
82
|
return [];
|
|
77
|
-
return empresas.filter(function (
|
|
83
|
+
return empresas.filter(function (proc) {
|
|
78
84
|
var _a;
|
|
79
|
-
var ativoMatch = (_a =
|
|
85
|
+
var ativoMatch = (_a = proc.envolvidos_ultima_movimentacao) === null || _a === void 0 ? void 0 : _a.some(function (e) {
|
|
80
86
|
return e.envolvido_tipo === 'Ativo' &&
|
|
81
|
-
similarNames(normalizeName(e.nome_sem_filtro),
|
|
87
|
+
similarNames(normalizeName(e.nome_sem_filtro), nomeNorm, 0.9);
|
|
82
88
|
});
|
|
83
89
|
if (!ativoMatch)
|
|
84
90
|
return false;
|
|
85
|
-
var assuntos = Array.isArray(
|
|
86
|
-
?
|
|
87
|
-
: [
|
|
91
|
+
var assuntos = Array.isArray(proc.assuntos)
|
|
92
|
+
? proc.assuntos
|
|
93
|
+
: [proc.assuntos];
|
|
88
94
|
return assuntos.some(function (a) {
|
|
89
95
|
return validAssuntos.includes(normalizeName(a));
|
|
90
96
|
});
|
|
@@ -93,136 +99,139 @@ var Liminar = function () {
|
|
|
93
99
|
(_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel,
|
|
94
100
|
(_b = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.empresa
|
|
95
101
|
]);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
case 'cenprot':
|
|
99
|
-
return 'Liminar no Cenprot';
|
|
100
|
-
case 'serasa':
|
|
101
|
-
return 'Liminar na Serasa';
|
|
102
|
-
case 'judicial':
|
|
103
|
-
return 'Liminar no Judiciário';
|
|
104
|
-
default:
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
var origensDetectadas = useMemo(function () {
|
|
102
|
+
/* -------- Labels de origem e detecção de entidade PJ -------- */
|
|
103
|
+
var _h = useMemo(function () {
|
|
109
104
|
var _a;
|
|
105
|
+
/* Labels */
|
|
110
106
|
var labels = new Set();
|
|
111
107
|
var indiciosApi = ((_a = ctx.document) === null || _a === void 0 ? void 0 : _a.indiciosDeLiminar) === true;
|
|
112
108
|
if (indiciosApi) {
|
|
113
109
|
tiposDocumento.forEach(function (tipo) {
|
|
114
|
-
var
|
|
115
|
-
|
|
116
|
-
|
|
110
|
+
var m = {
|
|
111
|
+
cenprot: 'Liminar no Cenprot',
|
|
112
|
+
serasa: 'Liminar na Serasa',
|
|
113
|
+
judicial: 'Liminar no Judiciário'
|
|
114
|
+
};
|
|
115
|
+
if (m[tipo])
|
|
116
|
+
labels.add(m[tipo]);
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
if (processosComAssuntoValido.length
|
|
119
|
+
if (processosComAssuntoValido.length)
|
|
120
120
|
labels.add('Liminar no Judiciário');
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
});
|
|
121
|
+
/* PJ “banco”, “fintech”... */
|
|
122
|
+
var pjDetectada = processosComAssuntoValido.some(function (proc) {
|
|
123
|
+
var _a;
|
|
124
|
+
return (_a = proc.envolvidos_ultima_movimentacao) === null || _a === void 0 ? void 0 : _a.some(function (e) {
|
|
125
|
+
if (e.envolvido_tipo !== 'Ativo')
|
|
126
|
+
return false;
|
|
127
|
+
var nomeNorm = normalizeName(e.nome_sem_filtro);
|
|
128
|
+
return businessTypes.some(function (t) { return nomeNorm.includes(t); });
|
|
129
129
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}, [ctx.document, tiposDocumento, processosComAssuntoValido,
|
|
136
|
-
|
|
137
|
-
|
|
130
|
+
});
|
|
131
|
+
return {
|
|
132
|
+
origensDetectadas: Array.from(labels),
|
|
133
|
+
foundBusinessEntity: pjDetectada
|
|
134
|
+
};
|
|
135
|
+
}, [ctx.document, tiposDocumento, processosComAssuntoValido]), origensDetectadas = _h.origensDetectadas, foundBusinessEntity = _h.foundBusinessEntity;
|
|
136
|
+
/* =========================================================================
|
|
137
|
+
* Efeito 1 – gravar IDs invertidos (invertedProcessos) apenas se mudarem
|
|
138
|
+
* ========================================================================= */
|
|
139
|
+
useEffect(function () {
|
|
140
|
+
if (!foundBusinessEntity)
|
|
141
|
+
return;
|
|
142
|
+
var newIds = processosComAssuntoValido.map(function (p) { return p.id; });
|
|
143
|
+
var same = newIds.length === invertedIdsRef.current.length &&
|
|
144
|
+
newIds.every(function (id, i) { return id === invertedIdsRef.current[i]; });
|
|
145
|
+
if (same)
|
|
146
|
+
return; // nada mudou → não dispara setState
|
|
147
|
+
invertedIdsRef.current = newIds;
|
|
148
|
+
setData(function (prev) { return (__assign(__assign({}, prev), { liminar: __assign(__assign({}, prev.liminar), { invertedProcessos: newIds }) })); });
|
|
149
|
+
}, [foundBusinessEntity, processosComAssuntoValido, setData]);
|
|
150
|
+
/* =========================================================================
|
|
151
|
+
* Efeito 2 – pipeline principal: status “Encontrado / Não encontrado”
|
|
152
|
+
* ========================================================================= */
|
|
138
153
|
useEffect(function () {
|
|
139
154
|
var _a, _b, _c, _d;
|
|
140
155
|
if (!((_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel) ||
|
|
141
156
|
!((_b = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.isLoaded))
|
|
142
157
|
return;
|
|
143
|
-
if (ctx.type === RequestStatus.Loading)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
158
|
+
if (ctx.type === RequestStatus.Loading)
|
|
159
|
+
return; // aguarda terminar
|
|
160
|
+
/* hash que depende apenas de campos realmente relevantes */
|
|
147
161
|
var hash = JSON.stringify({
|
|
148
|
-
|
|
162
|
+
t: ctx.type,
|
|
149
163
|
indicios: (_c = ctx.document) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminar,
|
|
150
164
|
carousel: globalData.dossie.carousel,
|
|
151
165
|
empresas: globalData.processosJuridicosData.empresa
|
|
152
166
|
});
|
|
153
|
-
if (hash === dataHashRef.current
|
|
154
|
-
return;
|
|
167
|
+
if (hash === dataHashRef.current)
|
|
168
|
+
return; // já processado
|
|
155
169
|
dataHashRef.current = hash;
|
|
156
|
-
|
|
157
|
-
setData(function (prev) { return (__assign(__assign({}, prev), { liminar: { isLoaded: true } })); });
|
|
158
|
-
console.error('Erro na requisição de liminares:', ctx.error || 'desconhecido');
|
|
159
|
-
}
|
|
170
|
+
/* status final */
|
|
160
171
|
var indiciosApi = ((_d = ctx.document) === null || _d === void 0 ? void 0 : _d.indiciosDeLiminar) === true;
|
|
161
|
-
var finalStatus = indiciosApi || processosComAssuntoValido.length
|
|
172
|
+
var finalStatus = indiciosApi || processosComAssuntoValido.length
|
|
162
173
|
? 'Encontrado'
|
|
163
174
|
: 'Não encontrado';
|
|
164
|
-
setData(function (prev) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return
|
|
169
|
-
}
|
|
170
|
-
return __assign(__assign({}, prev), { liminar: {
|
|
171
|
-
indiciosDeLiminar: indiciosApi,
|
|
172
|
-
message: finalStatus,
|
|
173
|
-
isLoaded: true,
|
|
174
|
-
processosComLiminarIds: processosComAssuntoValido.map(function (p) { return p.id; })
|
|
175
|
-
} });
|
|
176
|
-
});
|
|
177
|
-
resultRef.current = finalStatus;
|
|
178
|
-
processingRef.current = false;
|
|
175
|
+
setData(function (prev) { return (__assign(__assign({}, prev), { liminar: {
|
|
176
|
+
indiciosDeLiminar: indiciosApi,
|
|
177
|
+
message: finalStatus,
|
|
178
|
+
isLoaded: true,
|
|
179
|
+
processosComLiminarIds: processosComAssuntoValido.map(function (p) { return p.id; })
|
|
180
|
+
} })); });
|
|
179
181
|
processedRef.current = true;
|
|
180
|
-
}, [
|
|
182
|
+
}, [
|
|
183
|
+
ctx.type,
|
|
184
|
+
ctx.document,
|
|
185
|
+
(_c = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _c === void 0 ? void 0 : _c.carousel,
|
|
186
|
+
(_d = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _d === void 0 ? void 0 : _d.empresa,
|
|
187
|
+
processosComAssuntoValido,
|
|
188
|
+
setData
|
|
189
|
+
]);
|
|
190
|
+
/* -------- Limpa timeout do tooltip ao desmontar -------- */
|
|
191
|
+
useEffect(function () { return function () {
|
|
192
|
+
return hideTooltipTimeout.current && clearTimeout(hideTooltipTimeout.current);
|
|
193
|
+
}; }, []);
|
|
194
|
+
/* ---------------------- UI auxiliares ------------------- */
|
|
181
195
|
var scrollToProcesso = function (id) {
|
|
182
196
|
var el = document.getElementById(id);
|
|
183
|
-
if (el)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
197
|
+
if (!el)
|
|
198
|
+
return;
|
|
199
|
+
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
200
|
+
el.classList.add('highlighted-process');
|
|
201
|
+
setTimeout(function () { return el.classList.remove('highlighted-process'); }, 3000);
|
|
188
202
|
};
|
|
189
|
-
if (processedRef.current &&
|
|
203
|
+
if (processedRef.current && ((_e = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _e === void 0 ? void 0 : _e.message) === 'Não encontrado')
|
|
190
204
|
return null;
|
|
191
|
-
}
|
|
192
205
|
var renderTooltipIcon = function () {
|
|
193
|
-
var color = origensDetectadas.length
|
|
206
|
+
var color = origensDetectadas.length
|
|
194
207
|
? theme.colors.erroClaro
|
|
195
208
|
: theme.colors.cinzaClaro;
|
|
196
209
|
return (React.createElement(WarningCircle, { weight: "fill", size: 24, color: color, style: { marginLeft: 4 } }));
|
|
197
210
|
};
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
211
|
+
/* ---------------------- Render -------------------------- */
|
|
212
|
+
return (React.createElement(Section, { title: React.createElement(TitleWithTooltip, null,
|
|
213
|
+
"Liminares para Remo\u00E7\u00E3o de Protesto",
|
|
214
|
+
!!processosComAssuntoValido.length && (React.createElement(TooltipContainer, { onMouseEnter: showTooltip, onMouseLeave: hideTooltip },
|
|
215
|
+
renderTooltipIcon(),
|
|
216
|
+
React.createElement(TooltipText, { visible: isTooltipVisible },
|
|
217
|
+
React.createElement(React.Fragment, null,
|
|
204
218
|
"Processos com ind\u00EDcios encontrados:",
|
|
205
|
-
React.createElement("ul", { style: { marginTop:
|
|
206
|
-
fontSize:
|
|
219
|
+
React.createElement("ul", { style: { marginTop: 6, paddingLeft: 18 } }, processosComAssuntoValido.map(function (proc) { return (React.createElement("li", { key: proc.id, onClick: function () { return scrollToProcesso(proc.id); }, style: {
|
|
220
|
+
fontSize: 13,
|
|
207
221
|
cursor: 'pointer',
|
|
208
222
|
textDecoration: 'underline',
|
|
209
223
|
color: '#007aff'
|
|
210
|
-
} }, proc.id)); })))))))
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
description: (React.createElement(React.Fragment, null,
|
|
223
|
-
React.createElement(StatusMessage, { type: variant }, message),
|
|
224
|
-
origensDetectadas.map(function (o, i) { return (React.createElement(StatusMessage, { key: i, type: variant }, o)); })))
|
|
225
|
-
};
|
|
226
|
-
} }));
|
|
224
|
+
} }, proc.id)); }))))))), subtitle: "Ind\u00EDcios de liminares para oculta\u00E7\u00E3o de registros.", icon: ProtestosIcon, ctx: ctx, onSuccess: function () {
|
|
225
|
+
var _a;
|
|
226
|
+
var msg = ((_a = globalData === null || globalData === void 0 ? void 0 : globalData.liminar) === null || _a === void 0 ? void 0 : _a.message) || 'Não encontrado';
|
|
227
|
+
var variant = msg === 'Encontrado' ? 'error' : 'default';
|
|
228
|
+
return {
|
|
229
|
+
children: React.createElement(React.Fragment, null),
|
|
230
|
+
variant: variant,
|
|
231
|
+
description: (React.createElement(React.Fragment, null,
|
|
232
|
+
React.createElement(StatusMessage, { type: variant }, msg),
|
|
233
|
+
origensDetectadas.map(function (o) { return (React.createElement(StatusMessage, { key: o, type: variant }, o)); })))
|
|
234
|
+
};
|
|
235
|
+
} }));
|
|
227
236
|
};
|
|
228
237
|
export default Liminar;
|