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