@credithub/harlan-components 1.39.7 → 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 +38 -39
- package/dist/components/chart/hooks/useChartData.d.ts +1 -1
- package/dist/components/chart/hooks/useChartData.js +16 -8
- package/dist/components/chart/utils/chartUtils.js +5 -4
- package/dist/components/dossie/llama/llama.js +1 -0
- package/dist/components/refinBoaVista/refinBoaVista.d.ts +8 -0
- package/dist/components/refinBoaVista/refinBoaVista.js +3 -6
- package/dist/components/refinSerasa/refinSerasa.d.ts +25 -0
- package/dist/components/refinSerasa/refinSerasa.js +38 -35
- package/dist/components/webservice.js +11 -8
- package/lib/cjs/index.js +111 -99
- package/lib/esm/index.js +111 -99
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
4
4
|
};
|
|
5
5
|
import ResumoDeNegativacoesIcon from '../../assets/icones/resumoNegativacoes';
|
|
6
6
|
import { converterParaFormatoValido } from '../../utils/date';
|
|
7
|
-
import React, {
|
|
7
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
8
8
|
import styled from 'styled-components';
|
|
9
9
|
import useToggle from '../../hooks/useToggle';
|
|
10
10
|
import { ConsultasComplementaresContext } from '../consultasComplementares';
|
|
@@ -19,15 +19,28 @@ var Content = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateO
|
|
|
19
19
|
var ChartSystem = function (_a) {
|
|
20
20
|
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
21
21
|
var documento = _a.documento;
|
|
22
|
-
var _k = useChartData(documento), data = _k.data, isLoading = _k.isLoading, error = _k.error, refetch = _k.refetch, chartDataProgress = _k.loadingProgress;
|
|
23
|
-
var _l = useDividasPublicas(), quantidadeDividas = _l.quantidade, valorTotalDividas = _l.valorTotal, ultimaOcorrenciaDividas = _l.ultimaOcorrencia, dividasProgress = _l.loadingProgress;
|
|
24
22
|
var ctxConsultasComplementares = useContext(ConsultasComplementaresContext);
|
|
25
|
-
var
|
|
23
|
+
var consultaSerasa = (_c = (_b = ctxConsultasComplementares === null || ctxConsultasComplementares === void 0 ? void 0 : ctxConsultasComplementares.consultasComplementares) === null || _b === void 0 ? void 0 : _b.refinSerasa) === null || _c === void 0 ? void 0 : _c.data;
|
|
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
|
+
var _k = useChartData(documento, consultaSerasa, consultaBoaVista), data = _k.data, isLoadingChart = _k.isLoading, errorChart = _k.error, refetchChart = _k.refetch, chartDataProgress = _k.loadingProgress;
|
|
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;
|
|
28
|
+
useEffect(function () {
|
|
29
|
+
if (consultaSerasa || consultaBoaVista) {
|
|
30
|
+
refetchChart();
|
|
31
|
+
setRefetchTriggered(true);
|
|
32
|
+
}
|
|
33
|
+
}, [consultaSerasa, consultaBoaVista, refetchChart]);
|
|
34
|
+
useEffect(function () {
|
|
35
|
+
if (refetchTriggered) {
|
|
36
|
+
setRefetchTriggered(false);
|
|
37
|
+
}
|
|
38
|
+
}, [refetchTriggered]);
|
|
39
|
+
var errorMessage = typeof errorChart === 'string' ? new Error(errorChart) : errorChart;
|
|
26
40
|
var isOpen = useToggle(true)[0];
|
|
27
41
|
var ultimaOcorrenciaCCF = useUltimaOcorrenciaCCF();
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var valorTotalProtestos = ((_e = (_d = data === null || data === void 0 ? void 0 : data.protestos) === null || _d === void 0 ? void 0 : _d[(data === null || data === void 0 ? void 0 : data.protestos.length) - 1]) === null || _e === void 0 ? void 0 : _e.valorTotal) || 0;
|
|
42
|
+
var quantidadeProtestos = ((_g = (_f = data === null || data === void 0 ? void 0 : data.protestos) === null || _f === void 0 ? void 0 : _f[(data === null || data === void 0 ? void 0 : data.protestos.length) - 1]) === null || _g === void 0 ? void 0 : _g.quantidade) || 0;
|
|
43
|
+
var valorTotalProtestos = ((_j = (_h = data === null || data === void 0 ? void 0 : data.protestos) === null || _h === void 0 ? void 0 : _h[(data === null || data === void 0 ? void 0 : data.protestos.length) - 1]) === null || _j === void 0 ? void 0 : _j.valorTotal) || 0;
|
|
31
44
|
var _o = useCalculation((data === null || data === void 0 ? void 0 : data.serasa) || []), quantidadeSerasa = _o.quantidade, valorTotalSerasa = _o.valorTotal, ultimaOcorrenciaSerasa = _o.dataMaisRecente;
|
|
32
45
|
var _p = useCalculation((data === null || data === void 0 ? void 0 : data.boaVista) || []), quantidadeBoaVista = _p.quantidade, valorTotalBoaVista = _p.valorTotal, ultimaOcorrenciaBoaVista = _p.dataMaisRecente;
|
|
33
46
|
var quantidadeCCFs = useCalculation((data === null || data === void 0 ? void 0 : data.ccfs) || []).quantidade;
|
|
@@ -37,55 +50,41 @@ var ChartSystem = function (_a) {
|
|
|
37
50
|
.map(function (categoria) { return categoria.ultimaOcorrencia; })
|
|
38
51
|
.filter(Boolean)
|
|
39
52
|
.map(function (data) {
|
|
40
|
-
|
|
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();
|
|
41
60
|
})
|
|
42
|
-
.filter(function (timestamp) { return
|
|
61
|
+
.filter(function (timestamp) { return timestamp !== null; });
|
|
43
62
|
if (datasOcorrencias.length > 0) {
|
|
44
63
|
ultimaOcorrenciaProtestos = new Date(Math.max.apply(Math, datasOcorrencias)).toLocaleDateString();
|
|
45
64
|
}
|
|
46
65
|
}
|
|
47
|
-
var consultaPefinBoaVista = (_g = (_f = ctxConsultasComplementares === null || ctxConsultasComplementares === void 0 ? void 0 : ctxConsultasComplementares.consultasComplementares) === null || _f === void 0 ? void 0 : _f.refinBoaVista) === null || _g === void 0 ? void 0 : _g.data;
|
|
48
|
-
var consultaPefinSerasa = (_j = (_h = ctxConsultasComplementares === null || ctxConsultasComplementares === void 0 ? void 0 : ctxConsultasComplementares.consultasComplementares) === null || _h === void 0 ? void 0 : _h.refinSerasa) === null || _j === void 0 ? void 0 : _j.data;
|
|
49
|
-
var handleRefetch = useCallback(function () {
|
|
50
|
-
if ((consultaPefinBoaVista || consultaPefinSerasa) &&
|
|
51
|
-
!isLoading &&
|
|
52
|
-
!refetchTriggered) {
|
|
53
|
-
refetch();
|
|
54
|
-
setRefetchTriggered(true);
|
|
55
|
-
}
|
|
56
|
-
}, [
|
|
57
|
-
consultaPefinBoaVista,
|
|
58
|
-
consultaPefinSerasa,
|
|
59
|
-
refetch,
|
|
60
|
-
isLoading,
|
|
61
|
-
refetchTriggered
|
|
62
|
-
]);
|
|
63
|
-
useEffect(function () {
|
|
64
|
-
handleRefetch();
|
|
65
|
-
}, [handleRefetch]);
|
|
66
66
|
var loadingProgress = (chartDataProgress + dividasProgress) / 2;
|
|
67
67
|
return (React.createElement(Section, { ctx: {
|
|
68
68
|
response: undefined,
|
|
69
|
-
type:
|
|
69
|
+
type: isLoadingChart
|
|
70
70
|
? RequestStatus.Loading
|
|
71
|
-
:
|
|
71
|
+
: errorChart
|
|
72
72
|
? RequestStatus.Error
|
|
73
73
|
: RequestStatus.Success,
|
|
74
74
|
error: errorMessage || null,
|
|
75
|
-
refetch:
|
|
75
|
+
refetch: refetchChart,
|
|
76
76
|
document: data,
|
|
77
77
|
progress: loadingProgress,
|
|
78
78
|
Section: Section
|
|
79
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 () {
|
|
80
80
|
var _a;
|
|
81
|
-
return (React.createElement(
|
|
82
|
-
React.createElement(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
: 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 })));
|
|
89
88
|
}, isError: function (err) { return ({
|
|
90
89
|
children: React.createElement(React.Fragment, null),
|
|
91
90
|
description: (React.createElement(StatusMessage, { type: "error" },
|
|
@@ -5,7 +5,7 @@ export declare const useDividasPublicas: () => {
|
|
|
5
5
|
valorTotal: number;
|
|
6
6
|
ultimaOcorrencia: string;
|
|
7
7
|
};
|
|
8
|
-
declare const useChartData: (documento: string) => {
|
|
8
|
+
declare const useChartData: (documento: string, consultaSerasa: any, consultaBoaVista: any) => {
|
|
9
9
|
data: DataInput | null;
|
|
10
10
|
isLoading: boolean;
|
|
11
11
|
error: string | Error | null;
|
|
@@ -52,13 +52,14 @@ export var useDividasPublicas = function () {
|
|
|
52
52
|
}, [ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.type]);
|
|
53
53
|
return __assign(__assign({}, dividasPublicasData), { loadingProgress: loadingProgress });
|
|
54
54
|
};
|
|
55
|
-
var useChartData = function (documento) {
|
|
55
|
+
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);
|
|
@@ -75,7 +76,9 @@ var useChartData = function (documento) {
|
|
|
75
76
|
ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.type,
|
|
76
77
|
ctxCCF === null || ctxCCF === void 0 ? void 0 : ctxCCF.type,
|
|
77
78
|
ctxProcessosJuridicos === null || ctxProcessosJuridicos === void 0 ? void 0 : ctxProcessosJuridicos.type
|
|
78
|
-
].every(function (status) {
|
|
79
|
+
].every(function (status) {
|
|
80
|
+
return status !== RequestStatus.Loading && status !== RequestStatus.Empty;
|
|
81
|
+
});
|
|
79
82
|
}, [ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.type, ctxCCF === null || ctxCCF === void 0 ? void 0 : ctxCCF.type, ctxProcessosJuridicos === null || ctxProcessosJuridicos === void 0 ? void 0 : ctxProcessosJuridicos.type]);
|
|
80
83
|
var dadosProtestos = useMemo(function () {
|
|
81
84
|
if ((ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.type) === RequestStatus.Success && ctxProtestos.document) {
|
|
@@ -84,10 +87,15 @@ var useChartData = function (documento) {
|
|
|
84
87
|
return [];
|
|
85
88
|
}, [ctxProtestos]);
|
|
86
89
|
useEffect(function () {
|
|
87
|
-
if (liveQueriesIsFinish) {
|
|
90
|
+
if (liveQueriesIsFinish && !shouldFetch) {
|
|
91
|
+
setShouldFetch(true);
|
|
92
|
+
}
|
|
93
|
+
}, [liveQueriesIsFinish, shouldFetch]);
|
|
94
|
+
useEffect(function () {
|
|
95
|
+
if (shouldFetch || consultaSerasa || consultaBoaVista) {
|
|
88
96
|
refetch();
|
|
89
97
|
}
|
|
90
|
-
}, [
|
|
98
|
+
}, [shouldFetch, refetch, consultaSerasa, consultaBoaVista]);
|
|
91
99
|
useEffect(function () {
|
|
92
100
|
if (isLoading) {
|
|
93
101
|
setLoadingProgress(function (prev) { return Math.min(prev + 15, 90); });
|
|
@@ -95,7 +103,7 @@ var useChartData = function (documento) {
|
|
|
95
103
|
else if (!isLoading && (queryError || response)) {
|
|
96
104
|
setLoadingProgress(100);
|
|
97
105
|
}
|
|
98
|
-
}, [isLoading, queryError, response]);
|
|
106
|
+
}, [isLoading, queryError, response, loadingProgress]);
|
|
99
107
|
useEffect(function () {
|
|
100
108
|
if (!isLoading &&
|
|
101
109
|
!queryError &&
|
|
@@ -108,7 +116,7 @@ var useChartData = function (documento) {
|
|
|
108
116
|
setData(processedData);
|
|
109
117
|
}
|
|
110
118
|
catch (e) {
|
|
111
|
-
console.error('Erro ao processar os dados', e);
|
|
119
|
+
console.error('%c Erro ao processar os dados', 'color: red', e);
|
|
112
120
|
setErrorState('Erro ao processar os dados');
|
|
113
121
|
}
|
|
114
122
|
}
|
|
@@ -4,9 +4,10 @@ import XPathUtils from '../../../utils/xpath';
|
|
|
4
4
|
import last from 'lodash/last';
|
|
5
5
|
import { useContext, useMemo } from 'react';
|
|
6
6
|
export var useCalculation = function (itens, dataKey) {
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
7
|
+
var _a, _b;
|
|
8
|
+
var quantidade = ((_a = last(itens)) === null || _a === void 0 ? void 0 : _a.quantidade) || 0;
|
|
9
|
+
var valorTotal = ((_b = last(itens)) === null || _b === void 0 ? void 0 : _b.valorTotal) || 0;
|
|
10
|
+
var dataMaisRecente = (function () {
|
|
10
11
|
var datas = itens
|
|
11
12
|
.map(function (item) { return item[dataKey || 'data']; })
|
|
12
13
|
.filter(Boolean)
|
|
@@ -15,7 +16,7 @@ export var useCalculation = function (itens, dataKey) {
|
|
|
15
16
|
return datas.length
|
|
16
17
|
? new Date(Math.max.apply(Math, datas)).toLocaleDateString()
|
|
17
18
|
: null;
|
|
18
|
-
}
|
|
19
|
+
})();
|
|
19
20
|
return { quantidade: quantidade, valorTotal: valorTotal, dataMaisRecente: dataMaisRecente };
|
|
20
21
|
};
|
|
21
22
|
export var useUltimaOcorrenciaCCF = function () {
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
import { Spc } from '../../@types/domain';
|
|
1
2
|
import React from 'react';
|
|
3
|
+
export declare function useRefinBoaVista(documento: string): {
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
error: Error | null;
|
|
6
|
+
pendencias: Spc[];
|
|
7
|
+
consultaRealizada: boolean;
|
|
8
|
+
loadingProgress: number;
|
|
9
|
+
};
|
|
2
10
|
declare function RefinBoaVista({ documento }: {
|
|
3
11
|
documento: string;
|
|
4
12
|
}): React.JSX.Element | null;
|
|
@@ -20,7 +20,7 @@ import { Result, ResultContent } from '../interface/result';
|
|
|
20
20
|
import StatusMessage from '../interface/statusMessage';
|
|
21
21
|
import { Section } from '../section';
|
|
22
22
|
import { RequestStatus, useQuery } from '../webservice';
|
|
23
|
-
function useRefinBoaVista(documento) {
|
|
23
|
+
export function useRefinBoaVista(documento) {
|
|
24
24
|
var _a;
|
|
25
25
|
var consultasComplementaresContext = useContext(ConsultasComplementaresContext);
|
|
26
26
|
var setData = useGlobalData().setData;
|
|
@@ -42,14 +42,11 @@ function useRefinBoaVista(documento) {
|
|
|
42
42
|
return [];
|
|
43
43
|
}, [response]);
|
|
44
44
|
useEffect(function () {
|
|
45
|
-
|
|
46
|
-
if (!((_a = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinBoaVista) === null || _a === void 0 ? void 0 : _a.consultaRealizada) &&
|
|
47
|
-
!dataUpdated &&
|
|
48
|
-
(response === null || response === void 0 ? void 0 : response.document)) {
|
|
45
|
+
if (!dataUpdated && (response === null || response === void 0 ? void 0 : response.document)) {
|
|
49
46
|
var refinBoaVistaData_1 = {
|
|
50
47
|
refinBoaVistaData: response.document
|
|
51
48
|
};
|
|
52
|
-
setConsultasComplementares === null || setConsultasComplementares === void 0 ? void 0 : setConsultasComplementares(function (prev) { return (__assign(__assign({}, prev), { refinBoaVista: __assign(__assign({}, prev.refinBoaVista), { data: response }) })); });
|
|
49
|
+
setConsultasComplementares === null || setConsultasComplementares === void 0 ? void 0 : setConsultasComplementares(function (prev) { return (__assign(__assign({}, prev), { refinBoaVista: __assign(__assign({}, prev.refinBoaVista), { data: response, consultaRealizada: true }) })); });
|
|
53
50
|
setData(function (prevState) { return (__assign(__assign({}, prevState), { refinBoaVista: refinBoaVistaData_1 })); });
|
|
54
51
|
setDataUpdated(true);
|
|
55
52
|
}
|
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
export declare function useRefinSerasa(documento: string): {
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
error: Error | null;
|
|
5
|
+
pendencias: {
|
|
6
|
+
valor: string;
|
|
7
|
+
totalvalor: string;
|
|
8
|
+
vencimento: string;
|
|
9
|
+
ocorrencia: string;
|
|
10
|
+
entrada: string;
|
|
11
|
+
informante: string;
|
|
12
|
+
contrato: string;
|
|
13
|
+
avalista: string;
|
|
14
|
+
cidade: string;
|
|
15
|
+
uf: string;
|
|
16
|
+
situacao: string;
|
|
17
|
+
credor: string;
|
|
18
|
+
orgaoemissor: string;
|
|
19
|
+
totalpendencias: string;
|
|
20
|
+
totalcredores: string;
|
|
21
|
+
categoria: "PEND\u00CANCIAS FINANCEIRAS" | "RESTRI\u00C7\u00D5ES FINANCEIRAS" | "D\u00CDVIDAS VENCIDAS";
|
|
22
|
+
modalidade: string;
|
|
23
|
+
}[];
|
|
24
|
+
consultaRealizada: boolean;
|
|
25
|
+
loadingProgress: number;
|
|
26
|
+
};
|
|
2
27
|
declare const RefinSerasa: React.FC<{
|
|
3
28
|
documento: string;
|
|
4
29
|
}>;
|
|
@@ -20,15 +20,13 @@ import { Result, ResultContent } from '../interface/result';
|
|
|
20
20
|
import StatusMessage from '../interface/statusMessage';
|
|
21
21
|
import { Section } from '../section';
|
|
22
22
|
import { RequestStatus, useQuery } from '../webservice';
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
var documento = _a.documento;
|
|
26
|
-
var refinSerasaRef = useRef(null);
|
|
27
|
-
var setData = useGlobalData().setData;
|
|
28
|
-
var _d = useState(false), dataUpdated = _d[0], setDataUpdated = _d[1];
|
|
23
|
+
export function useRefinSerasa(documento) {
|
|
24
|
+
var _a;
|
|
29
25
|
var consultasComplementaresContext = useContext(ConsultasComplementaresContext);
|
|
30
|
-
var
|
|
31
|
-
var
|
|
26
|
+
var setData = useGlobalData().setData;
|
|
27
|
+
var _b = useState(false), dataUpdated = _b[0], setDataUpdated = _b[1];
|
|
28
|
+
var _c = consultasComplementaresContext !== null && consultasComplementaresContext !== void 0 ? consultasComplementaresContext : {}, consultasComplementares = _c.consultasComplementares, setConsultasComplementares = _c.setConsultasComplementares;
|
|
29
|
+
var _d = useQuery("SELECT FROM 'PROTESTOS'.'SERASA'", { documento: documento }, !!((_a = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinSerasa) === null || _a === void 0 ? void 0 : _a.consultaRealizada)), response = _d.response, isLoading = _d.isLoading, error = _d.error, loadingProgress = _d.loadingProgress;
|
|
32
30
|
var clearValue = function (value) {
|
|
33
31
|
if (!value)
|
|
34
32
|
return '0';
|
|
@@ -52,41 +50,46 @@ var RefinSerasa = function (_a) {
|
|
|
52
50
|
categoria === 'RESTRIÇÕES FINANCEIRAS' ||
|
|
53
51
|
categoria === 'DÍVIDAS VENCIDAS';
|
|
54
52
|
});
|
|
55
|
-
var consultaRefinRealizada = useMemo(function () { var _a; return (_a = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinSerasa) === null || _a === void 0 ? void 0 : _a.consultaRealizada; }, [(_c = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinSerasa) === null || _c === void 0 ? void 0 : _c.consultaRealizada]);
|
|
56
|
-
useEffect(function () {
|
|
57
|
-
var _a;
|
|
58
|
-
(_a = refinSerasaRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
|
|
59
|
-
}, [consultaRefinRealizada]);
|
|
60
53
|
useEffect(function () {
|
|
61
|
-
if (!
|
|
62
|
-
!dataUpdated &&
|
|
63
|
-
response &&
|
|
64
|
-
response.document) {
|
|
65
|
-
setConsultasComplementares &&
|
|
66
|
-
setConsultasComplementares(function (prev) { return (__assign(__assign({}, prev), { refinSerasa: __assign(__assign({}, prev.refinSerasa), { data: response }) })); });
|
|
54
|
+
if (!dataUpdated && (response === null || response === void 0 ? void 0 : response.document)) {
|
|
67
55
|
var refinSerasaData_1 = {
|
|
68
56
|
refinSerasaData: response.document
|
|
69
57
|
};
|
|
58
|
+
setConsultasComplementares === null || setConsultasComplementares === void 0 ? void 0 : setConsultasComplementares(function (prev) { return (__assign(__assign({}, prev), { refinSerasa: __assign(__assign({}, prev.refinSerasa), { data: response, consultaRealizada: true }) })); });
|
|
70
59
|
setData(function (prevState) { return (__assign(__assign({}, prevState), { refinSerasa: refinSerasaData_1 })); });
|
|
71
60
|
setDataUpdated(true);
|
|
72
61
|
}
|
|
73
|
-
}, [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
62
|
+
}, [
|
|
63
|
+
response,
|
|
64
|
+
dataUpdated,
|
|
65
|
+
setData,
|
|
66
|
+
setConsultasComplementares,
|
|
67
|
+
consultasComplementares
|
|
68
|
+
]);
|
|
69
|
+
return {
|
|
70
|
+
isLoading: isLoading,
|
|
71
|
+
error: error,
|
|
72
|
+
pendencias: pendencias,
|
|
73
|
+
consultaRealizada: !!response,
|
|
74
|
+
loadingProgress: loadingProgress
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
var RefinSerasa = function (_a) {
|
|
78
|
+
var documento = _a.documento;
|
|
79
|
+
var refinSerasaRef = useRef(null);
|
|
80
|
+
var _b = useRefinSerasa(documento), isLoading = _b.isLoading, error = _b.error, pendencias = _b.pendencias, consultaRealizada = _b.consultaRealizada, loadingProgress = _b.loadingProgress;
|
|
81
|
+
useEffect(function () {
|
|
82
|
+
var _a;
|
|
83
|
+
(_a = refinSerasaRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
|
|
84
|
+
}, [consultaRealizada]);
|
|
85
|
+
var totalPendencias = pendencias.length;
|
|
86
|
+
var valorTotalPendencias = pendencias.reduce(function (acc, curr) { return acc + (parseFloat(curr.valor) || 0); }, 0);
|
|
87
|
+
var description = totalPendencias === 0
|
|
88
|
+
? 'Não há ocorrência de Pefin/Refin Serasa'
|
|
89
|
+
: totalPendencias === 1
|
|
86
90
|
? "Foi encontrada 1 ocorr\u00EAncia no valor de ".concat(formatMoney(valorTotalPendencias))
|
|
87
91
|
: "Foram encontradas ".concat(totalPendencias, " ocorr\u00EAncias no valor total de ").concat(formatMoney(valorTotalPendencias));
|
|
88
|
-
|
|
89
|
-
return consultaRefinRealizada ? (React.createElement(Section, { ctx: {
|
|
92
|
+
return consultaRealizada ? (React.createElement(Section, { ctx: {
|
|
90
93
|
type: isLoading
|
|
91
94
|
? RequestStatus.Loading
|
|
92
95
|
: error
|
|
@@ -94,7 +97,7 @@ var RefinSerasa = function (_a) {
|
|
|
94
97
|
: RequestStatus.Success,
|
|
95
98
|
error: error || null,
|
|
96
99
|
response: undefined,
|
|
97
|
-
document:
|
|
100
|
+
document: pendencias,
|
|
98
101
|
refetch: function () { },
|
|
99
102
|
Section: Section,
|
|
100
103
|
progress: loadingProgress
|
|
@@ -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) {
|