@credithub/harlan-components 1.46.3 → 1.46.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.
@@ -13,15 +13,6 @@ var __assign = (this && this.__assign) || function () {
13
13
  };
14
14
  return __assign.apply(this, arguments);
15
15
  };
16
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
17
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
18
- if (ar || !(i in from)) {
19
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
20
- ar[i] = from[i];
21
- }
22
- }
23
- return to.concat(ar || Array.prototype.slice.call(from));
24
- };
25
16
  import ResumoDeNegativacoesIcon from '../../assets/icones/resumoNegativacoes';
26
17
  import { useGlobalData } from '../../contexts/globalDataContext';
27
18
  import { converterParaFormatoValido } from '../../utils/date';
@@ -31,7 +22,7 @@ import useToggle from '../../hooks/useToggle';
31
22
  import { ConsultasComplementaresContext } from '../consultasComplementares';
32
23
  import StatusMessage from '../interface/statusMessage';
33
24
  import Section from '../section';
34
- import { Queries, RequestStatus } from '../webservice';
25
+ import { RequestStatus } from '../webservice';
35
26
  import ChartContent from './chartContent';
36
27
  import useChartData, { useDividasPublicas } from './hooks/useChartData';
37
28
  import QuantidadeResultados from './quantityResult';
@@ -41,35 +32,13 @@ var ChartSystem = function (_a) {
41
32
  var _b, _c, _d, _e, _f, _g, _h, _j;
42
33
  var documento = _a.documento;
43
34
  var ctxConsultasComplementares = useContext(ConsultasComplementaresContext);
44
- var ctxProtestosSP = useContext(Queries.Liminar);
45
35
  var setGlobalState = useGlobalData().setData;
46
36
  var _k = useState(false), dataUpdated = _k[0], setDataUpdated = _k[1];
47
37
  var ultimaOcorrenciaCCF = useUltimaOcorrenciaCCF();
48
38
  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;
49
39
  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;
50
- var _l = useState(0), totalProtestosSP = _l[0], setTotalProtestosSP = _l[1];
51
- var _m = useState(0), valorTotalProtestosSP = _m[0], setValorTotalProtestosSP = _m[1];
52
- var _o = useChartData(documento, consultaSerasa, consultaBoaVista), chartData = _o.data, isLoadingChart = _o.isLoading, errorChart = _o.error, refetchChart = _o.refetch, chartDataProgress = _o.loadingProgress;
53
- var _p = useDividasPublicas(), quantidadeDividas = _p.quantidade, valorTotalDividas = _p.valorTotal, ultimaOcorrenciaDividas = _p.ultimaOcorrencia, dividasProgress = _p.loadingProgress;
54
- useEffect(function () {
55
- if ((ctxProtestosSP === null || ctxProtestosSP === void 0 ? void 0 : ctxProtestosSP.type) === RequestStatus.Success &&
56
- ctxProtestosSP.document &&
57
- Array.isArray(ctxProtestosSP.document.data)) {
58
- var totalProtestos_1 = ctxProtestosSP.document.data.reduce(function (sum, cartorio) { return sum + Number((cartorio === null || cartorio === void 0 ? void 0 : cartorio[9]) || 0); }, 0);
59
- var valorTotal = ctxProtestosSP.document.data.reduce(function (sum, cartorio) {
60
- var _a, _b;
61
- var valorString = (_b = (_a = cartorio === null || cartorio === void 0 ? void 0 : cartorio[7]) === null || _a === void 0 ? void 0 : _a.match(/[\d,.]+/g)) === null || _b === void 0 ? void 0 : _b[0];
62
- var valor = parseFloat((valorString === null || valorString === void 0 ? void 0 : valorString.replace('.', '').replace(',', '.')) || '0');
63
- return sum + valor;
64
- }, 0);
65
- setTotalProtestosSP(totalProtestos_1);
66
- setValorTotalProtestosSP(valorTotal);
67
- }
68
- else if ((ctxProtestosSP === null || ctxProtestosSP === void 0 ? void 0 : ctxProtestosSP.type) === RequestStatus.Error) {
69
- setTotalProtestosSP(0);
70
- setValorTotalProtestosSP(0);
71
- }
72
- }, [ctxProtestosSP === null || ctxProtestosSP === void 0 ? void 0 : ctxProtestosSP.type, ctxProtestosSP === null || ctxProtestosSP === void 0 ? void 0 : ctxProtestosSP.document]);
40
+ var _l = useChartData(documento, consultaSerasa, consultaBoaVista), chartData = _l.data, isLoadingChart = _l.isLoading, errorChart = _l.error, refetchChart = _l.refetch, chartDataProgress = _l.loadingProgress;
41
+ var _m = useDividasPublicas(), quantidadeDividas = _m.quantidade, valorTotalDividas = _m.valorTotal, ultimaOcorrenciaDividas = _m.ultimaOcorrencia, dividasProgress = _m.loadingProgress;
73
42
  useEffect(function () {
74
43
  if (consultaSerasa || consultaBoaVista) {
75
44
  refetchChart();
@@ -79,8 +48,8 @@ var ChartSystem = function (_a) {
79
48
  var isOpen = useToggle(true)[0];
80
49
  var quantidadeProtestos = ((_g = (_f = chartData === null || chartData === void 0 ? void 0 : chartData.protestos) === null || _f === void 0 ? void 0 : _f[(chartData === null || chartData === void 0 ? void 0 : chartData.protestos.length) - 1]) === null || _g === void 0 ? void 0 : _g.quantidade) || 0;
81
50
  var valorTotalProtestos = ((_j = (_h = chartData === null || chartData === void 0 ? void 0 : chartData.protestos) === null || _h === void 0 ? void 0 : _h[(chartData === null || chartData === void 0 ? void 0 : chartData.protestos.length) - 1]) === null || _j === void 0 ? void 0 : _j.valorTotal) || 0;
82
- var _q = useCalculation((chartData === null || chartData === void 0 ? void 0 : chartData.serasa) || []), quantidadeSerasa = _q.quantidade, valorTotalSerasa = _q.valorTotal, ultimaOcorrenciaSerasa = _q.dataMaisRecente;
83
- var _r = useCalculation((chartData === null || chartData === void 0 ? void 0 : chartData.boaVista) || []), quantidadeBoaVista = _r.quantidade, valorTotalBoaVista = _r.valorTotal, ultimaOcorrenciaBoaVista = _r.dataMaisRecente;
51
+ var _o = useCalculation((chartData === null || chartData === void 0 ? void 0 : chartData.serasa) || []), quantidadeSerasa = _o.quantidade, valorTotalSerasa = _o.valorTotal, ultimaOcorrenciaSerasa = _o.dataMaisRecente;
52
+ var _p = useCalculation((chartData === null || chartData === void 0 ? void 0 : chartData.boaVista) || []), quantidadeBoaVista = _p.quantidade, valorTotalBoaVista = _p.valorTotal, ultimaOcorrenciaBoaVista = _p.dataMaisRecente;
84
53
  var quantidadeCCFs = useCalculation((chartData === null || chartData === void 0 ? void 0 : chartData.ccfs) || []).quantidade;
85
54
  var ultimaOcorrenciaProtestos = '';
86
55
  if ((chartData === null || chartData === void 0 ? void 0 : chartData.protestosCategory) && chartData.protestosCategory.length > 0) {
@@ -101,15 +70,13 @@ var ChartSystem = function (_a) {
101
70
  ultimaOcorrenciaProtestos = new Date(Math.max.apply(Math, datasOcorrencias)).toLocaleDateString();
102
71
  }
103
72
  }
104
- var totalProtestos = quantidadeProtestos + totalProtestosSP;
105
- var totalValorProtestos = valorTotalProtestos + valorTotalProtestosSP;
106
73
  var loadingProgress = (chartDataProgress + dividasProgress) / 2;
107
74
  useEffect(function () {
108
75
  if (!dataUpdated && chartData) {
109
76
  setGlobalState(function (prevState) {
110
77
  var _a;
111
78
  return (__assign(__assign({}, prevState), { documentHistory: {
112
- quantidadeProtestos: totalProtestos,
79
+ quantidadeProtestos: quantidadeProtestos,
113
80
  quantidadeProcessos: ((_a = chartData === null || chartData === void 0 ? void 0 : chartData.pieChartTotalConfig) === null || _a === void 0 ? void 0 : _a.processosJuridicos) || 0,
114
81
  quantidadeDividas: quantidadeDividas,
115
82
  quantidadeDividasSerasa: quantidadeSerasa,
@@ -118,7 +85,7 @@ var ChartSystem = function (_a) {
118
85
  ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF,
119
86
  valorTotalDividasSerasa: valorTotalSerasa,
120
87
  valorTotalDividasBoaVista: valorTotalBoaVista,
121
- valorTotalProtestos: totalValorProtestos,
88
+ valorTotalProtestos: valorTotalProtestos,
122
89
  valorTotalDividas: valorTotalDividas,
123
90
  ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos,
124
91
  ultimaOcorrenciaDividas: ultimaOcorrenciaDividas,
@@ -138,9 +105,7 @@ var ChartSystem = function (_a) {
138
105
  valorTotalDividas,
139
106
  ultimaOcorrenciaDividas,
140
107
  setGlobalState,
141
- ultimaOcorrenciaCCF,
142
- totalProtestos,
143
- totalValorProtestos
108
+ ultimaOcorrenciaCCF
144
109
  ]);
145
110
  return (React.createElement(Section, { ctx: {
146
111
  response: undefined,
@@ -157,14 +122,8 @@ var ChartSystem = function (_a) {
157
122
  }, 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 () {
158
123
  var _a;
159
124
  return (React.createElement(Content, { isOpen: isOpen },
160
- chartData && (React.createElement(ChartContent, { dataInput: __assign(__assign({}, chartData), { protestos: __spreadArray(__spreadArray([], chartData.protestos, true), [
161
- {
162
- quantidade: totalProtestosSP,
163
- valorTotal: valorTotalProtestosSP,
164
- data: new Date().toISOString()
165
- }
166
- ], false) }) })),
167
- React.createElement(QuantidadeResultados, { data: chartData, quantidadeProtestos: totalProtestos, quantidadeProcessos: (_a = chartData === null || chartData === void 0 ? void 0 : chartData.pieChartTotalConfig) === null || _a === void 0 ? void 0 : _a.processosJuridicos, quantidadeDividas: quantidadeDividas, quantidadeDividasSerasa: quantidadeSerasa, quantidadeDividasBoaVista: quantidadeBoaVista, quantidadeChequesSemFundos: quantidadeCCFs, ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF, valorTotalDividasSerasa: valorTotalSerasa, valorTotalDividasBoaVista: valorTotalBoaVista, valorTotalProtestos: totalValorProtestos, valorTotalDividas: valorTotalDividas, ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos, ultimaOcorrenciaDividas: ultimaOcorrenciaDividas, ultimaOcorrenciaPefinBoaVista: quantidadeBoaVista > 0
125
+ chartData && React.createElement(ChartContent, { dataInput: chartData }),
126
+ React.createElement(QuantidadeResultados, { data: chartData, quantidadeProtestos: quantidadeProtestos, quantidadeProcessos: (_a = chartData === null || chartData === void 0 ? void 0 : chartData.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
168
127
  ? (ultimaOcorrenciaBoaVista !== null && ultimaOcorrenciaBoaVista !== void 0 ? ultimaOcorrenciaBoaVista : undefined)
169
128
  : undefined, ultimaOcorrenciaPefinSerasa: quantidadeSerasa > 0
170
129
  ? (ultimaOcorrenciaSerasa !== null && ultimaOcorrenciaSerasa !== void 0 ? ultimaOcorrenciaSerasa : undefined)
@@ -70,6 +70,8 @@ var ConsultaSimplesSection = function (_a) {
70
70
  var possuiPendenciaText = getPossuiPendenciaText(__assign(__assign({}, data), { receitaStatus: receitaStatus, liminar: data.liminar }));
71
71
  var isError = (ctx === null || ctx === void 0 ? void 0 : ctx.type) === RequestStatus.Error;
72
72
  var isLoading = (ctx === null || ctx === void 0 ? void 0 : ctx.type) === RequestStatus.Loading;
73
+ var isDataReady = !isLoading &&
74
+ (possuiPendenciaText.length > 0 || possuiPendencias || isError);
73
75
  var statusType = isError
74
76
  ? 'warning'
75
77
  : possuiPendencias
@@ -79,9 +81,7 @@ var ConsultaSimplesSection = function (_a) {
79
81
  React.createElement(StatusMessage, null, format(new Date(), "dd/MM/yyyy 'às' HH:mm")),
80
82
  React.createElement(StatusMessage, { type: "found" }, formatDocument(documento)),
81
83
  isError && (ctx === null || ctx === void 0 ? void 0 : ctx.error) && (React.createElement(StatusMessage, { type: statusType }, ctx.error.message)),
82
- !isLoading &&
83
- possuiPendenciaText.length === 0 &&
84
- !possuiPendencias ? (React.createElement(StatusMessage, { type: statusType }, "Nenhum registro encontrado")) : (possuiPendenciaText.map(function (text) { return (React.createElement(StatusMessage, { key: text, type: "error" }, text)); }))), onClose: onClose, icon: ConsultaSimplesIcon, variant: isLoading ? 'loading' : 'default', ctx: ctx, loadingProps: {
84
+ isDataReady ? (possuiPendenciaText.length === 0 && !possuiPendencias ? (React.createElement(StatusMessage, { type: statusType }, "Nenhum registro encontrado")) : (possuiPendenciaText.map(function (text) { return (React.createElement(StatusMessage, { key: text, type: "error" }, text)); }))) : null), onClose: onClose, icon: ConsultaSimplesIcon, variant: isLoading ? 'loading' : 'default', ctx: ctx, loadingProps: {
85
85
  percentage: (ctx === null || ctx === void 0 ? void 0 : ctx.progress) || 0,
86
86
  hidden: !isLoading
87
87
  } }, rest), children));