@credithub/harlan-components 1.39.8 → 1.39.9
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 +18 -13
- package/dist/components/chart/hooks/useChartData.js +10 -4
- package/dist/components/dossie/llama/llama.js +0 -1
- package/dist/components/webservice.js +11 -8
- package/lib/cjs/index.js +40 -27
- package/lib/esm/index.js +40 -27
- package/package.json +1 -1
|
@@ -24,6 +24,7 @@ var ChartSystem = function (_a) {
|
|
|
24
24
|
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;
|
|
25
25
|
var _k = useChartData(documento, consultaSerasa, consultaBoaVista), data = _k.data, isLoadingChart = _k.isLoading, errorChart = _k.error, refetchChart = _k.refetch, chartDataProgress = _k.loadingProgress;
|
|
26
26
|
var _l = useState(false), refetchTriggered = _l[0], setRefetchTriggered = _l[1];
|
|
27
|
+
var _m = useDividasPublicas(), quantidadeDividas = _m.quantidade, valorTotalDividas = _m.valorTotal, ultimaOcorrenciaDividas = _m.ultimaOcorrencia, dividasProgress = _m.loadingProgress;
|
|
27
28
|
useEffect(function () {
|
|
28
29
|
if (consultaSerasa || consultaBoaVista) {
|
|
29
30
|
refetchChart();
|
|
@@ -31,11 +32,10 @@ var ChartSystem = function (_a) {
|
|
|
31
32
|
}
|
|
32
33
|
}, [consultaSerasa, consultaBoaVista, refetchChart]);
|
|
33
34
|
useEffect(function () {
|
|
34
|
-
if (refetchTriggered
|
|
35
|
+
if (refetchTriggered) {
|
|
35
36
|
setRefetchTriggered(false);
|
|
36
37
|
}
|
|
37
|
-
}, [
|
|
38
|
-
var _m = useDividasPublicas(), quantidadeDividas = _m.quantidade, valorTotalDividas = _m.valorTotal, ultimaOcorrenciaDividas = _m.ultimaOcorrencia, dividasProgress = _m.loadingProgress;
|
|
38
|
+
}, [refetchTriggered]);
|
|
39
39
|
var errorMessage = typeof errorChart === 'string' ? new Error(errorChart) : errorChart;
|
|
40
40
|
var isOpen = useToggle(true)[0];
|
|
41
41
|
var ultimaOcorrenciaCCF = useUltimaOcorrenciaCCF();
|
|
@@ -50,9 +50,15 @@ var ChartSystem = function (_a) {
|
|
|
50
50
|
.map(function (categoria) { return categoria.ultimaOcorrencia; })
|
|
51
51
|
.filter(Boolean)
|
|
52
52
|
.map(function (data) {
|
|
53
|
-
|
|
53
|
+
var formattedDate = converterParaFormatoValido(data);
|
|
54
|
+
var dateInstance = new Date(formattedDate);
|
|
55
|
+
if (isNaN(dateInstance.getTime())) {
|
|
56
|
+
console.error("Invalid date: ".concat(formattedDate));
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return dateInstance.getTime();
|
|
54
60
|
})
|
|
55
|
-
.filter(function (timestamp) { return
|
|
61
|
+
.filter(function (timestamp) { return timestamp !== null; });
|
|
56
62
|
if (datasOcorrencias.length > 0) {
|
|
57
63
|
ultimaOcorrenciaProtestos = new Date(Math.max.apply(Math, datasOcorrencias)).toLocaleDateString();
|
|
58
64
|
}
|
|
@@ -72,14 +78,13 @@ var ChartSystem = function (_a) {
|
|
|
72
78
|
Section: Section
|
|
73
79
|
}, title: "Resumo de Negativa\u00E7\u00F5es", subtitle: "Veja a quantidade de ocorr\u00EAncias conforme o documento foi consultado ao longo do tempo", icon: ResumoDeNegativacoesIcon, onSuccess: function () {
|
|
74
80
|
var _a;
|
|
75
|
-
return (React.createElement(
|
|
76
|
-
React.createElement(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
: undefined }))));
|
|
81
|
+
return (React.createElement(Content, { isOpen: isOpen },
|
|
82
|
+
data && React.createElement(ChartContent, { dataInput: data }),
|
|
83
|
+
React.createElement(QuantidadeResultados, { data: data, quantidadeProtestos: quantidadeProtestos, quantidadeProcessos: (_a = data === null || data === void 0 ? void 0 : data.pieChartTotalConfig) === null || _a === void 0 ? void 0 : _a.processosJuridicos, quantidadeDividas: quantidadeDividas, quantidadeDividasSerasa: quantidadeSerasa, quantidadeDividasBoaVista: quantidadeBoaVista, quantidadeChequesSemFundos: quantidadeCCFs, ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF, valorTotalDividasSerasa: valorTotalSerasa, valorTotalDividasBoaVista: valorTotalBoaVista, valorTotalProtestos: valorTotalProtestos, valorTotalDividas: valorTotalDividas, ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos, ultimaOcorrenciaDividas: ultimaOcorrenciaDividas, ultimaOcorrenciaPefinBoaVista: quantidadeBoaVista > 0
|
|
84
|
+
? (ultimaOcorrenciaBoaVista !== null && ultimaOcorrenciaBoaVista !== void 0 ? ultimaOcorrenciaBoaVista : undefined)
|
|
85
|
+
: undefined, ultimaOcorrenciaPefinSerasa: quantidadeSerasa > 0
|
|
86
|
+
? (ultimaOcorrenciaSerasa !== null && ultimaOcorrenciaSerasa !== void 0 ? ultimaOcorrenciaSerasa : undefined)
|
|
87
|
+
: undefined })));
|
|
83
88
|
}, isError: function (err) { return ({
|
|
84
89
|
children: React.createElement(React.Fragment, null),
|
|
85
90
|
description: (React.createElement(StatusMessage, { type: "error" },
|
|
@@ -56,9 +56,10 @@ var useChartData = function (documento, consultaSerasa, consultaBoaVista) {
|
|
|
56
56
|
var _a = useState(null), data = _a[0], setData = _a[1];
|
|
57
57
|
var _b = useState(null), errorState = _b[0], setErrorState = _b[1];
|
|
58
58
|
var _c = useState(0), loadingProgress = _c[0], setLoadingProgress = _c[1];
|
|
59
|
-
var _d =
|
|
59
|
+
var _d = useState(false), shouldFetch = _d[0], setShouldFetch = _d[1];
|
|
60
|
+
var _e = useQuery("SELECT FROM 'DOCUMENTHISTORY'.'BASICHISTORY'", {
|
|
60
61
|
documento: documento
|
|
61
|
-
}), response =
|
|
62
|
+
}), response = _e.response, queryError = _e.error, isLoading = _e.isLoading, refetch = _e.refetch;
|
|
62
63
|
var ctxProtestos = useContext(Queries.Protestos);
|
|
63
64
|
var ctxCCF = useContext(Queries.CCF);
|
|
64
65
|
var ctxProcessosJuridicos = useContext(Queries.ProcessosJuridicos);
|
|
@@ -86,10 +87,15 @@ var useChartData = function (documento, consultaSerasa, consultaBoaVista) {
|
|
|
86
87
|
return [];
|
|
87
88
|
}, [ctxProtestos]);
|
|
88
89
|
useEffect(function () {
|
|
89
|
-
if (liveQueriesIsFinish
|
|
90
|
+
if (liveQueriesIsFinish && !shouldFetch) {
|
|
91
|
+
setShouldFetch(true);
|
|
92
|
+
}
|
|
93
|
+
}, [liveQueriesIsFinish, shouldFetch]);
|
|
94
|
+
useEffect(function () {
|
|
95
|
+
if (shouldFetch || consultaSerasa || consultaBoaVista) {
|
|
90
96
|
refetch();
|
|
91
97
|
}
|
|
92
|
-
}, [
|
|
98
|
+
}, [shouldFetch, refetch, consultaSerasa, consultaBoaVista]);
|
|
93
99
|
useEffect(function () {
|
|
94
100
|
if (isLoading) {
|
|
95
101
|
setLoadingProgress(function (prev) { return Math.min(prev + 15, 90); });
|
|
@@ -167,7 +167,6 @@ var Llama = function (_a) {
|
|
|
167
167
|
}, [queryEnabled]);
|
|
168
168
|
useEffect(function () {
|
|
169
169
|
if (response && !isLoading && !error) {
|
|
170
|
-
console.log('%c Resposta recebida do Llama API:', 'color: green; font-weight: bold;', response);
|
|
171
170
|
handleIncrementalResponse(response);
|
|
172
171
|
setIsProcessing(false);
|
|
173
172
|
}
|
|
@@ -170,7 +170,7 @@ export function useQuery(query, data, enabled) {
|
|
|
170
170
|
return function () { return clearInterval(interval); };
|
|
171
171
|
}, []);
|
|
172
172
|
var fetch = useCallback(function () {
|
|
173
|
-
if (!shouldFetch || isLoading
|
|
173
|
+
if (!shouldFetch || isLoading)
|
|
174
174
|
return;
|
|
175
175
|
setIsLoading(true);
|
|
176
176
|
simulateProgress();
|
|
@@ -201,23 +201,26 @@ export function useQuery(query, data, enabled) {
|
|
|
201
201
|
setShouldFetch(false);
|
|
202
202
|
});
|
|
203
203
|
return function () { return abortController.abort(); };
|
|
204
|
-
}, [shouldFetch, isLoading,
|
|
204
|
+
}, [shouldFetch, isLoading, client, query, data, simulateProgress]);
|
|
205
|
+
useEffect(function () {
|
|
206
|
+
if (enabled && shouldFetch) {
|
|
207
|
+
fetch();
|
|
208
|
+
}
|
|
209
|
+
}, [fetch, shouldFetch, enabled]);
|
|
205
210
|
useEffect(function () {
|
|
206
211
|
if (enabled && !isLoading && !shouldFetch && !response && !error) {
|
|
207
212
|
setShouldFetch(true);
|
|
208
213
|
}
|
|
209
214
|
}, [enabled, isLoading, shouldFetch, response, error]);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
}, [fetch, shouldFetch]);
|
|
215
|
+
var refetch = useCallback(function () {
|
|
216
|
+
setShouldFetch(true);
|
|
217
|
+
}, [query]);
|
|
215
218
|
return {
|
|
216
219
|
response: response,
|
|
217
220
|
error: error,
|
|
218
221
|
isLoading: isLoading,
|
|
219
222
|
loadingProgress: loadingProgressRef.current,
|
|
220
|
-
refetch:
|
|
223
|
+
refetch: refetch
|
|
221
224
|
};
|
|
222
225
|
}
|
|
223
226
|
export function useMutation(query, data) {
|