@credithub/harlan-components 1.83.7 → 1.83.8
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/chart/chartSystem.js +1 -6
- package/dist/components/chart/hooks/useChartData.js +2 -9
- package/dist/components/chart/hooks/useMixedChartData.d.ts +1 -1
- package/dist/components/chart/hooks/useMixedChartData.js +2 -2
- package/dist/components/chart/utils/dataProcessing.d.ts +3 -0
- package/dist/components/chart/utils/dataProcessing.js +57 -29
- package/dist/components/liminar/liminar.js +0 -1
- package/lib/cjs/index.js +70 -45
- package/lib/esm/index.js +70 -45
- package/package.json +1 -1
|
@@ -142,10 +142,6 @@ var ChartSystem = function (_a) {
|
|
|
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
145
|
var lastComplementary = useRef({
|
|
150
146
|
serasa: null,
|
|
151
147
|
boaVista: null
|
|
@@ -158,9 +154,8 @@ var ChartSystem = function (_a) {
|
|
|
158
154
|
serasa: consultaSerasa,
|
|
159
155
|
boaVista: consultaBoaVista
|
|
160
156
|
};
|
|
161
|
-
refetchChart();
|
|
157
|
+
refetchChart();
|
|
162
158
|
}
|
|
163
|
-
// refetchChart fora da lista para não disparar por identidade
|
|
164
159
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
165
160
|
}, [consultaSerasa, consultaBoaVista]);
|
|
166
161
|
var errorMessage = typeof errorChart === 'string' ? new Error(errorChart) : errorChart;
|
|
@@ -27,7 +27,6 @@ var useChartData = function (consultaSerasa, consultaBoaVista) {
|
|
|
27
27
|
}
|
|
28
28
|
return [];
|
|
29
29
|
}, [ctxProtestos.type, ctxProtestos.document, iaOverrides]);
|
|
30
|
-
// aggregate progress from all contexts
|
|
31
30
|
useEffect(function () {
|
|
32
31
|
var _a, _b, _c, _d;
|
|
33
32
|
var parts = [
|
|
@@ -47,10 +46,6 @@ var useChartData = function (consultaSerasa, consultaBoaVista) {
|
|
|
47
46
|
ctxCCF.progress,
|
|
48
47
|
ctxProcessos.progress
|
|
49
48
|
]);
|
|
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
49
|
var lastComplementary = useRef({
|
|
55
50
|
serasa: null,
|
|
56
51
|
boaVista: null
|
|
@@ -63,12 +58,10 @@ var useChartData = function (consultaSerasa, consultaBoaVista) {
|
|
|
63
58
|
serasa: consultaSerasa,
|
|
64
59
|
boaVista: consultaBoaVista
|
|
65
60
|
};
|
|
66
|
-
ctxHistory.refetch();
|
|
61
|
+
ctxHistory.refetch();
|
|
67
62
|
}
|
|
68
|
-
// ctxHistory.refetch fora da lista para não disparar por identidade
|
|
69
63
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
64
|
}, [consultaSerasa, consultaBoaVista]);
|
|
71
|
-
// handle history response
|
|
72
65
|
useEffect(function () {
|
|
73
66
|
var _a;
|
|
74
67
|
if (ctxHistory.type === RequestStatus.Loading) {
|
|
@@ -82,7 +75,7 @@ var useChartData = function (consultaSerasa, consultaBoaVista) {
|
|
|
82
75
|
try {
|
|
83
76
|
var parsed = JSON.parse(ctxHistory.document);
|
|
84
77
|
parsed.protestosCategory = dadosProtestos;
|
|
85
|
-
var processed = processData(parsed, quantidadeProcessos);
|
|
78
|
+
var processed = processData(structuredClone(parsed), quantidadeProcessos);
|
|
86
79
|
setData(processed);
|
|
87
80
|
}
|
|
88
81
|
catch (_b) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChartData, ChartOptions } from 'chart.js';
|
|
2
|
-
import { DataInput, TimeFilter } from '../types/iChart';
|
|
3
2
|
import 'chartjs-adapter-date-fns';
|
|
3
|
+
import { DataInput, TimeFilter } from '../types/iChart';
|
|
4
4
|
export declare const useMixedChartData: (dataInput: DataInput, timeFilter?: TimeFilter) => {
|
|
5
5
|
data: ChartData<"line" | "bar", (number | {
|
|
6
6
|
x: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
1
|
import 'chartjs-adapter-date-fns';
|
|
3
|
-
import {
|
|
2
|
+
import { useMemo } from 'react';
|
|
4
3
|
import { createDatasets, getChartOptions } from '../utils/chartCustomization';
|
|
4
|
+
import { addMissingDateEntries, getEarliestDate, getEndDate, getFilteredStartDate, getUniqueDates } from '../utils/dataManipulation';
|
|
5
5
|
export var useMixedChartData = function (dataInput, timeFilter) {
|
|
6
6
|
if (timeFilter === void 0) { timeFilter = '1m'; }
|
|
7
7
|
return useMemo(function () {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { DataInput } from '../../../components/chart/types/iChart';
|
|
2
|
+
/**
|
|
3
|
+
* Normaliza todos os datasets do DataInput.
|
|
4
|
+
*/
|
|
2
5
|
export declare const processData: (data: DataInput, quantidadeProcessosJuridicos: number) => DataInput;
|
|
3
6
|
export declare function processProtestData(document: Document, iaOverrides?: Record<string, string>): DataInput['protestosCategory'];
|
|
@@ -13,63 +13,91 @@ import { classifyProtestos } from '../../../hooks/useProtestosClassification';
|
|
|
13
13
|
import { converterParaFormatoValido, formatDatePtBrToDate } from '../../../utils/date';
|
|
14
14
|
import XPathUtils from '../../../utils/xpath';
|
|
15
15
|
import { groupBy, sortBy, unique } from 'underscore';
|
|
16
|
+
/**
|
|
17
|
+
* Remove pontos internos com quantidade = 0
|
|
18
|
+
* (mantém o 1.º e o último sempre).
|
|
19
|
+
*/
|
|
20
|
+
var removeZeros = function (current, index, arr) {
|
|
21
|
+
return index === 0 || index === arr.length - 1
|
|
22
|
+
? true
|
|
23
|
+
: ((current === null || current === void 0 ? void 0 : current.quantidade) || 0) > 0;
|
|
24
|
+
};
|
|
25
|
+
/** Mantém apenas break-points: 1.º, último e trocas de quantidade. */
|
|
26
|
+
var removeSameAsNext = function (current, index, arr) {
|
|
27
|
+
if (index === 0 || index === arr.length - 1)
|
|
28
|
+
return true;
|
|
29
|
+
return current.quantidade !== arr[index - 1].quantidade;
|
|
30
|
+
};
|
|
31
|
+
/** Converte chave de agrupamento (string) em timestamp ordenável. */
|
|
32
|
+
var keyToTime = function (key) {
|
|
33
|
+
return new Date(formatDatePtBrToDate(key)).getTime();
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Normaliza todos os datasets do DataInput.
|
|
37
|
+
*/
|
|
16
38
|
export var processData = function (data, quantidadeProcessosJuridicos) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
: ((current === null || current === void 0 ? void 0 : current.quantidade) || 0) > 0;
|
|
21
|
-
};
|
|
22
|
-
var removeSameAsNext = function (current, index, arr) {
|
|
23
|
-
if (index === 0 || index === arr.length - 1)
|
|
24
|
-
return true;
|
|
25
|
-
return current.quantidade !== arr[index + 1].quantidade;
|
|
26
|
-
};
|
|
27
|
-
data.pieChartTotalConfig = {
|
|
28
|
-
processosJuridicos: quantidadeProcessosJuridicos
|
|
29
|
-
};
|
|
39
|
+
// ------------------------------------------------------------------
|
|
40
|
+
// PROTESTOS
|
|
41
|
+
// ------------------------------------------------------------------
|
|
30
42
|
var grouped = groupBy(data.protestos, function (e) { return e.data; });
|
|
31
|
-
data
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return
|
|
43
|
+
// transforma em array ordenado por data asc
|
|
44
|
+
var groupedOrdered = Object.entries(grouped).sort(function (_a, _b) {
|
|
45
|
+
var kA = _a[0];
|
|
46
|
+
var kB = _b[0];
|
|
47
|
+
return keyToTime(kA) - keyToTime(kB);
|
|
48
|
+
});
|
|
49
|
+
data.protestos = groupedOrdered
|
|
50
|
+
.map(function (_a) {
|
|
51
|
+
var registros = _a[1];
|
|
52
|
+
return registros.length === 1
|
|
53
|
+
? registros
|
|
54
|
+
: registros.filter(function (el) { return Number(el.quantidade) > 0; });
|
|
36
55
|
})
|
|
37
56
|
.flat();
|
|
38
57
|
data.protestos = sortBy(unique(data.protestos, function (x) { return x.data; })
|
|
39
58
|
.filter(removeZeros)
|
|
40
59
|
.filter(removeSameAsNext)
|
|
41
|
-
.map(function (info) { return (__assign(__assign({}, info), { data: formatDatePtBrToDate(info.data)
|
|
60
|
+
.map(function (info) { return (__assign(__assign({}, info), { data: formatDatePtBrToDate(info.data) // normaliza p/ ISO local
|
|
61
|
+
})); }), function (info) { return info.data; });
|
|
62
|
+
// ------------------------------------------------------------------
|
|
63
|
+
// CCFs
|
|
64
|
+
// ------------------------------------------------------------------
|
|
42
65
|
data.ccfs = sortBy(unique(data.ccfs, function (x) { return x.data; })
|
|
43
66
|
.filter(removeZeros)
|
|
44
67
|
.filter(removeSameAsNext)
|
|
45
68
|
.map(function (info) { return (__assign(__assign({}, info), { data: formatDatePtBrToDate(info.data) })); }), function (info) { return info.data; });
|
|
69
|
+
// ------------------------------------------------------------------
|
|
70
|
+
// BOA VISTA - não tem quantidade → só formata e filtra vazios
|
|
71
|
+
// ------------------------------------------------------------------
|
|
46
72
|
data.boaVista = data.boaVista
|
|
47
73
|
.map(function (entry) {
|
|
48
74
|
var formattedDate = formatDatePtBrToDate(entry.creation);
|
|
49
75
|
return __assign(__assign({}, entry), { data: formattedDate, creation: undefined });
|
|
50
76
|
})
|
|
51
77
|
.filter(function (entry) { return entry.data; });
|
|
78
|
+
// ------------------------------------------------------------------
|
|
79
|
+
// SERASA
|
|
80
|
+
// ------------------------------------------------------------------
|
|
52
81
|
data.serasa = data.serasa
|
|
53
82
|
.map(function (entry) {
|
|
54
83
|
var formattedDate = formatDatePtBrToDate(entry.creation);
|
|
55
84
|
return __assign(__assign({}, entry), { data: formattedDate, creation: undefined });
|
|
56
85
|
})
|
|
57
86
|
.filter(function (entry) { return entry.data; });
|
|
87
|
+
// ------------------------------------------------------------------
|
|
88
|
+
// DÍVIDAS PÚBLICAS
|
|
89
|
+
// ------------------------------------------------------------------
|
|
58
90
|
data.dividasPublicasGrafico = data.dividasPublicasGrafico
|
|
59
91
|
.map(function (info) { return (__assign(__assign({}, info), { data: formatDatePtBrToDate(info.data), valorTotal: info.total, total: undefined })); })
|
|
60
92
|
.filter(function (info) { return info.data; });
|
|
93
|
+
// ------------------------------------------------------------------
|
|
94
|
+
// PIE-CHART EXTRA
|
|
95
|
+
// ------------------------------------------------------------------
|
|
96
|
+
data.pieChartTotalConfig = {
|
|
97
|
+
processosJuridicos: quantidadeProcessosJuridicos
|
|
98
|
+
};
|
|
61
99
|
return __assign(__assign({}, data), { protestos: data.protestos, ccfs: data.ccfs, boaVista: data.boaVista, serasa: data.serasa, dividasPublicasGrafico: data.dividasPublicasGrafico, pieChartTotalConfig: __assign(__assign({}, data.pieChartTotalConfig), { processosJuridicos: quantidadeProcessosJuridicos }) });
|
|
62
100
|
};
|
|
63
|
-
var obterUltimaData = function (protestos) {
|
|
64
|
-
if (!protestos.length)
|
|
65
|
-
return null;
|
|
66
|
-
var datas = protestos
|
|
67
|
-
.map(function (p) { return new Date(converterParaFormatoValido(p.dataProtesto)).getTime(); })
|
|
68
|
-
.filter(function (d) { return !isNaN(d); });
|
|
69
|
-
return datas.length
|
|
70
|
-
? new Date(Math.max.apply(Math, datas)).toLocaleDateString('pt-BR')
|
|
71
|
-
: null;
|
|
72
|
-
};
|
|
73
101
|
export function processProtestData(document, iaOverrides) {
|
|
74
102
|
var _a = classifyProtestos(document, iaOverrides), protestosDeCredito = _a.protestosDeCredito, protestosDeImposto = _a.protestosDeImposto, protestosGerais = _a.protestosGerais;
|
|
75
103
|
var obterUltimaData = function (protestos) {
|