@credithub/harlan-components 1.62.0 → 1.62.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/ccf/ccf.js +1 -0
- package/dist/components/dividasPublicas/dividasPublicas.js +1 -0
- package/dist/components/liminar/liminar.js +5 -6
- package/dist/components/processos-juridicos/processosJuridicos.js +2 -7
- package/dist/components/protestos/protestos.js +2 -1
- package/dist/utils/similarNames.d.ts +1 -1
- package/dist/utils/similarNames.js +8 -6
- package/lib/cjs/index.js +19 -24
- package/lib/esm/index.js +19 -24
- package/package.json +1 -1
|
@@ -48,6 +48,7 @@ var CCF = function () {
|
|
|
48
48
|
}
|
|
49
49
|
if (ctx.type === RequestStatus.Error || ctx.type === RequestStatus.Empty) {
|
|
50
50
|
setData(function (prevState) { return (__assign(__assign({}, prevState), { ccfData: { isLoaded: true } })); });
|
|
51
|
+
return;
|
|
51
52
|
}
|
|
52
53
|
var data = ctx.document;
|
|
53
54
|
var _a = processData(data), ccfData = _a.ccfData, totalOcorrencias = _a.totalOcorrencias, ultimoRegistro = _a.ultimoRegistro;
|
|
@@ -55,6 +55,7 @@ var DividasPublicas = function () {
|
|
|
55
55
|
var dividas = parseDividas(ctx.document);
|
|
56
56
|
if (ctx.type === RequestStatus.Error || ctx.type === RequestStatus.Empty) {
|
|
57
57
|
setData(function (prevState) { return (__assign(__assign({}, prevState), { divida: { isLoaded: true } })); });
|
|
58
|
+
return;
|
|
58
59
|
}
|
|
59
60
|
if (!dataUpdated) {
|
|
60
61
|
var dividasPublicas_1 = XPathUtils.select('number(//dividas/resumo/valor_total_dividas)', ctx.document) || 0;
|
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import ProtestosIcon from '../../assets/icones/protestos';
|
|
13
13
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
14
|
-
import { normalizeName,
|
|
14
|
+
import { normalizeName, similarNames } from '../../utils/similarNames';
|
|
15
15
|
import React, { useContext, useEffect, useMemo, useRef } from 'react';
|
|
16
16
|
import StatusMessage from '../interface/statusMessage';
|
|
17
17
|
import Section from '../section';
|
|
@@ -84,24 +84,23 @@ var Liminar = function () {
|
|
|
84
84
|
var empresas = globalData.processosJuridicosData.empresa;
|
|
85
85
|
// Begin the actual data processing
|
|
86
86
|
var empresaNomeNormalizado = normalizeName((carousel === null || carousel === void 0 ? void 0 : carousel.name) || '');
|
|
87
|
-
// Look for valid processes
|
|
88
87
|
var processosAtivo = empresas === null || empresas === void 0 ? void 0 : empresas.filter(function (processo) {
|
|
89
88
|
var _a;
|
|
90
89
|
var hasAtivoEnvolvido = (_a = processo.envolvidos_ultima_movimentacao) === null || _a === void 0 ? void 0 : _a.some(function (envolvido) {
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
var isAtivo = envolvido.envolvido_tipo === 'Ativo';
|
|
91
|
+
var isSimilar = similarNames(normalizeName(envolvido.nome_sem_filtro), empresaNomeNormalizado, 0.9);
|
|
92
|
+
return isAtivo && isSimilar;
|
|
93
93
|
});
|
|
94
94
|
var assuntos = Array.isArray(processo.assuntos)
|
|
95
95
|
? processo.assuntos
|
|
96
96
|
: [processo.assuntos];
|
|
97
97
|
var hasValidAssunto = assuntos.some(function (assunto) {
|
|
98
98
|
return validAssuntos.some(function (valid) {
|
|
99
|
-
return
|
|
99
|
+
return similarNames(normalizeName(assunto), valid, 0.9);
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
102
|
return hasAtivoEnvolvido && hasValidAssunto;
|
|
103
103
|
});
|
|
104
|
-
// Only log actual errors
|
|
105
104
|
if (ctx.type === RequestStatus.Error && !isProcessoNaoEncontrado) {
|
|
106
105
|
setData(function (prevState) { return (__assign(__assign({}, prevState), { liminar: { isLoaded: true } })); });
|
|
107
106
|
console.error('Erro na requisição de liminares:', ctx.error || 'Erro desconhecido');
|
|
@@ -23,12 +23,6 @@ var ProcessosJuridicos = function (_a) {
|
|
|
23
23
|
// Use a ref instead of state to track whether data has been processed
|
|
24
24
|
var processedRef = useRef(false);
|
|
25
25
|
var ctxHashRef = useRef('');
|
|
26
|
-
useEffect(function () {
|
|
27
|
-
if (ctx.type === RequestStatus.Loading) {
|
|
28
|
-
processedRef.current = false;
|
|
29
|
-
setData(function (prevState) { return (__assign(__assign({}, prevState), { processosJuridicosData: __assign(__assign({}, prevState.processosJuridicosData), { isLoaded: false }) })); });
|
|
30
|
-
}
|
|
31
|
-
}, [ctx.type, setData]);
|
|
32
26
|
useEffect(function () {
|
|
33
27
|
var _a;
|
|
34
28
|
// Create a hash of the current context state to detect changes
|
|
@@ -89,8 +83,9 @@ var ProcessosJuridicos = function (_a) {
|
|
|
89
83
|
useEffect(function () {
|
|
90
84
|
if (ctx.type === RequestStatus.Loading) {
|
|
91
85
|
processedRef.current = false;
|
|
86
|
+
setData(function (prevState) { return (__assign(__assign({}, prevState), { processosJuridicosData: __assign(__assign({}, prevState.processosJuridicosData), { isLoaded: false }) })); });
|
|
92
87
|
}
|
|
93
|
-
}, [ctx.type]);
|
|
88
|
+
}, [ctx.type, setData]);
|
|
94
89
|
return (React.createElement(Section, { ctx: ctx, title: "Processos Jur\u00EDdicos", subtitle: "Veja os processos jur\u00EDdicos para este documento.", icon: ProcessosJuridicosIcon, minimized: false, onSuccess: function (data) {
|
|
95
90
|
var _a;
|
|
96
91
|
var qtyProcessos = (_a = data.empresa) === null || _a === void 0 ? void 0 : _a.length;
|
|
@@ -51,8 +51,9 @@ var Protestos = function () {
|
|
|
51
51
|
if (dataUpdated || !ctx.document) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
if (ctx.type === RequestStatus.Error) {
|
|
54
|
+
if (ctx.type === RequestStatus.Error || ctx.type === RequestStatus.Empty) {
|
|
55
55
|
setData(function (prevState) { return (__assign(__assign({}, prevState), { protestosData: { isLoaded: true } })); });
|
|
56
|
+
return;
|
|
56
57
|
}
|
|
57
58
|
var data = ctx.document;
|
|
58
59
|
var registrosText = XPathUtils.select('string(//registros)', data);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const normalizeName: (name: string) => string;
|
|
2
|
-
export declare const similarNames: (name1: string, name2: string) => boolean;
|
|
2
|
+
export declare const similarNames: (name1: string, name2: string, threshold?: number) => boolean;
|
|
3
3
|
export declare const similarProcessos: (name1: string, name2: string) => boolean;
|
|
@@ -3,14 +3,16 @@ import stringSimilarity from 'string-similarity';
|
|
|
3
3
|
export var normalizeName = function (name) {
|
|
4
4
|
if (!name)
|
|
5
5
|
return '';
|
|
6
|
-
return remove(name) // Remove acentos e caracteres especiais
|
|
7
|
-
.toLowerCase() // Converte para
|
|
8
|
-
.replace(
|
|
6
|
+
return remove(name) // Remove acentos e caracteres especiais (como ç → c, á → a)
|
|
7
|
+
.toLowerCase() // Converte para minúsculas
|
|
8
|
+
.replace(/[^\w\s]/g, '') // Remove todos os caracteres que não são letras, números ou espaços (inclusive pontos e barras)
|
|
9
|
+
.replace(/\s+/g, ' ') // Normaliza múltiplos espaços para apenas um
|
|
9
10
|
.trim(); // Remove espaços nas extremidades
|
|
10
11
|
};
|
|
11
|
-
export var similarNames = function (name1, name2) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
export var similarNames = function (name1, name2, threshold) {
|
|
13
|
+
if (threshold === void 0) { threshold = 0.5; }
|
|
14
|
+
var similarityValue = stringSimilarity.compareTwoStrings(name1, name2);
|
|
15
|
+
return similarityValue >= threshold;
|
|
14
16
|
};
|
|
15
17
|
export var similarProcessos = function (name1, name2) {
|
|
16
18
|
var similarity = stringSimilarity.compareTwoStrings(name1, name2);
|