@credithub/harlan-components 1.104.0 → 1.105.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.
|
@@ -7,7 +7,11 @@ var useChartData = function (consultaSerasa, consultaBoaVista) {
|
|
|
7
7
|
var _b = useState(null), data = _b[0], setData = _b[1];
|
|
8
8
|
var _c = useState(null), errorState = _c[0], setErrorState = _c[1];
|
|
9
9
|
var _d = useState(0), loadingProgress = _d[0], _setLoadingProgress = _d[1];
|
|
10
|
+
var _e = useState(false), isProcessing = _e[0], setIsProcessing = _e[1];
|
|
11
|
+
var _f = useState(false), dataReady = _f[0], setDataReady = _f[1];
|
|
10
12
|
var lastProgress = useRef(0);
|
|
13
|
+
var lastProcessedDocument = useRef(null);
|
|
14
|
+
var processingTimeout = useRef(null);
|
|
11
15
|
var ctxHistory = useContext(Queries.GraficosAnaliticos);
|
|
12
16
|
var ctxProtestos = useContext(Queries.Protestos);
|
|
13
17
|
var ctxCCF = useContext(Queries.CCF);
|
|
@@ -36,15 +40,22 @@ var useChartData = function (consultaSerasa, consultaBoaVista) {
|
|
|
36
40
|
(_d = ctxProcessos.progress) !== null && _d !== void 0 ? _d : 0
|
|
37
41
|
];
|
|
38
42
|
var avg = parts.reduce(function (sum, p) { return sum + p; }, 0) / parts.length;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
// Se está processando dados, mostra 95% para indicar processamento
|
|
44
|
+
var adjustedProgress = avg;
|
|
45
|
+
if (isProcessing && avg === 100) {
|
|
46
|
+
adjustedProgress = 95;
|
|
47
|
+
}
|
|
48
|
+
if (adjustedProgress === 100 ||
|
|
49
|
+
Math.abs(adjustedProgress - lastProgress.current) >= 10) {
|
|
50
|
+
lastProgress.current = adjustedProgress;
|
|
51
|
+
_setLoadingProgress(adjustedProgress);
|
|
42
52
|
}
|
|
43
53
|
}, [
|
|
44
54
|
ctxHistory.progress,
|
|
45
55
|
ctxProtestos.progress,
|
|
46
56
|
ctxCCF.progress,
|
|
47
|
-
ctxProcessos.progress
|
|
57
|
+
ctxProcessos.progress,
|
|
58
|
+
isProcessing
|
|
48
59
|
]);
|
|
49
60
|
var lastComplementary = useRef({
|
|
50
61
|
serasa: null,
|
|
@@ -62,35 +73,102 @@ var useChartData = function (consultaSerasa, consultaBoaVista) {
|
|
|
62
73
|
}
|
|
63
74
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
75
|
}, [consultaSerasa, consultaBoaVista]);
|
|
76
|
+
// Verifica se todos os contextos necessários terminaram de carregar
|
|
77
|
+
var allContextsReady = useMemo(function () {
|
|
78
|
+
return (ctxHistory.type !== RequestStatus.Loading &&
|
|
79
|
+
ctxProtestos.type !== RequestStatus.Loading &&
|
|
80
|
+
ctxCCF.type !== RequestStatus.Loading &&
|
|
81
|
+
ctxProcessos.type !== RequestStatus.Loading &&
|
|
82
|
+
ctxHistory.type === RequestStatus.Success &&
|
|
83
|
+
ctxProtestos.type === RequestStatus.Success &&
|
|
84
|
+
ctxCCF.type === RequestStatus.Success &&
|
|
85
|
+
ctxProcessos.type === RequestStatus.Success);
|
|
86
|
+
}, [ctxHistory.type, ctxProtestos.type, ctxCCF.type, ctxProcessos.type]);
|
|
65
87
|
useEffect(function () {
|
|
66
88
|
var _a;
|
|
67
|
-
|
|
89
|
+
// Limpa timeout anterior se existir
|
|
90
|
+
if (processingTimeout.current) {
|
|
91
|
+
clearTimeout(processingTimeout.current);
|
|
92
|
+
processingTimeout.current = null;
|
|
93
|
+
}
|
|
94
|
+
// Reset quando qualquer contexto volta para Loading
|
|
95
|
+
if (ctxHistory.type === RequestStatus.Loading ||
|
|
96
|
+
ctxProtestos.type === RequestStatus.Loading ||
|
|
97
|
+
ctxCCF.type === RequestStatus.Loading ||
|
|
98
|
+
ctxProcessos.type === RequestStatus.Loading) {
|
|
99
|
+
setDataReady(false);
|
|
68
100
|
setErrorState(null);
|
|
101
|
+
setIsProcessing(false);
|
|
102
|
+
return;
|
|
69
103
|
}
|
|
70
|
-
|
|
104
|
+
if (ctxHistory.type === RequestStatus.Error) {
|
|
71
105
|
setErrorState(((_a = ctxHistory.error) === null || _a === void 0 ? void 0 : _a.message) || 'Erro ao consultar histórico');
|
|
106
|
+
setIsProcessing(false);
|
|
107
|
+
setDataReady(false);
|
|
108
|
+
lastProcessedDocument.current = null;
|
|
109
|
+
return;
|
|
72
110
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
setData(processed);
|
|
80
|
-
}
|
|
81
|
-
catch (_b) {
|
|
82
|
-
setErrorState('Erro ao processar os dados');
|
|
111
|
+
// Só processa quando TODOS os contextos estiverem prontos
|
|
112
|
+
if (allContextsReady && ctxHistory.document) {
|
|
113
|
+
var documentSnapshot_1 = ctxHistory.document;
|
|
114
|
+
// Evita processar o mesmo documento múltiplas vezes
|
|
115
|
+
if (lastProcessedDocument.current === documentSnapshot_1) {
|
|
116
|
+
return;
|
|
83
117
|
}
|
|
118
|
+
// Marca como processando
|
|
119
|
+
setIsProcessing(true);
|
|
120
|
+
setDataReady(false);
|
|
121
|
+
lastProcessedDocument.current = documentSnapshot_1;
|
|
122
|
+
// Usa setTimeout para permitir que a UI atualize o estado de loading
|
|
123
|
+
processingTimeout.current = setTimeout(function () {
|
|
124
|
+
try {
|
|
125
|
+
if (!documentSnapshot_1) {
|
|
126
|
+
throw new Error('Document is undefined');
|
|
127
|
+
}
|
|
128
|
+
var parsed = JSON.parse(documentSnapshot_1);
|
|
129
|
+
parsed.protestosCategory = dadosProtestos;
|
|
130
|
+
var processed = processData(structuredClone(parsed), quantidadeProcessos);
|
|
131
|
+
setData(processed);
|
|
132
|
+
setIsProcessing(false);
|
|
133
|
+
setDataReady(true);
|
|
134
|
+
// Garante que o progresso chegue a 100% quando dados estão prontos
|
|
135
|
+
_setLoadingProgress(100);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
console.error('[useChartData] Erro ao processar dados:', error);
|
|
139
|
+
setErrorState('Erro ao processar os dados');
|
|
140
|
+
setIsProcessing(false);
|
|
141
|
+
setDataReady(false);
|
|
142
|
+
}
|
|
143
|
+
processingTimeout.current = null;
|
|
144
|
+
}, 0);
|
|
84
145
|
}
|
|
85
146
|
}, [
|
|
86
147
|
ctxHistory.type,
|
|
148
|
+
ctxProtestos.type,
|
|
149
|
+
ctxCCF.type,
|
|
150
|
+
ctxProcessos.type,
|
|
87
151
|
ctxHistory.document,
|
|
88
152
|
dadosProtestos,
|
|
89
|
-
quantidadeProcessos
|
|
153
|
+
quantidadeProcessos,
|
|
154
|
+
allContextsReady
|
|
90
155
|
]);
|
|
156
|
+
// Cleanup do timeout quando componente desmonta
|
|
157
|
+
useEffect(function () {
|
|
158
|
+
return function () {
|
|
159
|
+
if (processingTimeout.current) {
|
|
160
|
+
clearTimeout(processingTimeout.current);
|
|
161
|
+
processingTimeout.current = null;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}, []);
|
|
165
|
+
// Verifica se está carregando - aguarda TODOS os contextos necessários terminarem
|
|
166
|
+
// E aguarda o processamento E renderização dos dados estar completo
|
|
167
|
+
// Só sai de loading quando dataReady === true (todos os contextos prontos + dados processados)
|
|
168
|
+
var isLoading = !dataReady || isProcessing || !allContextsReady;
|
|
91
169
|
return {
|
|
92
170
|
data: data,
|
|
93
|
-
isLoading:
|
|
171
|
+
isLoading: isLoading,
|
|
94
172
|
error: errorState,
|
|
95
173
|
refetch: ctxHistory.refetch,
|
|
96
174
|
loadingProgress: loadingProgress
|
|
@@ -6,15 +6,16 @@ import { formatDocument } from '../../utils/string';
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
import AddItemField from '../common/addItem';
|
|
9
|
-
import { ResultContent } from '../interface/result';
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
9
|
+
import { ResultContent as BaseResultContent } from '../interface/result';
|
|
10
|
+
var ResultContent = styled(BaseResultContent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 18px 20px;\n"], ["\n padding: 18px 20px;\n"])));
|
|
11
|
+
var EditalContainer = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n gap: 20px;\n margin-top: 20px;\n padding: 0 20px;\n"], ["\n display: flex;\n flex-direction: column;\n gap: 20px;\n margin-top: 20px;\n padding: 0 20px;\n"])));
|
|
12
|
+
var EditalCard = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: #f8f9fa;\n border-radius: 8px;\n padding: 0;\n border-left: 4px solid #dc3545;\n overflow: hidden;\n"], ["\n background: #f8f9fa;\n border-radius: 8px;\n padding: 0;\n border-left: 4px solid #dc3545;\n overflow: hidden;\n"])));
|
|
13
|
+
var EditalHeader = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n border-bottom: 1px solid #dee2e6;\n"], ["\n border-bottom: 1px solid #dee2e6;\n"])));
|
|
14
|
+
var EditalTitle = styled.h4(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin: 0;\n padding: 18px 20px 12px 20px;\n color: #212529;\n font-size: 16px;\n font-weight: 600;\n"], ["\n margin: 0;\n padding: 18px 20px 12px 20px;\n color: #212529;\n font-size: 16px;\n font-weight: 600;\n"])));
|
|
15
|
+
var EditalText = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding: 18px 20px;\n background: white;\n font-size: 14px;\n line-height: 1.6;\n color: #495057;\n border-top: 1px solid #dee2e6;\n border-bottom: 1px solid #dee2e6;\n\n strong {\n display: block;\n margin-bottom: 10px;\n color: #212529;\n }\n"], ["\n padding: 18px 20px;\n background: white;\n font-size: 14px;\n line-height: 1.6;\n color: #495057;\n border-top: 1px solid #dee2e6;\n border-bottom: 1px solid #dee2e6;\n\n strong {\n display: block;\n margin-bottom: 10px;\n color: #212529;\n }\n"])));
|
|
16
|
+
var TitulosSection = styled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding: 18px 0;\n"], ["\n padding: 18px 0;\n"])));
|
|
17
|
+
var TitulosSectionTitle = styled.h5(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n margin: 0 0 20px 0;\n padding: 0 20px;\n color: #495057;\n font-size: 14px;\n font-weight: 600;\n text-transform: uppercase;\n"], ["\n margin: 0 0 20px 0;\n padding: 0 20px;\n color: #495057;\n font-size: 14px;\n font-weight: 600;\n text-transform: uppercase;\n"])));
|
|
18
|
+
var TituloCard = styled.div(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n background: white;\n border-radius: 6px;\n margin: 0 20px 12px 20px;\n border: 1px solid #dee2e6;\n\n &:last-child {\n margin-bottom: 0;\n }\n"], ["\n background: white;\n border-radius: 6px;\n margin: 0 20px 12px 20px;\n border: 1px solid #dee2e6;\n\n &:last-child {\n margin-bottom: 0;\n }\n"])));
|
|
18
19
|
var formatDate = function (dateStr) {
|
|
19
20
|
if (!dateStr)
|
|
20
21
|
return '-';
|
|
@@ -51,7 +52,8 @@ var EditalList = function (_a) {
|
|
|
51
52
|
React.createElement(EditalTitle, null,
|
|
52
53
|
"Edital #",
|
|
53
54
|
edital.cd_arquivo_editalEletronico,
|
|
54
|
-
" -
|
|
55
|
+
" -",
|
|
56
|
+
' ',
|
|
55
57
|
edital.nome_cartorio),
|
|
56
58
|
React.createElement(ResultContent, { print: "repeat(3, 1fr)", desktop: "repeat(3, 1fr)", tablet: "repeat(2, 1fr)", mobile: "1fr" },
|
|
57
59
|
React.createElement(AddItemField, { name: "Cart\u00F3rio", value: edital.nome_cartorio }),
|
|
@@ -83,4 +85,4 @@ var EditalList = function (_a) {
|
|
|
83
85
|
})));
|
|
84
86
|
};
|
|
85
87
|
export default EditalList;
|
|
86
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
|
|
88
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
|
|
@@ -13,13 +13,25 @@ import ProtestosIcon from '../../assets/icones/protestos';
|
|
|
13
13
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
14
14
|
import { formatMoney } from '../../utils/number';
|
|
15
15
|
import { formatDocument } from '../../utils/string';
|
|
16
|
-
import React, { useEffect, useMemo, useRef } from 'react';
|
|
16
|
+
import React, { memo, useEffect, useMemo, useRef } from 'react';
|
|
17
17
|
import AddItemField from '../common/addItem';
|
|
18
|
-
import { ResultContent } from '../interface/result';
|
|
18
|
+
import { Result, ResultContent } from '../interface/result';
|
|
19
19
|
import StatusMessage from '../interface/statusMessage';
|
|
20
20
|
import Section from '../section';
|
|
21
21
|
import { RequestStatus } from '../webservice';
|
|
22
22
|
import { adaptToUI, buildChartSeries } from './adaptToChart';
|
|
23
|
+
// Componente individual para cada protesto pago/baixado
|
|
24
|
+
var ProtestoHistoricoItemComponent = memo(function (_a) {
|
|
25
|
+
var protesto = _a.protesto;
|
|
26
|
+
return (React.createElement(ResultContent, { print: "repeat(7, 1fr)", desktop: "repeat(8, 1fr)", tablet: "repeat(4, 1fr)", mobile: "repeat(2, 1fr)" },
|
|
27
|
+
React.createElement(AddItemField, { name: "Quem Protestou", value: protesto.nomeCedente }),
|
|
28
|
+
React.createElement(AddItemField, { name: "Atrav\u00E9s De", value: protesto.nomeApresentante }),
|
|
29
|
+
React.createElement(AddItemField, { name: "CPF/CNPJ Protestado", value: formatDocument(protesto.cpfCnpj) }),
|
|
30
|
+
React.createElement(AddItemField, { name: "Data Do Protesto", value: protesto.dataProtesto }),
|
|
31
|
+
React.createElement(AddItemField, { name: "Possui Anu\u00EAncia / Protesto Pago", value: protesto.temAnuencia ? 'Sim' : 'Não' }),
|
|
32
|
+
React.createElement(AddItemField, { name: "Valor Do Protesto", value: formatMoney(protesto.valor) })));
|
|
33
|
+
});
|
|
34
|
+
ProtestoHistoricoItemComponent.displayName = 'ProtestoHistoricoItemComponent';
|
|
23
35
|
var ProtestosPagosBaixados = function (_a) {
|
|
24
36
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
25
37
|
var _p = _a.isFinancial, isFinancial = _p === void 0 ? false : _p;
|
|
@@ -74,12 +86,13 @@ var ProtestosPagosBaixados = function (_a) {
|
|
|
74
86
|
? 'Não foram encontradas ocorrências'
|
|
75
87
|
: ((_j = (_h = data === null || data === void 0 ? void 0 : data.protestosPagosBaixados) === null || _h === void 0 ? void 0 : _h.protestos) === null || _j === void 0 ? void 0 : _j.length) === 1
|
|
76
88
|
? 'Foi encontrado um protesto'
|
|
77
|
-
: "Foram encontrados ".concat((_l = (_k = data === null || data === void 0 ? void 0 : data.protestosPagosBaixados) === null || _k === void 0 ? void 0 : _k.protestos) === null || _l === void 0 ? void 0 : _l.length, " protestos")), variant: ((_o = (_m = data === null || data === void 0 ? void 0 : data.protestosPagosBaixados) === null || _m === void 0 ? void 0 : _m.protestos) === null || _o === void 0 ? void 0 : _o.length) ? 'error' : 'default', icon: ProtestosIcon, onSuccess: function () {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
React.createElement(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
: "Foram encontrados ".concat((_l = (_k = data === null || data === void 0 ? void 0 : data.protestosPagosBaixados) === null || _k === void 0 ? void 0 : _k.protestos) === null || _l === void 0 ? void 0 : _l.length, " protestos")), variant: ((_o = (_m = data === null || data === void 0 ? void 0 : data.protestosPagosBaixados) === null || _m === void 0 ? void 0 : _m.protestos) === null || _o === void 0 ? void 0 : _o.length) ? 'error' : 'default', icon: ProtestosIcon, onSuccess: function () {
|
|
90
|
+
var protestosAdaptados = adaptToUI(items);
|
|
91
|
+
var totalProtestos = protestosAdaptados.length;
|
|
92
|
+
var children = totalProtestos ? (React.createElement(Result, null, protestosAdaptados.map(function (protesto) { return (React.createElement(ProtestoHistoricoItemComponent, { key: protesto.chave, protesto: protesto })); }))) : null;
|
|
93
|
+
return {
|
|
94
|
+
children: children
|
|
95
|
+
};
|
|
96
|
+
} }));
|
|
84
97
|
};
|
|
85
98
|
export default ProtestosPagosBaixados;
|