@credithub/harlan-components 1.13.8 → 1.14.0
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/lib/cjs/components/chart/chartContent.d.ts +3 -4
- package/lib/cjs/components/chart/chartContent.js +40 -72
- package/lib/cjs/components/chart/chartSystem.d.ts +6 -0
- package/lib/cjs/components/chart/chartSystem.js +50 -0
- package/lib/cjs/components/chart/components/MixedChart.d.ts +7 -0
- package/lib/cjs/components/chart/components/MixedChart.js +55 -0
- package/lib/cjs/components/chart/components/PieChart.d.ts +7 -0
- package/lib/cjs/components/chart/components/PieChart.js +14 -0
- package/lib/cjs/components/chart/components/categoryProtestos.d.ts +7 -0
- package/lib/cjs/components/chart/components/categoryProtestos.js +22 -0
- package/lib/cjs/components/chart/hooks/useCategoryProtestos.d.ts +6 -0
- package/lib/cjs/components/chart/hooks/useCategoryProtestos.js +75 -0
- package/lib/cjs/components/chart/hooks/useChartData.d.ts +8 -0
- package/lib/cjs/components/chart/hooks/useChartData.js +61 -0
- package/lib/cjs/components/chart/hooks/useMixedChartData.d.ts +10 -0
- package/lib/cjs/components/chart/hooks/useMixedChartData.js +47 -0
- package/lib/cjs/components/chart/hooks/usePieChartData.d.ts +6 -0
- package/lib/cjs/components/chart/hooks/usePieChartData.js +93 -0
- package/lib/cjs/components/chart/quantityResult.js +22 -21
- package/lib/cjs/components/chart/types/iChart.d.ts +58 -0
- package/lib/cjs/components/chart/utils/chartCustomization.d.ts +7 -0
- package/lib/cjs/components/chart/utils/chartCustomization.js +159 -0
- package/lib/cjs/components/chart/utils/chartUtils.d.ts +11 -0
- package/lib/cjs/components/chart/utils/chartUtils.js +46 -0
- package/lib/cjs/components/chart/utils/dataManipulation.d.ts +10 -0
- package/lib/cjs/components/chart/utils/dataManipulation.js +106 -0
- package/lib/cjs/components/chart/utils/dataProcessing.d.ts +3 -0
- package/lib/cjs/components/chart/utils/dataProcessing.js +94 -0
- package/lib/cjs/components/common/button.js +1 -1
- package/lib/cjs/components/dossie/carrousel/carrousel.js +1 -1
- package/lib/cjs/components/dossie/companyLogo/companyLogo.js +7 -8
- package/lib/cjs/components/dossie/dossie.js +6 -5
- package/lib/cjs/components/dossie/summary/cardsAndProducts.js +2 -2
- package/lib/cjs/components/dossie/summary/summary.js +12 -9
- package/lib/cjs/components/interface/theme.d.ts +6 -0
- package/lib/cjs/components/interface/theme.js +6 -0
- package/lib/cjs/consultaSimples.js +4 -2
- package/lib/cjs/hooks/useWindowSize.d.ts +4 -0
- package/lib/cjs/hooks/useWindowSize.js +23 -0
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/index.js +5 -4
- package/lib/cjs/utils/fillMissingData.d.ts +6 -0
- package/lib/cjs/utils/fillMissingData.js +16 -0
- package/lib/cjs/utils/getUniqueDates.d.ts +5 -0
- package/lib/cjs/utils/getUniqueDates.js +13 -0
- package/lib/esm/components/chart/chartContent.d.ts +3 -4
- package/lib/esm/components/chart/chartContent.js +41 -50
- package/lib/esm/components/chart/chartSystem.d.ts +6 -0
- package/lib/esm/components/chart/chartSystem.js +45 -0
- package/lib/esm/components/chart/components/MixedChart.d.ts +7 -0
- package/lib/esm/components/chart/components/MixedChart.js +30 -0
- package/lib/esm/components/chart/components/PieChart.d.ts +7 -0
- package/lib/esm/components/chart/components/PieChart.js +9 -0
- package/lib/esm/components/chart/components/categoryProtestos.d.ts +7 -0
- package/lib/esm/components/chart/components/categoryProtestos.js +17 -0
- package/lib/esm/components/chart/hooks/useCategoryProtestos.d.ts +6 -0
- package/lib/esm/components/chart/hooks/useCategoryProtestos.js +71 -0
- package/lib/esm/components/chart/hooks/useChartData.d.ts +8 -0
- package/lib/esm/components/chart/hooks/useChartData.js +59 -0
- package/lib/esm/components/chart/hooks/useMixedChartData.d.ts +10 -0
- package/lib/esm/components/chart/hooks/useMixedChartData.js +43 -0
- package/lib/esm/components/chart/hooks/usePieChartData.d.ts +6 -0
- package/lib/esm/components/chart/hooks/usePieChartData.js +89 -0
- package/lib/esm/components/chart/quantityResult.js +23 -22
- package/lib/esm/components/chart/types/iChart.d.ts +58 -0
- package/lib/esm/components/chart/utils/chartCustomization.d.ts +7 -0
- package/lib/esm/components/chart/utils/chartCustomization.js +154 -0
- package/lib/esm/components/chart/utils/chartUtils.d.ts +11 -0
- package/lib/esm/components/chart/utils/chartUtils.js +37 -0
- package/lib/esm/components/chart/utils/dataManipulation.d.ts +10 -0
- package/lib/esm/components/chart/utils/dataManipulation.js +97 -0
- package/lib/esm/components/chart/utils/dataProcessing.d.ts +3 -0
- package/lib/esm/components/chart/utils/dataProcessing.js +86 -0
- package/lib/esm/components/common/button.js +1 -1
- package/lib/esm/components/dossie/carrousel/carrousel.js +1 -1
- package/lib/esm/components/dossie/companyLogo/companyLogo.js +7 -8
- package/lib/esm/components/dossie/dossie.js +6 -5
- package/lib/esm/components/dossie/summary/cardsAndProducts.js +2 -2
- package/lib/esm/components/dossie/summary/summary.js +12 -9
- package/lib/esm/components/interface/theme.d.ts +6 -0
- package/lib/esm/components/interface/theme.js +6 -0
- package/lib/esm/consultaSimples.js +6 -4
- package/lib/esm/hooks/useWindowSize.d.ts +4 -0
- package/lib/esm/hooks/useWindowSize.js +19 -0
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +4 -1
- package/lib/esm/utils/fillMissingData.d.ts +6 -0
- package/lib/esm/utils/fillMissingData.js +12 -0
- package/lib/esm/utils/getUniqueDates.d.ts +5 -0
- package/lib/esm/utils/getUniqueDates.js +9 -0
- package/package.json +8 -1
- package/lib/cjs/components/chart/categoryProtestos.d.ts +0 -4
- package/lib/cjs/components/chart/categoryProtestos.js +0 -97
- package/lib/cjs/components/chart/chartHelper.d.ts +0 -7
- package/lib/cjs/components/chart/chartHelper.js +0 -66
- package/lib/cjs/components/chart/customChart.d.ts +0 -10
- package/lib/cjs/components/chart/customChart.js +0 -142
- package/lib/cjs/components/chart/getUniqueDates.d.ts +0 -2
- package/lib/cjs/components/chart/getUniqueDates.js +0 -8
- package/lib/cjs/components/chart/plotly/barChartDataStrategy.d.ts +0 -14
- package/lib/cjs/components/chart/plotly/barChartDataStrategy.js +0 -152
- package/lib/cjs/components/chart/plotly/baseChartDataStrategy.d.ts +0 -8
- package/lib/cjs/components/chart/plotly/baseChartDataStrategy.js +0 -31
- package/lib/cjs/components/chart/plotly/getSeries.d.ts +0 -3
- package/lib/cjs/components/chart/plotly/getSeries.js +0 -35
- package/lib/cjs/components/chart/plotly/iChartDataStrategy.d.ts +0 -35
- package/lib/cjs/components/chart/plotly/index.d.ts +0 -5
- package/lib/cjs/components/chart/plotly/index.js +0 -20
- package/lib/cjs/components/chart/plotly/layoutLineBarChart.d.ts +0 -39
- package/lib/cjs/components/chart/plotly/layoutLineBarChart.js +0 -67
- package/lib/cjs/components/chart/plotly/lineChartDataStrategy.d.ts +0 -17
- package/lib/cjs/components/chart/plotly/lineChartDataStrategy.js +0 -198
- package/lib/cjs/components/chart/plotly/pieChartDataStrategy.d.ts +0 -5
- package/lib/cjs/components/chart/plotly/pieChartDataStrategy.js +0 -45
- package/lib/cjs/components/chart/plotly/types.d.ts +0 -40
- package/lib/cjs/components/chart/plotly/types.js +0 -2
- package/lib/cjs/components/chart/processChartData.d.ts +0 -5
- package/lib/cjs/components/chart/processChartData.js +0 -41
- package/lib/cjs/components/chart/useCalculation.d.ts +0 -6
- package/lib/cjs/components/chart/useCalculation.js +0 -12
- package/lib/cjs/components/chart/useDividasPublicas.d.ts +0 -5
- package/lib/cjs/components/chart/useDividasPublicas.js +0 -26
- package/lib/cjs/components/chart/useUltimaOcorrenciaCCF.d.ts +0 -2
- package/lib/cjs/components/chart/useUltimaOcorrenciaCCF.js +0 -20
- package/lib/esm/components/chart/categoryProtestos.d.ts +0 -4
- package/lib/esm/components/chart/categoryProtestos.js +0 -69
- package/lib/esm/components/chart/chartHelper.d.ts +0 -7
- package/lib/esm/components/chart/chartHelper.js +0 -60
- package/lib/esm/components/chart/customChart.d.ts +0 -10
- package/lib/esm/components/chart/customChart.js +0 -112
- package/lib/esm/components/chart/getUniqueDates.d.ts +0 -2
- package/lib/esm/components/chart/getUniqueDates.js +0 -4
- package/lib/esm/components/chart/plotly/barChartDataStrategy.d.ts +0 -14
- package/lib/esm/components/chart/plotly/barChartDataStrategy.js +0 -149
- package/lib/esm/components/chart/plotly/baseChartDataStrategy.d.ts +0 -8
- package/lib/esm/components/chart/plotly/baseChartDataStrategy.js +0 -28
- package/lib/esm/components/chart/plotly/getSeries.d.ts +0 -3
- package/lib/esm/components/chart/plotly/getSeries.js +0 -31
- package/lib/esm/components/chart/plotly/iChartDataStrategy.d.ts +0 -35
- package/lib/esm/components/chart/plotly/index.d.ts +0 -5
- package/lib/esm/components/chart/plotly/index.js +0 -5
- package/lib/esm/components/chart/plotly/layoutLineBarChart.d.ts +0 -39
- package/lib/esm/components/chart/plotly/layoutLineBarChart.js +0 -64
- package/lib/esm/components/chart/plotly/lineChartDataStrategy.d.ts +0 -17
- package/lib/esm/components/chart/plotly/lineChartDataStrategy.js +0 -195
- package/lib/esm/components/chart/plotly/pieChartDataStrategy.d.ts +0 -5
- package/lib/esm/components/chart/plotly/pieChartDataStrategy.js +0 -42
- package/lib/esm/components/chart/plotly/types.d.ts +0 -40
- package/lib/esm/components/chart/plotly/types.js +0 -1
- package/lib/esm/components/chart/processChartData.d.ts +0 -5
- package/lib/esm/components/chart/processChartData.js +0 -37
- package/lib/esm/components/chart/useCalculation.d.ts +0 -6
- package/lib/esm/components/chart/useCalculation.js +0 -8
- package/lib/esm/components/chart/useDividasPublicas.d.ts +0 -5
- package/lib/esm/components/chart/useDividasPublicas.js +0 -21
- package/lib/esm/components/chart/useUltimaOcorrenciaCCF.d.ts +0 -2
- package/lib/esm/components/chart/useUltimaOcorrenciaCCF.js +0 -15
- /package/lib/cjs/components/chart/{plotly/iChartDataStrategy.js → types/iChart.js} +0 -0
- /package/lib/esm/components/chart/{plotly/iChartDataStrategy.js → types/iChart.js} +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useContext, useEffect, useState, useMemo } from "react";
|
|
2
|
+
import { useQuery, Queries, RequestStatus } from "../../../components/webservice";
|
|
3
|
+
import { processData, processProtestData } from "../utils/dataProcessing";
|
|
4
|
+
var useChartData = function (documento) {
|
|
5
|
+
var _a = useState(null), data = _a[0], setData = _a[1];
|
|
6
|
+
var _b = useState(null), errorState = _b[0], setErrorState = _b[1];
|
|
7
|
+
var _c = useQuery("SELECT FROM 'DOCUMENTHISTORY'.'BASICHISTORY'", {
|
|
8
|
+
documento: documento,
|
|
9
|
+
}), response = _c.response, queryError = _c.error, isLoading = _c.isLoading, refetch = _c.refetch;
|
|
10
|
+
var ctxProtestos = useContext(Queries.Protestos);
|
|
11
|
+
var ctxCCF = useContext(Queries.CCF);
|
|
12
|
+
var ctxProcessosJuridicos = useContext(Queries.ProcessosJuridicos);
|
|
13
|
+
var quantidadeProcessosJuridicos = useMemo(function () {
|
|
14
|
+
var _a;
|
|
15
|
+
if ((ctxProcessosJuridicos === null || ctxProcessosJuridicos === void 0 ? void 0 : ctxProcessosJuridicos.type) === RequestStatus.Success &&
|
|
16
|
+
((_a = ctxProcessosJuridicos.document) === null || _a === void 0 ? void 0 : _a.empresa)) {
|
|
17
|
+
return ctxProcessosJuridicos.document.empresa.length;
|
|
18
|
+
}
|
|
19
|
+
return 0;
|
|
20
|
+
}, [ctxProcessosJuridicos]);
|
|
21
|
+
var liveQueriesIsFinish = useMemo(function () {
|
|
22
|
+
return [
|
|
23
|
+
ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.type,
|
|
24
|
+
ctxCCF === null || ctxCCF === void 0 ? void 0 : ctxCCF.type,
|
|
25
|
+
ctxProcessosJuridicos === null || ctxProcessosJuridicos === void 0 ? void 0 : ctxProcessosJuridicos.type,
|
|
26
|
+
].every(function (status) { return status !== RequestStatus.Loading; });
|
|
27
|
+
}, [ctxProtestos, ctxCCF, ctxProcessosJuridicos]);
|
|
28
|
+
var dadosProtestos = useMemo(function () {
|
|
29
|
+
if ((ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.type) === RequestStatus.Success && ctxProtestos.data) {
|
|
30
|
+
return processProtestData(ctxProtestos.document);
|
|
31
|
+
}
|
|
32
|
+
return [];
|
|
33
|
+
}, [ctxProtestos]);
|
|
34
|
+
useEffect(function () {
|
|
35
|
+
if (!isLoading &&
|
|
36
|
+
!queryError &&
|
|
37
|
+
(response === null || response === void 0 ? void 0 : response.document) &&
|
|
38
|
+
liveQueriesIsFinish) {
|
|
39
|
+
try {
|
|
40
|
+
var parsedData = JSON.parse(response.document);
|
|
41
|
+
parsedData.protestosCategory = dadosProtestos;
|
|
42
|
+
var processedData = processData(parsedData, quantidadeProcessosJuridicos);
|
|
43
|
+
setData(processedData);
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
console.error("Erro ao processar os dados", e);
|
|
47
|
+
setErrorState("Erro ao processar os dados");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}, [
|
|
51
|
+
isLoading,
|
|
52
|
+
response,
|
|
53
|
+
queryError,
|
|
54
|
+
liveQueriesIsFinish,
|
|
55
|
+
quantidadeProcessosJuridicos,
|
|
56
|
+
]);
|
|
57
|
+
return { data: data, isLoading: isLoading, error: errorState || queryError, refetch: refetch };
|
|
58
|
+
};
|
|
59
|
+
export default useChartData;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ChartData, ChartOptions } from "chart.js";
|
|
2
|
+
import { DataInput, TimeFilter } from "../types/iChart";
|
|
3
|
+
import "chartjs-adapter-date-fns";
|
|
4
|
+
export declare const useMixedChartData: (dataInput: DataInput, timeFilter?: TimeFilter) => {
|
|
5
|
+
data: ChartData<"line" | "bar", (number | {
|
|
6
|
+
x: string;
|
|
7
|
+
y: number;
|
|
8
|
+
})[], string>;
|
|
9
|
+
options: ChartOptions<"line" | "bar">;
|
|
10
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import "chartjs-adapter-date-fns";
|
|
3
|
+
import { getEndDate, getUniqueDates, addMissingDateEntries, getFilteredStartDate, getEarliestDate, } from "../utils/dataManipulation";
|
|
4
|
+
import { createDatasets, getChartOptions } from "../utils/chartCustomization";
|
|
5
|
+
export var useMixedChartData = function (dataInput, timeFilter) {
|
|
6
|
+
if (timeFilter === void 0) { timeFilter = "1m"; }
|
|
7
|
+
return useMemo(function () {
|
|
8
|
+
var filteredStartDate = getFilteredStartDate(timeFilter, dataInput);
|
|
9
|
+
var endDate = getEndDate();
|
|
10
|
+
var fullDataStartDate = getEarliestDate(dataInput);
|
|
11
|
+
var fullProcessedData = {
|
|
12
|
+
protestos: addMissingDateEntries(dataInput.protestos, fullDataStartDate, endDate),
|
|
13
|
+
ccfs: addMissingDateEntries(dataInput.ccfs, fullDataStartDate, endDate),
|
|
14
|
+
serasa: addMissingDateEntries(dataInput.serasa, fullDataStartDate, endDate),
|
|
15
|
+
boaVista: addMissingDateEntries(dataInput.boaVista, fullDataStartDate, endDate),
|
|
16
|
+
dividasPublicasGrafico: addMissingDateEntries(dataInput.dividasPublicasGrafico, fullDataStartDate, endDate),
|
|
17
|
+
};
|
|
18
|
+
var processedData = {
|
|
19
|
+
protestos: fullProcessedData.protestos.filter(function (d) { return new Date(d.data) >= filteredStartDate; }),
|
|
20
|
+
ccfs: fullProcessedData.ccfs.filter(function (d) { return new Date(d.data) >= filteredStartDate; }),
|
|
21
|
+
serasa: fullProcessedData.serasa.filter(function (d) { return new Date(d.data) >= filteredStartDate; }),
|
|
22
|
+
boaVista: fullProcessedData.boaVista.filter(function (d) { return new Date(d.data) >= filteredStartDate; }),
|
|
23
|
+
dividasPublicasGrafico: fullProcessedData.dividasPublicasGrafico.filter(function (d) { return new Date(d.data) >= filteredStartDate; }),
|
|
24
|
+
};
|
|
25
|
+
var uniqueDates = getUniqueDates(processedData);
|
|
26
|
+
var datasets = createDatasets(processedData, uniqueDates, timeFilter);
|
|
27
|
+
var options = getChartOptions(timeFilter);
|
|
28
|
+
if (!options.plugins) {
|
|
29
|
+
options.plugins = {};
|
|
30
|
+
}
|
|
31
|
+
options.plugins.datalabels = {
|
|
32
|
+
display: false,
|
|
33
|
+
};
|
|
34
|
+
var labels = uniqueDates;
|
|
35
|
+
return {
|
|
36
|
+
data: {
|
|
37
|
+
labels: labels,
|
|
38
|
+
datasets: datasets,
|
|
39
|
+
},
|
|
40
|
+
options: options,
|
|
41
|
+
};
|
|
42
|
+
}, [dataInput, timeFilter]);
|
|
43
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useWindowSize } from "../../../hooks/useWindowSize";
|
|
3
|
+
export var usePieChartData = function (dataInput) {
|
|
4
|
+
var width = useWindowSize().width;
|
|
5
|
+
return useMemo(function () {
|
|
6
|
+
var _a;
|
|
7
|
+
var getLastValue = function (arr) { var _a; return arr.length > 0 ? (_a = arr[arr.length - 1].quantidade) !== null && _a !== void 0 ? _a : 0 : 0; };
|
|
8
|
+
var totalProtestos = getLastValue(dataInput.protestos);
|
|
9
|
+
var totalCCFs = getLastValue(dataInput.ccfs);
|
|
10
|
+
var totalSerasa = getLastValue(dataInput.serasa);
|
|
11
|
+
var totalBoaVista = getLastValue(dataInput.boaVista);
|
|
12
|
+
var totalDividasPublicas = getLastValue(dataInput.dividasPublicasGrafico);
|
|
13
|
+
var processosJuridicos = (_a = dataInput.pieChartTotalConfig) === null || _a === void 0 ? void 0 : _a.processosJuridicos;
|
|
14
|
+
var chartData = {
|
|
15
|
+
labels: [
|
|
16
|
+
"Protestos",
|
|
17
|
+
"Cheques Devolvidos",
|
|
18
|
+
"Pefin/Refin Serasa",
|
|
19
|
+
"Pefin/Refin Boa Vista",
|
|
20
|
+
"Dívidas Públicas",
|
|
21
|
+
"Processos Jurídicos",
|
|
22
|
+
],
|
|
23
|
+
datasets: [
|
|
24
|
+
{
|
|
25
|
+
data: [
|
|
26
|
+
totalProtestos,
|
|
27
|
+
totalCCFs,
|
|
28
|
+
totalSerasa,
|
|
29
|
+
totalBoaVista,
|
|
30
|
+
totalDividasPublicas,
|
|
31
|
+
processosJuridicos !== null && processosJuridicos !== void 0 ? processosJuridicos : 0,
|
|
32
|
+
],
|
|
33
|
+
backgroundColor: [
|
|
34
|
+
"#ff4081",
|
|
35
|
+
"#3f51b5",
|
|
36
|
+
"#008cf8",
|
|
37
|
+
"#ffc107",
|
|
38
|
+
"#4caf50",
|
|
39
|
+
"#58508d",
|
|
40
|
+
],
|
|
41
|
+
hoverOffset: 4,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
var aspectRatio = width < 1000 ? 1.5 : 1;
|
|
46
|
+
var options = {
|
|
47
|
+
responsive: true,
|
|
48
|
+
maintainAspectRatio: true,
|
|
49
|
+
aspectRatio: aspectRatio,
|
|
50
|
+
layout: {
|
|
51
|
+
padding: {
|
|
52
|
+
top: 32,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
plugins: {
|
|
56
|
+
legend: {
|
|
57
|
+
position: "right",
|
|
58
|
+
align: "start",
|
|
59
|
+
fullSize: true,
|
|
60
|
+
labels: {
|
|
61
|
+
boxWidth: 16,
|
|
62
|
+
padding: 16,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
title: {
|
|
66
|
+
display: true,
|
|
67
|
+
text: "Quantidade de Ocorrências",
|
|
68
|
+
font: {
|
|
69
|
+
size: 12,
|
|
70
|
+
},
|
|
71
|
+
padding: {
|
|
72
|
+
bottom: 8,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
datalabels: {
|
|
76
|
+
color: "#fff",
|
|
77
|
+
formatter: function (value) {
|
|
78
|
+
return value > 0 ? value.toString() : "";
|
|
79
|
+
},
|
|
80
|
+
font: {
|
|
81
|
+
weight: "bold",
|
|
82
|
+
},
|
|
83
|
+
textAlign: "center",
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
return { data: chartData, options: options };
|
|
88
|
+
}, [dataInput]);
|
|
89
|
+
};
|
|
@@ -6,35 +6,36 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
6
6
|
import React from "react";
|
|
7
7
|
import AddItemField from "../common/addItem";
|
|
8
8
|
import { formatMoney, formatValue } from "../../utils/number";
|
|
9
|
-
import { ResultContent } from "../interface/result";
|
|
9
|
+
import { Result, ResultContent } from "../interface/result";
|
|
10
10
|
import styled from "styled-components";
|
|
11
11
|
import theme from "../interface/theme";
|
|
12
12
|
var QuantityContainer = function (_a) {
|
|
13
13
|
var children = _a.children;
|
|
14
|
-
return React.createElement("div", { className: "t" }, children);
|
|
14
|
+
return (React.createElement("div", { className: "t" }, children));
|
|
15
15
|
};
|
|
16
|
-
var QuantidadeResultadosWrapper = styled(ResultContent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 18px
|
|
16
|
+
var QuantidadeResultadosWrapper = styled(ResultContent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 18px 20px;\n row-gap: 20px;\n > * {\n row-gap: 10px;\n }\n @media only screen and (max-width: 768px) {\n > * {\n :not(:last-child) {\n border-bottom: 1px solid ", ";\n }\n }\n }\n"], ["\n padding: 18px 20px;\n row-gap: 20px;\n > * {\n row-gap: 10px;\n }\n @media only screen and (max-width: 768px) {\n > * {\n :not(:last-child) {\n border-bottom: 1px solid ", ";\n }\n }\n }\n"])), theme.colors.cinzaClaro);
|
|
17
17
|
var QuantidadeResultados = function (_a) {
|
|
18
18
|
var _b = _a.quantidadeProtestos, quantidadeProtestos = _b === void 0 ? 0 : _b, _c = _a.quantidadeProcessos, quantidadeProcessos = _c === void 0 ? 0 : _c, _d = _a.quantidadeDividas, quantidadeDividas = _d === void 0 ? 0 : _d, _e = _a.quantidadeChequesSemFundos, quantidadeChequesSemFundos = _e === void 0 ? 0 : _e, _f = _a.quantidadeDividasSerasa, quantidadeDividasSerasa = _f === void 0 ? 0 : _f, _g = _a.quantidadeDividasBoaVista, quantidadeDividasBoaVista = _g === void 0 ? 0 : _g, _h = _a.valorTotalProtestos, valorTotalProtestos = _h === void 0 ? 0 : _h, _j = _a.valorTotalDividas, valorTotalDividas = _j === void 0 ? 0 : _j, _k = _a.valorTotalDividasSerasa, valorTotalDividasSerasa = _k === void 0 ? 0 : _k, _l = _a.valorTotalDividasBoaVista, valorTotalDividasBoaVista = _l === void 0 ? 0 : _l, _m = _a.ultimaOcorrenciaProtestos, ultimaOcorrenciaProtestos = _m === void 0 ? null : _m, _o = _a.ultimaOcorrenciaChequesSemFundos, ultimaOcorrenciaChequesSemFundos = _o === void 0 ? null : _o;
|
|
19
|
-
return (React.createElement(
|
|
20
|
-
React.createElement(
|
|
21
|
-
React.createElement(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
React.createElement(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
React.createElement(
|
|
29
|
-
|
|
30
|
-
React.createElement(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
React.createElement(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
React.createElement(
|
|
37
|
-
|
|
19
|
+
return (React.createElement(Result, { resultContentStriped: false },
|
|
20
|
+
React.createElement(QuantidadeResultadosWrapper, { desktop: "repeat(6, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr" },
|
|
21
|
+
React.createElement(QuantityContainer, null,
|
|
22
|
+
React.createElement(AddItemField, { name: "Total Protestos", value: formatValue(quantidadeProtestos) }),
|
|
23
|
+
React.createElement(AddItemField, { name: "Valor Total Protestos", value: formatMoney(valorTotalProtestos) }),
|
|
24
|
+
React.createElement(AddItemField, { hidden: quantidadeProtestos == 0, name: "\u00DAltima Ocorr\u00EAncia", value: ultimaOcorrenciaProtestos })),
|
|
25
|
+
React.createElement(QuantityContainer, null,
|
|
26
|
+
React.createElement(AddItemField, { name: "Cheques Sem Fundos", value: formatValue(quantidadeChequesSemFundos) }),
|
|
27
|
+
React.createElement(AddItemField, { hidden: quantidadeChequesSemFundos == 0, name: "\u00DAltima Ocorr\u00EAncia", value: ultimaOcorrenciaChequesSemFundos })),
|
|
28
|
+
React.createElement(QuantityContainer, null,
|
|
29
|
+
React.createElement(AddItemField, { name: "Processos Jur\u00EDdicos", value: formatValue(quantidadeProcessos) })),
|
|
30
|
+
React.createElement(QuantityContainer, null,
|
|
31
|
+
React.createElement(AddItemField, { name: "D\u00EDvidas P\u00FAblicas", value: formatValue(quantidadeDividas) }),
|
|
32
|
+
React.createElement(AddItemField, { name: "Total D\u00EDvidas P\u00FAblicas", value: formatMoney(valorTotalDividas) })),
|
|
33
|
+
React.createElement(QuantityContainer, null,
|
|
34
|
+
React.createElement(AddItemField, { name: "Pefin Refin Serasa", value: formatValue(quantidadeDividasSerasa) }),
|
|
35
|
+
React.createElement(AddItemField, { name: "Total Pefin Refin Serasa", value: formatMoney(valorTotalDividasSerasa) })),
|
|
36
|
+
React.createElement(QuantityContainer, null,
|
|
37
|
+
React.createElement(AddItemField, { name: "Pefin Refin Boa Vista", value: formatValue(quantidadeDividasBoaVista) }),
|
|
38
|
+
React.createElement(AddItemField, { name: "Total Pefin Refin Boa Vista", value: formatMoney(valorTotalDividasBoaVista) })))));
|
|
38
39
|
};
|
|
39
40
|
export default QuantidadeResultados;
|
|
40
41
|
var templateObject_1;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface Consulta {
|
|
2
|
+
data: string | Date;
|
|
3
|
+
categoria?: string;
|
|
4
|
+
quantidade?: number | null;
|
|
5
|
+
creation?: string | Date;
|
|
6
|
+
valorTotal?: number | null;
|
|
7
|
+
total?: number | null;
|
|
8
|
+
}
|
|
9
|
+
export interface DataInput {
|
|
10
|
+
ccfs: Consulta[];
|
|
11
|
+
protestos: Consulta[];
|
|
12
|
+
serasa: Consulta[];
|
|
13
|
+
boaVista: Consulta[];
|
|
14
|
+
dividasPublicasGrafico: Consulta[];
|
|
15
|
+
pieChartTotalConfig?: {
|
|
16
|
+
protestos?: {
|
|
17
|
+
total: number | null;
|
|
18
|
+
valorTotal: number | null;
|
|
19
|
+
ultimaOcorrencia: string | null;
|
|
20
|
+
};
|
|
21
|
+
processosJuridicos?: number;
|
|
22
|
+
ccf?: {
|
|
23
|
+
total: number | null;
|
|
24
|
+
ultimaOcorrencia: string | null;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
protestosCategory?: ProtestoData[];
|
|
28
|
+
}
|
|
29
|
+
export interface ProtestoData {
|
|
30
|
+
categoria: string;
|
|
31
|
+
quantidade: number;
|
|
32
|
+
}
|
|
33
|
+
export interface DataSetCommon {
|
|
34
|
+
label: string;
|
|
35
|
+
data: {
|
|
36
|
+
x: string;
|
|
37
|
+
y: number;
|
|
38
|
+
}[];
|
|
39
|
+
borderColor?: string;
|
|
40
|
+
backgroundColor?: string;
|
|
41
|
+
borderWidth?: number;
|
|
42
|
+
yAxisID?: "y" | "y2";
|
|
43
|
+
}
|
|
44
|
+
export interface DataSetLine extends DataSetCommon {
|
|
45
|
+
type: "line";
|
|
46
|
+
tension?: number;
|
|
47
|
+
spanGaps: boolean;
|
|
48
|
+
showLine: boolean;
|
|
49
|
+
pointRadius: number;
|
|
50
|
+
fill?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface DataSetBar extends DataSetCommon {
|
|
53
|
+
type: "bar";
|
|
54
|
+
borderRadius?: number;
|
|
55
|
+
categoryPercentage?: number;
|
|
56
|
+
barPercentage?: number;
|
|
57
|
+
}
|
|
58
|
+
export type TimeFilter = "1y" | "6m" | "1m" | "all";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DataInput, TimeFilter } from "../types/iChart";
|
|
2
|
+
import { ChartDataset, ChartOptions } from "chart.js";
|
|
3
|
+
export declare function createDatasets(data: DataInput, uniqueDates: string[], timeFilter: TimeFilter): ChartDataset<"line" | "bar", (number | {
|
|
4
|
+
x: string;
|
|
5
|
+
y: number;
|
|
6
|
+
})[]>[];
|
|
7
|
+
export declare function getChartOptions(timeFilter: TimeFilter): ChartOptions<"line" | "bar">;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { format, parseISO } from "date-fns";
|
|
13
|
+
import { getBarSettings } from "./dataManipulation";
|
|
14
|
+
export function createDatasets(data, uniqueDates, timeFilter) {
|
|
15
|
+
var _a = getBarSettings(timeFilter), categoryPercentage = _a.categoryPercentage, barPercentage = _a.barPercentage;
|
|
16
|
+
var createDataSet = function (entries, label, borderColor, chartType, valueKey, yAxisID) {
|
|
17
|
+
var dateValues = new Map(entries.map(function (entry) {
|
|
18
|
+
var _a;
|
|
19
|
+
return [
|
|
20
|
+
format(typeof entry.data === "string" ? parseISO(entry.data) : entry.data, "yyyy-MM-dd"),
|
|
21
|
+
(_a = entry[valueKey]) !== null && _a !== void 0 ? _a : 0,
|
|
22
|
+
];
|
|
23
|
+
}));
|
|
24
|
+
var datasetData = uniqueDates.map(function (date) {
|
|
25
|
+
var _a;
|
|
26
|
+
var value = (_a = dateValues.get(date)) !== null && _a !== void 0 ? _a : 0;
|
|
27
|
+
return { x: date, y: value };
|
|
28
|
+
});
|
|
29
|
+
var datasetConfiguration = __assign({ type: chartType, label: label, data: datasetData, borderColor: borderColor, backgroundColor: chartType === "bar" ? borderColor + "60" : undefined, tension: chartType === "line" ? 0.4 : undefined, spanGaps: true, showLine: chartType === "line", pointRadius: 2, yAxisID: yAxisID }, (chartType === "bar" && {
|
|
30
|
+
categoryPercentage: categoryPercentage,
|
|
31
|
+
barPercentage: barPercentage,
|
|
32
|
+
}));
|
|
33
|
+
return datasetConfiguration;
|
|
34
|
+
};
|
|
35
|
+
return [
|
|
36
|
+
createDataSet(data.protestos, "Protestos - Quantidade", "#ff4081", "line", "quantidade", "y"),
|
|
37
|
+
createDataSet(data.protestos, "Protestos - Valor Total", "#ff4081", "bar", "valorTotal", "y2"),
|
|
38
|
+
createDataSet(data.ccfs, "CCFs - Quantidade", "#3f51b5", "line", "quantidade", "y"),
|
|
39
|
+
createDataSet(data.ccfs, "CCFs - Valor Total", "#3f51b5", "bar", "valorTotal", "y2"),
|
|
40
|
+
createDataSet(data.serasa, "Serasa - Quantidade", "#008cf8", "line", "quantidade", "y"),
|
|
41
|
+
createDataSet(data.serasa, "Serasa - Valor Total", "#008cf8", "bar", "valorTotal", "y2"),
|
|
42
|
+
createDataSet(data.boaVista, "Boa Vista - Quantidade", "#ffc107", "line", "quantidade", "y"),
|
|
43
|
+
createDataSet(data.boaVista, "Boa Vista - Valor Total", "#ffc107", "bar", "valorTotal", "y2"),
|
|
44
|
+
createDataSet(data.dividasPublicasGrafico, "Dívidas Públicas - Quantidade", "#4caf50", "line", "quantidade", "y"),
|
|
45
|
+
createDataSet(data.dividasPublicasGrafico, "Dívidas Públicas - Valor Total", "#4caf50", "bar", "valorTotal", "y2"),
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
export function getChartOptions(timeFilter) {
|
|
49
|
+
var unit = "day";
|
|
50
|
+
switch (timeFilter) {
|
|
51
|
+
case "1m":
|
|
52
|
+
unit = "day";
|
|
53
|
+
break;
|
|
54
|
+
case "6m":
|
|
55
|
+
unit = "week";
|
|
56
|
+
break;
|
|
57
|
+
case "1y":
|
|
58
|
+
unit = "month";
|
|
59
|
+
break;
|
|
60
|
+
case "all":
|
|
61
|
+
unit = "quarter";
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
responsive: true,
|
|
66
|
+
maintainAspectRatio: true,
|
|
67
|
+
interaction: {
|
|
68
|
+
mode: "index",
|
|
69
|
+
intersect: false,
|
|
70
|
+
},
|
|
71
|
+
plugins: {
|
|
72
|
+
legend: {
|
|
73
|
+
fullSize: true,
|
|
74
|
+
position: "right",
|
|
75
|
+
labels: {
|
|
76
|
+
boxWidth: 16,
|
|
77
|
+
padding: 16,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
title: {
|
|
81
|
+
display: true,
|
|
82
|
+
text: "Histórico de Consultas",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
scales: {
|
|
86
|
+
y: {
|
|
87
|
+
type: "linear",
|
|
88
|
+
display: true,
|
|
89
|
+
position: "right",
|
|
90
|
+
beginAtZero: true,
|
|
91
|
+
title: {
|
|
92
|
+
display: true,
|
|
93
|
+
text: "Quantidade de Ocorrências por Consulta",
|
|
94
|
+
font: {
|
|
95
|
+
size: 14,
|
|
96
|
+
family: "open sans",
|
|
97
|
+
weight: "bold",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
y2: {
|
|
102
|
+
type: "logarithmic",
|
|
103
|
+
display: true,
|
|
104
|
+
position: "left",
|
|
105
|
+
suggestedMin: 1,
|
|
106
|
+
title: {
|
|
107
|
+
display: true,
|
|
108
|
+
text: "Valor Total de Negativações (R$)",
|
|
109
|
+
font: {
|
|
110
|
+
size: 14,
|
|
111
|
+
family: "open sans",
|
|
112
|
+
weight: "bold",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
grid: {
|
|
116
|
+
drawOnChartArea: false,
|
|
117
|
+
},
|
|
118
|
+
ticks: {
|
|
119
|
+
font: {
|
|
120
|
+
size: 12,
|
|
121
|
+
},
|
|
122
|
+
callback: function (value) {
|
|
123
|
+
return new Intl.NumberFormat("pt-BR", {
|
|
124
|
+
style: "currency",
|
|
125
|
+
currency: "BRL",
|
|
126
|
+
minimumFractionDigits: 2,
|
|
127
|
+
notation: "compact",
|
|
128
|
+
}).format(value);
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
x: {
|
|
133
|
+
type: "time",
|
|
134
|
+
time: {
|
|
135
|
+
unit: unit,
|
|
136
|
+
parser: "yyyy-MM-dd",
|
|
137
|
+
},
|
|
138
|
+
title: {
|
|
139
|
+
display: true,
|
|
140
|
+
text: "Data",
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
elements: {
|
|
145
|
+
line: {
|
|
146
|
+
fill: false,
|
|
147
|
+
tension: 0.4,
|
|
148
|
+
},
|
|
149
|
+
point: {
|
|
150
|
+
radius: 3,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ItemCalculo } from "../../../utils/calculation";
|
|
2
|
+
export declare const useCalculation: (itens: ItemCalculo[]) => {
|
|
3
|
+
quantidade: number;
|
|
4
|
+
valorTotal: number;
|
|
5
|
+
dataMaisRecente: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const useUltimaOcorrenciaCCF: () => string | undefined;
|
|
8
|
+
export declare const useDividasPublicas: () => {
|
|
9
|
+
quantidade: number;
|
|
10
|
+
valorTotal: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
import { useMemo, useContext } from "react";
|
|
3
|
+
import { encontrarDataMaisRecente, somarQuantidades, somarValoresTotais, } from "../../../utils/calculation";
|
|
4
|
+
import { Queries, RequestStatus } from "../../../components/webservice";
|
|
5
|
+
import XPathUtils from "../../../utils/xpath";
|
|
6
|
+
export var useCalculation = function (itens) {
|
|
7
|
+
var quantidade = useMemo(function () { return somarQuantidades(itens); }, [itens]);
|
|
8
|
+
var valorTotal = useMemo(function () { return somarValoresTotais(itens); }, [itens]);
|
|
9
|
+
var dataMaisRecente = useMemo(function () { return encontrarDataMaisRecente(itens); }, [itens]);
|
|
10
|
+
return { quantidade: quantidade, valorTotal: valorTotal, dataMaisRecente: dataMaisRecente };
|
|
11
|
+
};
|
|
12
|
+
export var useUltimaOcorrenciaCCF = function () {
|
|
13
|
+
var ctxCCF = useContext(Queries.CCF);
|
|
14
|
+
var ultimaOcorrenciaCCF = useMemo(function () {
|
|
15
|
+
if ((ctxCCF === null || ctxCCF === void 0 ? void 0 : ctxCCF.type) === RequestStatus.Success) {
|
|
16
|
+
return XPathUtils.select("string(//ultimaOcorrencia)", ctxCCF === null || ctxCCF === void 0 ? void 0 : ctxCCF.document);
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}, [ctxCCF === null || ctxCCF === void 0 ? void 0 : ctxCCF.type]);
|
|
20
|
+
return ultimaOcorrenciaCCF;
|
|
21
|
+
};
|
|
22
|
+
export var useDividasPublicas = function () {
|
|
23
|
+
var ctxFinder = useContext(Queries.Finder);
|
|
24
|
+
var dividasPublicasData = useMemo(function () {
|
|
25
|
+
if ((ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.type) === RequestStatus.Success) {
|
|
26
|
+
return {
|
|
27
|
+
quantidade: XPathUtils.select("number(//dividas/resumo/quantidade_dividas)", ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.document) || 0,
|
|
28
|
+
valorTotal: XPathUtils.select("number(//dividas/resumo/valor_total_dividas)", ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.document) || 0,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
quantidade: 0,
|
|
33
|
+
valorTotal: 0,
|
|
34
|
+
};
|
|
35
|
+
}, [ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.type]);
|
|
36
|
+
return dividasPublicasData;
|
|
37
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Consulta, DataInput, TimeFilter } from "../types/iChart";
|
|
2
|
+
export declare const addMissingDateEntries: (data: Consulta[], startDate: Date, endDate: Date) => Consulta[];
|
|
3
|
+
export declare const getFilteredStartDate: (timeFilter: TimeFilter, data: DataInput) => Date;
|
|
4
|
+
export declare const getEarliestDate: (data: DataInput) => Date;
|
|
5
|
+
export declare const getEndDate: () => Date;
|
|
6
|
+
export declare function getUniqueDates(data: DataInput): string[];
|
|
7
|
+
export declare const getBarSettings: (timeFilter: TimeFilter) => {
|
|
8
|
+
categoryPercentage: number;
|
|
9
|
+
barPercentage: number;
|
|
10
|
+
};
|