@credithub/harlan-components 1.62.0 → 1.62.1

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.
@@ -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, similarProcessos } from '../../utils/similarNames';
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
- return envolvido.envolvido_tipo === 'Ativo' &&
92
- similarProcessos(normalizeName(envolvido.nome_sem_filtro), empresaNomeNormalizado);
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 similarProcessos(normalizeName(assunto), valid);
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');
@@ -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 letras minúsculas
8
- .replace(/\s+/g, ' ') // Remove espaços extras
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
- var similarity = stringSimilarity.compareTwoStrings(name1, name2);
13
- return similarity >= 0.5;
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);