@credithub/harlan-components 1.45.1 → 1.46.1

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,6 +13,15 @@ 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
+ };
16
25
  import ResumoDeNegativacoesIcon from '../../assets/icones/resumoNegativacoes';
17
26
  import { useGlobalData } from '../../contexts/globalDataContext';
18
27
  import { converterParaFormatoValido } from '../../utils/date';
@@ -22,7 +31,7 @@ import useToggle from '../../hooks/useToggle';
22
31
  import { ConsultasComplementaresContext } from '../consultasComplementares';
23
32
  import StatusMessage from '../interface/statusMessage';
24
33
  import Section from '../section';
25
- import { RequestStatus } from '../webservice';
34
+ import { Queries, RequestStatus } from '../webservice';
26
35
  import ChartContent from './chartContent';
27
36
  import useChartData, { useDividasPublicas } from './hooks/useChartData';
28
37
  import QuantidadeResultados from './quantityResult';
@@ -32,13 +41,35 @@ var ChartSystem = function (_a) {
32
41
  var _b, _c, _d, _e, _f, _g, _h, _j;
33
42
  var documento = _a.documento;
34
43
  var ctxConsultasComplementares = useContext(ConsultasComplementaresContext);
44
+ var ctxProtestosSP = useContext(Queries.Liminar);
35
45
  var setGlobalState = useGlobalData().setData;
36
46
  var _k = useState(false), dataUpdated = _k[0], setDataUpdated = _k[1];
37
47
  var ultimaOcorrenciaCCF = useUltimaOcorrenciaCCF();
38
48
  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;
39
49
  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;
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;
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]);
42
73
  useEffect(function () {
43
74
  if (consultaSerasa || consultaBoaVista) {
44
75
  refetchChart();
@@ -48,8 +79,8 @@ var ChartSystem = function (_a) {
48
79
  var isOpen = useToggle(true)[0];
49
80
  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;
50
81
  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;
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;
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;
53
84
  var quantidadeCCFs = useCalculation((chartData === null || chartData === void 0 ? void 0 : chartData.ccfs) || []).quantidade;
54
85
  var ultimaOcorrenciaProtestos = '';
55
86
  if ((chartData === null || chartData === void 0 ? void 0 : chartData.protestosCategory) && chartData.protestosCategory.length > 0) {
@@ -70,13 +101,15 @@ var ChartSystem = function (_a) {
70
101
  ultimaOcorrenciaProtestos = new Date(Math.max.apply(Math, datasOcorrencias)).toLocaleDateString();
71
102
  }
72
103
  }
104
+ var totalProtestos = quantidadeProtestos + totalProtestosSP;
105
+ var totalValorProtestos = valorTotalProtestos + valorTotalProtestosSP;
73
106
  var loadingProgress = (chartDataProgress + dividasProgress) / 2;
74
107
  useEffect(function () {
75
108
  if (!dataUpdated && chartData) {
76
109
  setGlobalState(function (prevState) {
77
110
  var _a;
78
111
  return (__assign(__assign({}, prevState), { documentHistory: {
79
- quantidadeProtestos: quantidadeProtestos,
112
+ quantidadeProtestos: totalProtestos,
80
113
  quantidadeProcessos: ((_a = chartData === null || chartData === void 0 ? void 0 : chartData.pieChartTotalConfig) === null || _a === void 0 ? void 0 : _a.processosJuridicos) || 0,
81
114
  quantidadeDividas: quantidadeDividas,
82
115
  quantidadeDividasSerasa: quantidadeSerasa,
@@ -85,7 +118,7 @@ var ChartSystem = function (_a) {
85
118
  ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF,
86
119
  valorTotalDividasSerasa: valorTotalSerasa,
87
120
  valorTotalDividasBoaVista: valorTotalBoaVista,
88
- valorTotalProtestos: valorTotalProtestos,
121
+ valorTotalProtestos: totalValorProtestos,
89
122
  valorTotalDividas: valorTotalDividas,
90
123
  ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos,
91
124
  ultimaOcorrenciaDividas: ultimaOcorrenciaDividas,
@@ -105,7 +138,9 @@ var ChartSystem = function (_a) {
105
138
  valorTotalDividas,
106
139
  ultimaOcorrenciaDividas,
107
140
  setGlobalState,
108
- ultimaOcorrenciaCCF
141
+ ultimaOcorrenciaCCF,
142
+ totalProtestos,
143
+ totalValorProtestos
109
144
  ]);
110
145
  return (React.createElement(Section, { ctx: {
111
146
  response: undefined,
@@ -122,8 +157,14 @@ var ChartSystem = function (_a) {
122
157
  }, 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 () {
123
158
  var _a;
124
159
  return (React.createElement(Content, { isOpen: isOpen },
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
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
127
168
  ? (ultimaOcorrenciaBoaVista !== null && ultimaOcorrenciaBoaVista !== void 0 ? ultimaOcorrenciaBoaVista : undefined)
128
169
  : undefined, ultimaOcorrenciaPefinSerasa: quantidadeSerasa > 0
129
170
  ? (ultimaOcorrenciaSerasa !== null && ultimaOcorrenciaSerasa !== void 0 ? ultimaOcorrenciaSerasa : undefined)
@@ -43,10 +43,10 @@ var Protestos = function () {
43
43
  var _a = useState(false), dataUpdated = _a[0], setDataUpdated = _a[1];
44
44
  var total = useMemo(function () {
45
45
  var _a, _b;
46
- if (ctxLiminar.type === RequestStatus.Success)
47
- return ((_b = (_a = ctxLiminar === null || ctxLiminar === void 0 ? void 0 : ctxLiminar.document) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.reduce(function (carry, e) { return carry + Number(e[9]); }, 0)) || 0;
46
+ if ((ctxLiminar === null || ctxLiminar === void 0 ? void 0 : ctxLiminar.type) === RequestStatus.Success)
47
+ return ((_b = (_a = ctxLiminar === null || ctxLiminar === void 0 ? void 0 : ctxLiminar.document) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.reduce(function (carry, e) { return carry + Number(e === null || e === void 0 ? void 0 : e[9]); }, 0)) || 0;
48
48
  return 0;
49
- }, [ctxLiminar.type]);
49
+ }, [ctxLiminar === null || ctxLiminar === void 0 ? void 0 : ctxLiminar.type]);
50
50
  useEffect(function () {
51
51
  if (ctx.type !== RequestStatus.Success || dataUpdated || !ctx.document) {
52
52
  return;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const ProtestosSP: React.FC;
3
+ export default ProtestosSP;
@@ -0,0 +1,62 @@
1
+ import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
2
+ import { Queries, RequestStatus } from "../webservice";
3
+ import Section from '../section';
4
+ import ProtestosIcon from "../../assets/icones/protestos";
5
+ import StatusMessage from "../interface/statusMessage";
6
+ import { useGlobalData } from "../../contexts/globalDataContext";
7
+ import { ResultContent } from "../interface/result";
8
+ import AddItemField from "../common/addItem";
9
+ import { formatMoney } from "../../utils/number";
10
+ var ProtestosSP = function () {
11
+ var ctxLiminar = useContext(Queries.Liminar);
12
+ var setData = useGlobalData().setData;
13
+ var _a = useState(false), dataUpdated = _a[0], setDataUpdated = _a[1];
14
+ var _b = useState(false), hideSection = _b[0], setHideSection = _b[1];
15
+ var prevCtxTypeRef = useRef(null);
16
+ useEffect(function () {
17
+ if (ctxLiminar.type === RequestStatus.Success &&
18
+ prevCtxTypeRef.current !== RequestStatus.Success &&
19
+ !dataUpdated &&
20
+ ctxLiminar.document) {
21
+ var doc = ctxLiminar.document;
22
+ var possuiProtestos = doc.totalProtestos === 'CONSTAM PROTESTOS';
23
+ var message = possuiProtestos ? 'Encontrado' : 'Não encontrado';
24
+ /*setData((prevState: GlobalState) => ({
25
+ ...prevState,
26
+ liminar: { totalProtestos: doc.totalProtestos },
27
+ message: message
28
+ }));*/
29
+ //setDataUpdated(true);
30
+ if (!possuiProtestos) {
31
+ setHideSection(true);
32
+ }
33
+ }
34
+ prevCtxTypeRef.current = ctxLiminar.type;
35
+ }, [ctxLiminar.type, ctxLiminar.document, dataUpdated, setData]);
36
+ var possuiProtestosSp = useMemo(function () {
37
+ var _a;
38
+ if ((ctxLiminar === null || ctxLiminar === void 0 ? void 0 : ctxLiminar.type) === RequestStatus.Success)
39
+ return ['NADA CONSTA', 'CONSTAM PROTESTOS'].includes(((_a = ctxLiminar === null || ctxLiminar === void 0 ? void 0 : ctxLiminar.document) === null || _a === void 0 ? void 0 : _a.totalProtestos) || '');
40
+ return false;
41
+ }, [ctxLiminar === null || ctxLiminar === void 0 ? void 0 : ctxLiminar.type]);
42
+ return React.createElement(Section, { ctx: ctxLiminar, title: "Protestos SP", subtitle: "Consulta de protestos nos cart\u00F3rios de SP", icon: ProtestosIcon, onSuccess: function (_a) {
43
+ var data = _a.data, totalProtestos = _a.totalProtestos;
44
+ var registros = (data === null || data === void 0 ? void 0 : data.reduce(function (carry, cartorio) { return Number(cartorio === null || cartorio === void 0 ? void 0 : cartorio[9]) + carry; }, 0)) || 0;
45
+ return {
46
+ children: data === null || data === void 0 ? void 0 : data.map(function (e) {
47
+ var _a, _b, _c, _d;
48
+ return (React.createElement(ResultContent, { print: "repeat(7, 1fr)", desktop: "repeat(8, 1fr)", tablet: "repeat(4, 1fr)", mobile: "repeat(2, 1fr)" },
49
+ React.createElement(AddItemField, { name: "Cartorio", value: e === null || e === void 0 ? void 0 : e[2] }),
50
+ React.createElement(AddItemField, { name: "Quantidade", value: e === null || e === void 0 ? void 0 : e[9] }),
51
+ React.createElement(AddItemField, { name: "Valor Total", value: formatMoney((_d = (_c = (_b = (_a = e === null || e === void 0 ? void 0 : e[7]) === null || _a === void 0 ? void 0 : _a.match(/[\d,.]+/g)) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.replace('.', "")) === null || _d === void 0 ? void 0 : _d.replace(',', '.')) })));
52
+ }),
53
+ variant: registros ? 'error' : 'default',
54
+ description: (React.createElement(StatusMessage, { type: registros ? 'error' : 'default' }, possuiProtestosSp && !registros ? 'Existem protestos' : registros
55
+ ? registros === 1
56
+ ? 'Encontrado um protesto'
57
+ : "Encontrados ".concat(registros, " protestos")
58
+ : 'Não há ocorrência de protesto'))
59
+ };
60
+ } });
61
+ };
62
+ export default ProtestosSP;
@@ -17,6 +17,7 @@ import ConsultaSCR from './components/scr/scr';
17
17
  import { GlobalDataProvider } from './contexts/globalDataContext';
18
18
  import GlobalStyle from './styles/globalStyle';
19
19
  import theme from './styles/theme';
20
+ import ProtestosSP from './components/protestos/protestosSp';
20
21
  Chart.register.apply(Chart, registerables);
21
22
  var Wrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-family: 'Open Sans Condensed';\n display: flex;\n flex-direction: column;\n gap: 20px;\n\n * {\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n }\n\n @media print {\n @page {\n size: auto;\n margin: 5mm;\n }\n }\n"], ["\n font-family: 'Open Sans Condensed';\n display: flex;\n flex-direction: column;\n gap: 20px;\n\n * {\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n }\n\n @media print {\n @page {\n size: auto;\n margin: 5mm;\n }\n }\n"])));
22
23
  var FinderDependency = function (_a) {
@@ -55,6 +56,7 @@ var ConsultaSimples = function (_a) {
55
56
  React.createElement(ConsultaScore, { documento: documento }),
56
57
  React.createElement(ConsultaImoveis, { documento: documento }),
57
58
  React.createElement(Veiculos, { documento: documento })),
59
+ React.createElement(ProtestosSP, null),
58
60
  React.createElement(Protestos, null),
59
61
  React.createElement(CCF, null),
60
62
  React.createElement(DividasPublicas, null),