@credithub/harlan-components 1.69.1 → 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 +116 -112
- package/lib/cjs/index.js +117 -113
- package/lib/esm/index.js +117 -113
- 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,141 +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 _e = 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
|
-
var
|
|
121
|
+
/* PJ “banco”, “fintech”... */
|
|
122
|
+
var pjDetectada = processosComAssuntoValido.some(function (proc) {
|
|
123
123
|
var _a;
|
|
124
|
-
return (_a =
|
|
124
|
+
return (_a = proc.envolvidos_ultima_movimentacao) === null || _a === void 0 ? void 0 : _a.some(function (e) {
|
|
125
125
|
if (e.envolvido_tipo !== 'Ativo')
|
|
126
126
|
return false;
|
|
127
127
|
var nomeNorm = normalizeName(e.nome_sem_filtro);
|
|
128
|
-
return businessTypes.some(function (
|
|
128
|
+
return businessTypes.some(function (t) { return nomeNorm.includes(t); });
|
|
129
129
|
});
|
|
130
130
|
});
|
|
131
131
|
return {
|
|
132
132
|
origensDetectadas: Array.from(labels),
|
|
133
|
-
foundBusinessEntity:
|
|
133
|
+
foundBusinessEntity: pjDetectada
|
|
134
134
|
};
|
|
135
|
-
}, [ctx.document, tiposDocumento, processosComAssuntoValido]), origensDetectadas =
|
|
135
|
+
}, [ctx.document, tiposDocumento, processosComAssuntoValido]), origensDetectadas = _h.origensDetectadas, foundBusinessEntity = _h.foundBusinessEntity;
|
|
136
|
+
/* =========================================================================
|
|
137
|
+
* Efeito 1 – gravar IDs invertidos (invertedProcessos) apenas se mudarem
|
|
138
|
+
* ========================================================================= */
|
|
136
139
|
useEffect(function () {
|
|
137
140
|
if (!foundBusinessEntity)
|
|
138
141
|
return;
|
|
139
|
-
|
|
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 }) })); });
|
|
140
149
|
}, [foundBusinessEntity, processosComAssuntoValido, setData]);
|
|
141
|
-
|
|
142
|
-
|
|
150
|
+
/* =========================================================================
|
|
151
|
+
* Efeito 2 – pipeline principal: status “Encontrado / Não encontrado”
|
|
152
|
+
* ========================================================================= */
|
|
143
153
|
useEffect(function () {
|
|
144
154
|
var _a, _b, _c, _d;
|
|
145
155
|
if (!((_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel) ||
|
|
146
156
|
!((_b = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _b === void 0 ? void 0 : _b.isLoaded))
|
|
147
157
|
return;
|
|
148
|
-
if (ctx.type === RequestStatus.Loading)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
158
|
+
if (ctx.type === RequestStatus.Loading)
|
|
159
|
+
return; // aguarda terminar
|
|
160
|
+
/* hash que depende apenas de campos realmente relevantes */
|
|
152
161
|
var hash = JSON.stringify({
|
|
153
|
-
|
|
162
|
+
t: ctx.type,
|
|
154
163
|
indicios: (_c = ctx.document) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminar,
|
|
155
164
|
carousel: globalData.dossie.carousel,
|
|
156
165
|
empresas: globalData.processosJuridicosData.empresa
|
|
157
166
|
});
|
|
158
|
-
if (hash === dataHashRef.current
|
|
159
|
-
return;
|
|
167
|
+
if (hash === dataHashRef.current)
|
|
168
|
+
return; // já processado
|
|
160
169
|
dataHashRef.current = hash;
|
|
161
|
-
|
|
162
|
-
setData(function (prev) { return (__assign(__assign({}, prev), { liminar: { isLoaded: true } })); });
|
|
163
|
-
console.error('Erro na requisição de liminares:', ctx.error || 'desconhecido');
|
|
164
|
-
}
|
|
170
|
+
/* status final */
|
|
165
171
|
var indiciosApi = ((_d = ctx.document) === null || _d === void 0 ? void 0 : _d.indiciosDeLiminar) === true;
|
|
166
|
-
var finalStatus = indiciosApi || processosComAssuntoValido.length
|
|
172
|
+
var finalStatus = indiciosApi || processosComAssuntoValido.length
|
|
167
173
|
? 'Encontrado'
|
|
168
174
|
: 'Não encontrado';
|
|
169
|
-
setData(function (prev) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return
|
|
174
|
-
}
|
|
175
|
-
return __assign(__assign({}, prev), { liminar: {
|
|
176
|
-
indiciosDeLiminar: indiciosApi,
|
|
177
|
-
message: finalStatus,
|
|
178
|
-
isLoaded: true,
|
|
179
|
-
processosComLiminarIds: processosComAssuntoValido.map(function (p) { return p.id; })
|
|
180
|
-
} });
|
|
181
|
-
});
|
|
182
|
-
resultRef.current = finalStatus;
|
|
183
|
-
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
|
+
} })); });
|
|
184
181
|
processedRef.current = true;
|
|
185
|
-
}, [
|
|
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 ------------------- */
|
|
186
195
|
var scrollToProcesso = function (id) {
|
|
187
196
|
var el = document.getElementById(id);
|
|
188
|
-
if (el)
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
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);
|
|
193
202
|
};
|
|
194
|
-
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')
|
|
195
204
|
return null;
|
|
196
|
-
}
|
|
197
205
|
var renderTooltipIcon = function () {
|
|
198
|
-
var color = origensDetectadas.length
|
|
206
|
+
var color = origensDetectadas.length
|
|
199
207
|
? theme.colors.erroClaro
|
|
200
208
|
: theme.colors.cinzaClaro;
|
|
201
209
|
return (React.createElement(WarningCircle, { weight: "fill", size: 24, color: color, style: { marginLeft: 4 } }));
|
|
202
210
|
};
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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,
|
|
209
218
|
"Processos com ind\u00EDcios encontrados:",
|
|
210
|
-
React.createElement("ul", { style: { marginTop:
|
|
211
|
-
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,
|
|
212
221
|
cursor: 'pointer',
|
|
213
222
|
textDecoration: 'underline',
|
|
214
223
|
color: '#007aff'
|
|
215
|
-
} }, proc.id)); })))))))
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
description: (React.createElement(React.Fragment, null,
|
|
228
|
-
React.createElement(StatusMessage, { type: variant }, message),
|
|
229
|
-
origensDetectadas.map(function (o, i) { return (React.createElement(StatusMessage, { key: i, type: variant }, o)); })))
|
|
230
|
-
};
|
|
231
|
-
} }));
|
|
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
|
+
} }));
|
|
232
236
|
};
|
|
233
237
|
export default Liminar;
|