@credithub/harlan-components 1.83.4 → 1.83.7

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.
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { DataInput } from './types/iChart';
3
- declare const ChartContent: React.FC<{
3
+ declare const _default: React.NamedExoticComponent<{
4
4
  dataInput: DataInput;
5
5
  }>;
6
- export default ChartContent;
6
+ export default _default;
@@ -33,7 +33,7 @@ var ChartContainer = styled.div(templateObject_2 || (templateObject_2 = __makeTe
33
33
  var windowWidth = _a.windowWidth, chartType = _a.chartType;
34
34
  return getWidth(windowWidth, chartType);
35
35
  });
36
- var ChartContent = function (_a) {
36
+ var ChartContentBase = function (_a) {
37
37
  var dataInput = _a.dataInput;
38
38
  var windowWidth = useWindowSize().width;
39
39
  return (React.createElement(React.Fragment, null,
@@ -46,5 +46,5 @@ var ChartContent = function (_a) {
46
46
  React.createElement(MixedChart, { dataInput: dataInput }))),
47
47
  React.createElement(CategoriaProtesto, { dataInput: dataInput.protestosCategory || [] })));
48
48
  };
49
- export default ChartContent;
49
+ export default React.memo(ChartContentBase);
50
50
  var templateObject_1, templateObject_2;
@@ -57,7 +57,7 @@ import { areModulesLoaded } from '../../utils/isGlobalReady';
57
57
  import { formatMoney } from '../../utils/number';
58
58
  import { isCpf } from '../../utils/string';
59
59
  import { Spinner } from 'phosphor-react';
60
- import React, { useContext, useEffect, useMemo, useState } from 'react';
60
+ import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
61
61
  import styled from 'styled-components';
62
62
  import useToggle from '../../hooks/useToggle';
63
63
  import { ConsultasComplementaresContext } from '../consultasComplementares';
@@ -98,7 +98,7 @@ var ChartSystem = function (_a) {
98
98
  var consultaBoaVista = (_e = (_d = ctxConsultasComplementares === null || ctxConsultasComplementares === void 0 ? void 0 : ctxConsultasComplementares.consultasComplementares) === null || _d === void 0 ? void 0 : _d.refinBoaVista) === null || _e === void 0 ? void 0 : _e.data;
99
99
  var _o = useState({}), loadingButtons = _o[0], setLoadingButtons = _o[1];
100
100
  var productsPrices = getProductsPrices(isCpf(documento));
101
- var handleOnClick = function (key) {
101
+ var handleOnClick = useCallback(function (key) {
102
102
  return function () { return __awaiter(void 0, void 0, void 0, function () {
103
103
  var callback;
104
104
  return __generator(this, function (_a) {
@@ -139,14 +139,30 @@ var ChartSystem = function (_a) {
139
139
  }
140
140
  });
141
141
  }); };
142
- };
142
+ }, [loadingButtons, hasCredits, productsPrices, setConsultasComplementares]);
143
143
  var _p = useChartData(consultaSerasa, consultaBoaVista), chartData = _p.data, isLoadingChart = _p.isLoading, errorChart = _p.error, refetchChart = _p.refetch, chartDataProgress = _p.loadingProgress;
144
144
  var _q = useDividasPublicas(), quantidadeDividas = _q.quantidade, valorTotalDividas = _q.valorTotal, ultimaOcorrenciaDividas = _q.ultimaOcorrencia, dividasProgress = _q.loadingProgress;
145
+ /**
146
+ * Refaz o histórico apenas quando muda o OBJETO de resposta (não a função refetch).
147
+ * Usamos um ref para lembrar o último valor e evitar chamadas repetidas.
148
+ */
149
+ var lastComplementary = useRef({
150
+ serasa: null,
151
+ boaVista: null
152
+ });
145
153
  useEffect(function () {
146
- if (consultaSerasa || consultaBoaVista) {
147
- refetchChart();
154
+ var serasaChanged = consultaSerasa !== lastComplementary.current.serasa;
155
+ var boaVistaChanged = consultaBoaVista !== lastComplementary.current.boaVista;
156
+ if (serasaChanged || boaVistaChanged) {
157
+ lastComplementary.current = {
158
+ serasa: consultaSerasa,
159
+ boaVista: consultaBoaVista
160
+ };
161
+ refetchChart(); // executa só UMA vez por nova consulta
148
162
  }
149
- }, [consultaSerasa, consultaBoaVista, refetchChart]);
163
+ // refetchChart fora da lista para não disparar por identidade
164
+ // eslint-disable-next-line react-hooks/exhaustive-deps
165
+ }, [consultaSerasa, consultaBoaVista]);
150
166
  var errorMessage = typeof errorChart === 'string' ? new Error(errorChart) : errorChart;
151
167
  var isOpen = useToggle(true)[0];
152
168
  var quantidadeProtestos = ((_g = (_f = chartData === null || chartData === void 0 ? void 0 : chartData.protestos) === null || _f === void 0 ? void 0 : _f[(chartData === null || chartData === void 0 ? void 0 : chartData.protestos.length) - 1]) === null || _g === void 0 ? void 0 : _g.quantidade) || 0;
@@ -3,5 +3,5 @@ import { DataInput } from '../types/iChart';
3
3
  interface MixedChartProps {
4
4
  dataInput: DataInput;
5
5
  }
6
- declare const MixedChart: React.FC<MixedChartProps>;
7
- export default MixedChart;
6
+ declare const _default: React.NamedExoticComponent<MixedChartProps>;
7
+ export default _default;
@@ -48,5 +48,5 @@ var MixedChart = function (_a) {
48
48
  : '1 Mês')); })),
49
49
  React.createElement(Chart, { className: "mixed-chart", type: chartType, data: data, options: options })));
50
50
  };
51
- export default MixedChart;
51
+ export default React.memo(MixedChart);
52
52
  var templateObject_1, templateObject_2, templateObject_3;
@@ -3,5 +3,5 @@ import { DataInput } from '../types/iChart';
3
3
  interface PieChartProps {
4
4
  dataInput: DataInput;
5
5
  }
6
- declare const PieChart: React.FC<PieChartProps>;
7
- export default PieChart;
6
+ declare const _default: React.NamedExoticComponent<PieChartProps>;
7
+ export default _default;
@@ -6,4 +6,4 @@ var PieChart = function (_a) {
6
6
  var _b = usePieChartData(dataInput), data = _b.data, options = _b.options;
7
7
  return React.createElement(Pie, { className: "pie-chart", data: data, options: options });
8
8
  };
9
- export default PieChart;
9
+ export default React.memo(PieChart);
@@ -3,5 +3,5 @@ import { DataInput } from '../types/iChart';
3
3
  interface ProtestoCategory {
4
4
  dataInput: DataInput['protestosCategory'];
5
5
  }
6
- declare const CategoriaProtesto: React.FC<ProtestoCategory>;
7
- export default CategoriaProtesto;
6
+ declare const _default: React.NamedExoticComponent<ProtestoCategory>;
7
+ export default _default;
@@ -13,5 +13,5 @@ var CategoriaProtesto = function (_a) {
13
13
  return (React.createElement(ChartContainer, null,
14
14
  React.createElement(Bar, { className: "categoria-protesto", data: data, options: options })));
15
15
  };
16
- export default CategoriaProtesto;
16
+ export default React.memo(CategoriaProtesto);
17
17
  var templateObject_1;
@@ -1,12 +1,13 @@
1
1
  import { Queries, RequestStatus } from '../../../components/webservice';
2
2
  import { useGlobalData } from '../../../contexts/globalDataContext';
3
- import { useContext, useEffect, useMemo, useState } from 'react';
3
+ import { useContext, useEffect, useMemo, useRef, useState } from 'react';
4
4
  import { processData, processProtestData } from '../utils/dataProcessing';
5
5
  var useChartData = function (consultaSerasa, consultaBoaVista) {
6
6
  var _a;
7
7
  var _b = useState(null), data = _b[0], setData = _b[1];
8
8
  var _c = useState(null), errorState = _c[0], setErrorState = _c[1];
9
- var _d = useState(0), loadingProgress = _d[0], setLoadingProgress = _d[1];
9
+ var _d = useState(0), loadingProgress = _d[0], _setLoadingProgress = _d[1];
10
+ var lastProgress = useRef(0);
10
11
  var ctxHistory = useContext(Queries.GraficosAnaliticos);
11
12
  var ctxProtestos = useContext(Queries.Protestos);
12
13
  var ctxCCF = useContext(Queries.CCF);
@@ -36,19 +37,37 @@ var useChartData = function (consultaSerasa, consultaBoaVista) {
36
37
  (_d = ctxProcessos.progress) !== null && _d !== void 0 ? _d : 0
37
38
  ];
38
39
  var avg = parts.reduce(function (sum, p) { return sum + p; }, 0) / parts.length;
39
- setLoadingProgress(avg);
40
+ if (avg === 100 || Math.abs(avg - lastProgress.current) >= 10) {
41
+ lastProgress.current = avg;
42
+ _setLoadingProgress(avg);
43
+ }
40
44
  }, [
41
45
  ctxHistory.progress,
42
46
  ctxProtestos.progress,
43
47
  ctxCCF.progress,
44
48
  ctxProcessos.progress
45
49
  ]);
46
- // trigger refetch when complementary queries change
50
+ /**
51
+ * Refaz o histórico apenas quando muda o OBJETO de resposta (não a função refetch).
52
+ * Usamos um ref para lembrar o último valor e evitar chamadas repetidas.
53
+ */
54
+ var lastComplementary = useRef({
55
+ serasa: null,
56
+ boaVista: null
57
+ });
47
58
  useEffect(function () {
48
- if (consultaSerasa || consultaBoaVista) {
49
- ctxHistory.refetch();
59
+ var serasaChanged = consultaSerasa !== lastComplementary.current.serasa;
60
+ var boaVistaChanged = consultaBoaVista !== lastComplementary.current.boaVista;
61
+ if (serasaChanged || boaVistaChanged) {
62
+ lastComplementary.current = {
63
+ serasa: consultaSerasa,
64
+ boaVista: consultaBoaVista
65
+ };
66
+ ctxHistory.refetch(); // executa só UMA vez por nova consulta
50
67
  }
51
- }, [consultaSerasa, consultaBoaVista, ctxHistory.refetch]);
68
+ // ctxHistory.refetch fora da lista para não disparar por identidade
69
+ // eslint-disable-next-line react-hooks/exhaustive-deps
70
+ }, [consultaSerasa, consultaBoaVista]);
52
71
  // handle history response
53
72
  useEffect(function () {
54
73
  var _a;
@@ -190,9 +190,9 @@ var Liminar = function (_a) {
190
190
  return;
191
191
  var fetch = function () { return __awaiter(void 0, void 0, void 0, function () {
192
192
  var dossie, processosJuridicos, depsLoaded, newIds, hash, indiciosApi, indiciosDeLiminarProtestosDoPassado, protestosDoPassadoIds, _a, possuiIndiciosDeLiminarProtestosDoPassado, protestosIds, finalStatus, descricaoLiminar;
193
- var _b, _c, _d;
194
- return __generator(this, function (_e) {
195
- switch (_e.label) {
193
+ var _b, _c;
194
+ return __generator(this, function (_d) {
195
+ switch (_d.label) {
196
196
  case 0:
197
197
  dossie = globalData === null || globalData === void 0 ? void 0 : globalData.dossie;
198
198
  processosJuridicos = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData;
@@ -214,11 +214,10 @@ var Liminar = function (_a) {
214
214
  indiciosApi = ((_c = ctx.document) === null || _c === void 0 ? void 0 : _c.indiciosDeLiminar) === true;
215
215
  indiciosDeLiminarProtestosDoPassado = false;
216
216
  protestosDoPassadoIds = '';
217
- if (!((_d = globalData === null || globalData === void 0 ? void 0 : globalData.documentHistory) === null || _d === void 0 ? void 0 : _d.protestoLiminar)) return [3 /*break*/, 2];
218
217
  setIsLoadingLiminarProtestosDoPassado(true);
219
218
  return [4 /*yield*/, fetchLiminarProtestosDoPassado()];
220
219
  case 1:
221
- _a = _e.sent(), possuiIndiciosDeLiminarProtestosDoPassado = _a.possuiIndiciosDeLiminarProtestosDoPassado, protestosIds = _a.protestosDoPassadoIds;
220
+ _a = _d.sent(), possuiIndiciosDeLiminarProtestosDoPassado = _a.possuiIndiciosDeLiminarProtestosDoPassado, protestosIds = _a.protestosDoPassadoIds;
222
221
  if (possuiIndiciosDeLiminarProtestosDoPassado) {
223
222
  origensDetectadas.push('Liminar no Cenprot');
224
223
  indiciosDeLiminarProtestosDoPassado =
@@ -226,8 +225,6 @@ var Liminar = function (_a) {
226
225
  protestosDoPassadoIds = protestosIds.join(',');
227
226
  }
228
227
  setIsLoadingLiminarProtestosDoPassado(false);
229
- _e.label = 2;
230
- case 2:
231
228
  finalStatus = indiciosApi ||
232
229
  processosComAssuntoValido.length ||
233
230
  indiciosDeLiminarProtestosDoPassado
@@ -255,6 +252,7 @@ var Liminar = function (_a) {
255
252
  }
256
253
  });
257
254
  }); };
255
+ console.log('Is financial:', isFinancial);
258
256
  if (isFinancial)
259
257
  fetch();
260
258
  }, [
@@ -7,7 +7,7 @@ interface LiminarProtestosDoPassadoProps {
7
7
  *
8
8
  * Regras (2025‑07‑01)
9
9
  * • Um instrumento é **oculto** se a consulta a `PDFPROTESTO.PDF` **não** retornar PDF.
10
- * • Se todos ainda possuem PDF, não há indício de liminar.
10
+ * • Se todos ainda possuem PDF, não há indício de liminar. (!?)
11
11
  *
12
12
  * Esta versão limita a concorrência (10 chamadas em paralelo) e aplica
13
13
  * timeout defensivo para cada requisição.
@@ -44,7 +44,7 @@ import { useGlobalData } from '../../contexts/globalDataContext';
44
44
  *
45
45
  * Regras (2025‑07‑01)
46
46
  * • Um instrumento é **oculto** se a consulta a `PDFPROTESTO.PDF` **não** retornar PDF.
47
- * • Se todos ainda possuem PDF, não há indício de liminar.
47
+ * • Se todos ainda possuem PDF, não há indício de liminar. (!?)
48
48
  *
49
49
  * Esta versão limita a concorrência (10 chamadas em paralelo) e aplica
50
50
  * timeout defensivo para cada requisição.
@@ -56,7 +56,7 @@ var useLiminarProtestosDoPassado = function (_a) {
56
56
  /** Máximo de requisições simultâneas ao endpoint de PDF. */
57
57
  var MAX_CONCURRENT = 10;
58
58
  /** Timeout (ms) por requisição individual ao PDF. */
59
- var PDF_TIMEOUT = 8000;
59
+ var PDF_TIMEOUT = 80000;
60
60
  /**
61
61
  * Checa se um `nm_chave` ainda possui PDF no CENPROT.
62
62
  * Retorna `true` quando há PDF, `false` caso contrário ou erro.
@@ -113,11 +113,11 @@ var RefinSerasa = function (_a) {
113
113
  var valorTotalPendencias = useMemo(function () {
114
114
  var _a, _b, _c, _d, _e, _f, _g, _h;
115
115
  var resumo = (_b = (_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.dados) === null || _b === void 0 ? void 0 : _b.resumo;
116
- return ((Number((_d = (_c = resumo === null || resumo === void 0 ? void 0 : resumo.pefin) === null || _c === void 0 ? void 0 : _c.valor_total) === null || _d === void 0 ? void 0 : _d.replace('.', '').replace(',', '.')) ||
116
+ return ((Number((_d = (_c = resumo === null || resumo === void 0 ? void 0 : resumo.pefin) === null || _c === void 0 ? void 0 : _c.valor_total) === null || _d === void 0 ? void 0 : _d.replace(/\./g, '').replace(',', '.')) ||
117
117
  0) +
118
- (Number((_f = (_e = resumo === null || resumo === void 0 ? void 0 : resumo.refin) === null || _e === void 0 ? void 0 : _e.valor_total) === null || _f === void 0 ? void 0 : _f.replace('.', '').replace(',', '.')) ||
118
+ (Number((_f = (_e = resumo === null || resumo === void 0 ? void 0 : resumo.refin) === null || _e === void 0 ? void 0 : _e.valor_total) === null || _f === void 0 ? void 0 : _f.replace(/\./g, '').replace(',', '.')) ||
119
119
  0) +
120
- (Number((_h = (_g = resumo === null || resumo === void 0 ? void 0 : resumo.pendencias_vencidas) === null || _g === void 0 ? void 0 : _g.valor_total) === null || _h === void 0 ? void 0 : _h.replace('.', '').replace(',', '.')) || 0));
120
+ (Number((_h = (_g = resumo === null || resumo === void 0 ? void 0 : resumo.pendencias_vencidas) === null || _g === void 0 ? void 0 : _g.valor_total) === null || _h === void 0 ? void 0 : _h.replace(/\./g, '').replace(',', '.')) || 0));
121
121
  }, [response === null || response === void 0 ? void 0 : response.document]);
122
122
  var description = totalPendencias === 0
123
123
  ? 'Não há ocorrência de Pefin/Refin Serasa'