@credithub/harlan-components 1.39.7 → 1.39.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 +23 -29
- package/dist/components/chart/hooks/useChartData.d.ts +1 -1
- package/dist/components/chart/hooks/useChartData.js +8 -6
- package/dist/components/chart/utils/chartUtils.js +5 -4
- package/dist/components/dossie/llama/llama.js +2 -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/lib/cjs/index.js +78 -79
- package/lib/esm/index.js +78 -79
- 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
|
+
useEffect(function () {
|
|
28
|
+
if (consultaSerasa || consultaBoaVista) {
|
|
29
|
+
refetchChart();
|
|
30
|
+
setRefetchTriggered(true);
|
|
31
|
+
}
|
|
32
|
+
}, [consultaSerasa, consultaBoaVista, refetchChart]);
|
|
33
|
+
useEffect(function () {
|
|
34
|
+
if (refetchTriggered && !consultaSerasa && !consultaBoaVista) {
|
|
35
|
+
setRefetchTriggered(false);
|
|
36
|
+
}
|
|
37
|
+
}, [consultaSerasa, consultaBoaVista, refetchTriggered]);
|
|
38
|
+
var _m = useDividasPublicas(), quantidadeDividas = _m.quantidade, valorTotalDividas = _m.valorTotal, ultimaOcorrenciaDividas = _m.ultimaOcorrencia, dividasProgress = _m.loadingProgress;
|
|
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;
|
|
@@ -44,35 +57,16 @@ var ChartSystem = function (_a) {
|
|
|
44
57
|
ultimaOcorrenciaProtestos = new Date(Math.max.apply(Math, datasOcorrencias)).toLocaleDateString();
|
|
45
58
|
}
|
|
46
59
|
}
|
|
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
60
|
var loadingProgress = (chartDataProgress + dividasProgress) / 2;
|
|
67
61
|
return (React.createElement(Section, { ctx: {
|
|
68
62
|
response: undefined,
|
|
69
|
-
type:
|
|
63
|
+
type: isLoadingChart
|
|
70
64
|
? RequestStatus.Loading
|
|
71
|
-
:
|
|
65
|
+
: errorChart
|
|
72
66
|
? RequestStatus.Error
|
|
73
67
|
: RequestStatus.Success,
|
|
74
68
|
error: errorMessage || null,
|
|
75
|
-
refetch:
|
|
69
|
+
refetch: refetchChart,
|
|
76
70
|
document: data,
|
|
77
71
|
progress: loadingProgress,
|
|
78
72
|
Section: Section
|
|
@@ -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,7 +52,7 @@ 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];
|
|
@@ -75,7 +75,9 @@ var useChartData = function (documento) {
|
|
|
75
75
|
ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.type,
|
|
76
76
|
ctxCCF === null || ctxCCF === void 0 ? void 0 : ctxCCF.type,
|
|
77
77
|
ctxProcessosJuridicos === null || ctxProcessosJuridicos === void 0 ? void 0 : ctxProcessosJuridicos.type
|
|
78
|
-
].every(function (status) {
|
|
78
|
+
].every(function (status) {
|
|
79
|
+
return status !== RequestStatus.Loading && status !== RequestStatus.Empty;
|
|
80
|
+
});
|
|
79
81
|
}, [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
82
|
var dadosProtestos = useMemo(function () {
|
|
81
83
|
if ((ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.type) === RequestStatus.Success && ctxProtestos.document) {
|
|
@@ -84,10 +86,10 @@ var useChartData = function (documento) {
|
|
|
84
86
|
return [];
|
|
85
87
|
}, [ctxProtestos]);
|
|
86
88
|
useEffect(function () {
|
|
87
|
-
if (liveQueriesIsFinish) {
|
|
89
|
+
if (liveQueriesIsFinish || consultaSerasa || consultaBoaVista) {
|
|
88
90
|
refetch();
|
|
89
91
|
}
|
|
90
|
-
}, [liveQueriesIsFinish, refetch]);
|
|
92
|
+
}, [liveQueriesIsFinish, refetch, consultaSerasa, consultaBoaVista]);
|
|
91
93
|
useEffect(function () {
|
|
92
94
|
if (isLoading) {
|
|
93
95
|
setLoadingProgress(function (prev) { return Math.min(prev + 15, 90); });
|
|
@@ -95,7 +97,7 @@ var useChartData = function (documento) {
|
|
|
95
97
|
else if (!isLoading && (queryError || response)) {
|
|
96
98
|
setLoadingProgress(100);
|
|
97
99
|
}
|
|
98
|
-
}, [isLoading, queryError, response]);
|
|
100
|
+
}, [isLoading, queryError, response, loadingProgress]);
|
|
99
101
|
useEffect(function () {
|
|
100
102
|
if (!isLoading &&
|
|
101
103
|
!queryError &&
|
|
@@ -108,7 +110,7 @@ var useChartData = function (documento) {
|
|
|
108
110
|
setData(processedData);
|
|
109
111
|
}
|
|
110
112
|
catch (e) {
|
|
111
|
-
console.error('Erro ao processar os dados', e);
|
|
113
|
+
console.error('%c Erro ao processar os dados', 'color: red', e);
|
|
112
114
|
setErrorState('Erro ao processar os dados');
|
|
113
115
|
}
|
|
114
116
|
}
|
|
@@ -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 () {
|
|
@@ -167,10 +167,12 @@ 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);
|
|
170
171
|
handleIncrementalResponse(response);
|
|
171
172
|
setIsProcessing(false);
|
|
172
173
|
}
|
|
173
174
|
if (error) {
|
|
175
|
+
console.log('%c Erro ao realizar a consulta:', 'color: red; font-weight: bold;', error);
|
|
174
176
|
setIsProcessing(false);
|
|
175
177
|
}
|
|
176
178
|
}, [response, isLoading, error]);
|
|
@@ -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
|