@credithub/harlan-components 1.62.3 → 1.62.4
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/dividasPublicas/dividasPublicas.d.ts +2 -2
- package/dist/components/dividasPublicas/dividasPublicas.js +43 -31
- package/dist/components/processos-juridicos/processosJuridicos.d.ts +2 -2
- package/dist/components/processos-juridicos/processosJuridicos.js +40 -43
- package/lib/cjs/index.js +85 -76
- package/lib/esm/index.js +84 -75
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const _default: React.NamedExoticComponent<{}>;
|
|
3
|
+
export default _default;
|
|
@@ -13,7 +13,7 @@ import DividasVencidasSerasaIcon from '../../assets/icones/dividasVencidasSerasa
|
|
|
13
13
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
14
14
|
import { formatMoney } from '../../utils/number';
|
|
15
15
|
import XPathUtils from '../../utils/xpath';
|
|
16
|
-
import React, { useContext, useEffect, useState } from 'react';
|
|
16
|
+
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
17
17
|
import { Result } from '../interface/result';
|
|
18
18
|
import StatusMessage from '../interface/statusMessage';
|
|
19
19
|
import Section from '../section';
|
|
@@ -48,39 +48,51 @@ var DividasPublicas = function () {
|
|
|
48
48
|
var ctx = useContext(Queries.Finder);
|
|
49
49
|
var setData = useGlobalData().setData;
|
|
50
50
|
var _a = useState(false), dataUpdated = _a[0], setDataUpdated = _a[1];
|
|
51
|
+
var dividas = useMemo(function () {
|
|
52
|
+
if (ctx.document) {
|
|
53
|
+
return parseDividas(ctx.document);
|
|
54
|
+
}
|
|
55
|
+
return [];
|
|
56
|
+
}, [ctx.document]);
|
|
57
|
+
var dividasPublicas = useMemo(function () {
|
|
58
|
+
if (ctx.document) {
|
|
59
|
+
return (XPathUtils.select('number(//dividas/resumo/valor_total_dividas)', ctx.document) || 0);
|
|
60
|
+
}
|
|
61
|
+
return 0;
|
|
62
|
+
}, [ctx.document]);
|
|
51
63
|
useEffect(function () {
|
|
52
|
-
if (dataUpdated || !ctx.document)
|
|
64
|
+
if (dataUpdated || !ctx.document)
|
|
53
65
|
return;
|
|
54
|
-
}
|
|
55
|
-
var dividas = parseDividas(ctx.document);
|
|
56
66
|
if (ctx.type === RequestStatus.Error || ctx.type === RequestStatus.Empty) {
|
|
57
|
-
setData(function (prevState) { return (__assign(__assign({}, prevState), { divida: {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
setData(function (prevState) { return (__assign(__assign({}, prevState), { divida: {
|
|
68
|
+
protestosDeCredito: [],
|
|
69
|
+
protestosDeImposto: [],
|
|
70
|
+
protestosGerais: [],
|
|
71
|
+
totalProtestos: 0,
|
|
72
|
+
isLoaded: true
|
|
73
|
+
} })); });
|
|
63
74
|
setDataUpdated(true);
|
|
75
|
+
return;
|
|
64
76
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
?
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
setData(function (prevState) { return (__assign(__assign({}, prevState), { divida: { dividas: dividas, isLoaded: true }, dividasPublicas: dividasPublicas })); });
|
|
78
|
+
setDataUpdated(true);
|
|
79
|
+
}, [ctx.document, ctx.type, dataUpdated, dividas, dividasPublicas, setData]);
|
|
80
|
+
var handleSuccess = useCallback(function (document, _ctx) {
|
|
81
|
+
var parsedDividas = parseDividas(document);
|
|
82
|
+
var totalOcorrencias = parsedDividas.length;
|
|
83
|
+
var children = totalOcorrencias ? (React.createElement(Result, null,
|
|
84
|
+
React.createElement(DividasPublicasList, { dividas: parsedDividas }))) : null;
|
|
85
|
+
var variant = totalOcorrencias ? 'error' : 'default';
|
|
86
|
+
return {
|
|
87
|
+
children: children,
|
|
88
|
+
variant: variant,
|
|
89
|
+
description: (React.createElement(StatusMessage, { type: totalOcorrencias ? 'error' : 'default' }, totalOcorrencias
|
|
90
|
+
? totalOcorrencias === 1
|
|
91
|
+
? 'Encontrada uma dívida pública'
|
|
92
|
+
: "".concat(totalOcorrencias, " d\u00EDvidas encontradas")
|
|
93
|
+
: 'Não há ocorrência de dívida pública'))
|
|
94
|
+
};
|
|
95
|
+
}, []);
|
|
96
|
+
return (React.createElement(Section, { ctx: ctx, title: "D\u00EDvidas P\u00FAblicas", icon: DividasVencidasSerasaIcon, subtitle: "Veja as d\u00EDvidas p\u00FAblicas com a Uni\u00E3o (ativa, FGTS e previdenci\u00E1ria).", onSuccess: handleSuccess }));
|
|
85
97
|
};
|
|
86
|
-
export default DividasPublicas;
|
|
98
|
+
export default React.memo(DividasPublicas);
|
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import ProcessosJuridicosIcon from '../../assets/icones/processosJuridicos';
|
|
13
13
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
14
|
-
import React, {
|
|
14
|
+
import React, { useContext, useEffect, useRef } from 'react';
|
|
15
15
|
import StatusMessage from '../interface/statusMessage';
|
|
16
16
|
import Section from '../section';
|
|
17
17
|
import { Queries, RequestStatus } from '../webservice';
|
|
@@ -20,41 +20,41 @@ var ProcessosJuridicos = function (_a) {
|
|
|
20
20
|
var onClickConsultarProcessoJuridico = _a.onClickConsultarProcessoJuridico;
|
|
21
21
|
var ctx = useContext(Queries.ProcessosJuridicos);
|
|
22
22
|
var setData = useGlobalData().setData;
|
|
23
|
-
// Refs para evitar processamento desnecessário
|
|
24
23
|
var processedRef = useRef(false);
|
|
25
24
|
var ctxHashRef = useRef('');
|
|
26
25
|
useEffect(function () {
|
|
27
26
|
var _a;
|
|
28
|
-
// Gera um hash para detectar mudanças relevantes no contexto
|
|
29
27
|
var currentCtxHash = JSON.stringify({
|
|
30
28
|
type: ctx.type,
|
|
31
|
-
documentId:
|
|
29
|
+
documentId: ctx.document ? true : false
|
|
32
30
|
});
|
|
33
|
-
|
|
31
|
+
var cleanup = undefined;
|
|
34
32
|
if (currentCtxHash === ctxHashRef.current && processedRef.current) {
|
|
35
|
-
return;
|
|
33
|
+
return undefined;
|
|
36
34
|
}
|
|
37
|
-
// Atualiza o hash atual
|
|
38
35
|
ctxHashRef.current = currentCtxHash;
|
|
39
|
-
// Caso de erro ou resposta vazia
|
|
40
36
|
if ((ctx.type === RequestStatus.Error || ctx.type === RequestStatus.Empty) &&
|
|
41
37
|
!processedRef.current) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
var timer_1 = setTimeout(function () {
|
|
39
|
+
if (ctx.type === RequestStatus.Error ||
|
|
40
|
+
ctx.type === RequestStatus.Empty) {
|
|
41
|
+
setData(function (prevState) {
|
|
42
|
+
var _a;
|
|
43
|
+
if (((_a = prevState.processosJuridicosData) === null || _a === void 0 ? void 0 : _a.isLoaded) &&
|
|
44
|
+
Array.isArray(prevState.processosJuridicosData.empresa) &&
|
|
45
|
+
prevState.processosJuridicosData.empresa.length === 0) {
|
|
46
|
+
return prevState;
|
|
47
|
+
}
|
|
48
|
+
return __assign(__assign({}, prevState), { processosJuridicosData: {
|
|
49
|
+
empresa: [],
|
|
50
|
+
isLoaded: true
|
|
51
|
+
} });
|
|
52
|
+
});
|
|
53
|
+
processedRef.current = true;
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
isLoaded: true
|
|
52
|
-
} });
|
|
53
|
-
});
|
|
54
|
-
processedRef.current = true;
|
|
55
|
-
return;
|
|
55
|
+
}, 300);
|
|
56
|
+
cleanup = function () { return clearTimeout(timer_1); };
|
|
56
57
|
}
|
|
57
|
-
// Caso de resposta bem-sucedida
|
|
58
58
|
if (ctx.type === RequestStatus.Success &&
|
|
59
59
|
!processedRef.current &&
|
|
60
60
|
ctx.document) {
|
|
@@ -76,30 +76,27 @@ var ProcessosJuridicos = function (_a) {
|
|
|
76
76
|
processedRef.current = true;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
+
return cleanup;
|
|
79
80
|
}, [ctx.type, ctx.document, setData]);
|
|
80
|
-
// Reseta o estado processado ao iniciar novo carregamento
|
|
81
81
|
useEffect(function () {
|
|
82
82
|
if (ctx.type === RequestStatus.Loading) {
|
|
83
83
|
processedRef.current = false;
|
|
84
|
-
setData(function (prevState) { return (__assign(__assign({}, prevState), { processosJuridicosData: __assign(__assign({}, prevState.processosJuridicosData), { isLoaded: false }) })); });
|
|
85
84
|
}
|
|
86
|
-
}, [ctx.type
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
: '
|
|
99
|
-
:
|
|
100
|
-
|
|
101
|
-
};
|
|
102
|
-
}, [onClickConsultarProcessoJuridico]);
|
|
103
|
-
return (React.createElement(Section, { ctx: ctx, title: "Processos Jur\u00EDdicos", subtitle: "Veja os processos jur\u00EDdicos para este documento.", icon: ProcessosJuridicosIcon, minimized: false, onSuccess: handleSuccess }));
|
|
85
|
+
}, [ctx.type]);
|
|
86
|
+
return (React.createElement(Section, { ctx: ctx, title: "Processos Jur\u00EDdicos", subtitle: "Veja os processos jur\u00EDdicos para este documento.", icon: ProcessosJuridicosIcon, minimized: false, onSuccess: function (data) {
|
|
87
|
+
var _a;
|
|
88
|
+
var qtyProcessos = (_a = data.empresa) === null || _a === void 0 ? void 0 : _a.length;
|
|
89
|
+
var children = qtyProcessos ? (React.createElement(ProcessosJuridicosList, { processos: data.empresa || [], onClickConsultarProcessoJuridico: onClickConsultarProcessoJuridico })) : null;
|
|
90
|
+
return {
|
|
91
|
+
children: children,
|
|
92
|
+
description: (React.createElement(StatusMessage, { type: qtyProcessos ? 'error' : 'default' }, qtyProcessos
|
|
93
|
+
? 'Pesquisa concluída, ' +
|
|
94
|
+
(qtyProcessos > 1
|
|
95
|
+
? "foram encontrados ".concat(qtyProcessos, " processos")
|
|
96
|
+
: 'foi encontrado 1 processo')
|
|
97
|
+
: 'Não foram encontrados processos jurídicos para o documento pesquisado')),
|
|
98
|
+
variant: qtyProcessos ? 'error' : 'default'
|
|
99
|
+
};
|
|
100
|
+
} }));
|
|
104
101
|
};
|
|
105
|
-
export default
|
|
102
|
+
export default ProcessosJuridicos;
|