@credithub/harlan-components 1.18.3 → 1.18.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/lib/cjs/index.js CHANGED
@@ -64833,28 +64833,35 @@ var __makeTemplateObject$6 = (undefined && undefined.__makeTemplateObject) || fu
64833
64833
  };
64834
64834
  var Content$1 = styled.div(templateObject_1$6 || (templateObject_1$6 = __makeTemplateObject$6(["\n display: ", ";\n"], ["\n display: ", ";\n"])), function (props) { return (props.isOpen ? "block" : "none"); });
64835
64835
  var ChartSystem = function (_a) {
64836
- var _b, _c, _d, _e, _f;
64836
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k;
64837
64837
  var documento = _a.documento;
64838
- var _g = useChartData(documento), data = _g.data, isLoading = _g.isLoading, error = _g.error;
64838
+ var _l = useChartData(documento), data = _l.data, isLoading = _l.isLoading, error = _l.error, refetch = _l.refetch;
64839
+ var ctxConsultasComplementares = React.useContext(ConsultasComplementaresContext);
64839
64840
  var errorMessage = typeof error === "string" ? error : error === null || error === void 0 ? void 0 : error.toString();
64840
- var _h = useToggle(true), isOpen = _h[0], toggleOpen = _h[1];
64841
+ var _m = useToggle(true), isOpen = _m[0], toggleOpen = _m[1];
64841
64842
  var ultimaOcorrenciaCCF = useUltimaOcorrenciaCCF();
64842
64843
  var quantidadeProtestos = ((_c = (_b = data === null || data === void 0 ? void 0 : data.protestos) === null || _b === void 0 ? void 0 : _b[(data === null || data === void 0 ? void 0 : data.protestos.length) - 1]) === null || _c === void 0 ? void 0 : _c.quantidade) || 0;
64843
64844
  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;
64844
- var _j = useDividasPublicas(), quantidadeDividas = _j.quantidade, valorTotalDividas = _j.valorTotal;
64845
- var _k = useCalculation((data === null || data === void 0 ? void 0 : data.serasa) || []), quantidadeSerasa = _k.quantidade, valorTotalSerasa = _k.valorTotal;
64846
- var _l = useCalculation((data === null || data === void 0 ? void 0 : data.boaVista) || []), quantidadeBoaVista = _l.quantidade, valorTotalBoaVista = _l.valorTotal;
64845
+ var _o = useDividasPublicas(), quantidadeDividas = _o.quantidade, valorTotalDividas = _o.valorTotal;
64846
+ var _p = useCalculation((data === null || data === void 0 ? void 0 : data.serasa) || []), quantidadeSerasa = _p.quantidade, valorTotalSerasa = _p.valorTotal;
64847
+ var _q = useCalculation((data === null || data === void 0 ? void 0 : data.boaVista) || []), quantidadeBoaVista = _q.quantidade, valorTotalBoaVista = _q.valorTotal;
64847
64848
  var quantidadeCCFs = useCalculation((data === null || data === void 0 ? void 0 : data.ccfs) || []).quantidade;
64848
64849
  var ultimaOcorrenciaProtestos = "";
64849
64850
  if ((data === null || data === void 0 ? void 0 : data.protestos) && data.protestos.length > 0) {
64850
64851
  ultimaOcorrenciaProtestos = new Date(data.protestos[data.protestos.length - 1].data).toLocaleDateString();
64851
64852
  }
64853
+ 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;
64854
+ 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;
64855
+ React.useEffect(function () {
64856
+ if (consultaPefinBoaVista || consultaPefinSerasa)
64857
+ refetch();
64858
+ }, [consultaPefinBoaVista, consultaPefinSerasa]);
64852
64859
  return (React.createElement(React.Fragment, null,
64853
64860
  React.createElement(Header$1, { title: "Resumo de Negativa\u00E7\u00F5es", subtitle: "Veja a quantidade de ocorr\u00EAncias conforme o documento foi consultado ao longo do tempo", description: errorMessage && (React.createElement(StatusMessage, { type: "error" }, errorMessage)), variant: isLoading ? "loading" : "default", icon: ResumoDeNegativacoesIcon, actions: React.createElement(BtnWrapper, { onClick: toggleOpen }, isOpen ? React.createElement(ChevronUp, null) : React.createElement(ChevronDown, null)) }),
64854
64861
  React.createElement(Result, null,
64855
64862
  React.createElement(Content$1, { isOpen: isOpen },
64856
64863
  data && React.createElement(ChartContent, { dataInput: data }),
64857
- !isLoading && (React.createElement(QuantidadeResultados, { data: data, quantidadeProtestos: quantidadeProtestos, quantidadeProcessos: (_f = data === null || data === void 0 ? void 0 : data.pieChartTotalConfig) === null || _f === void 0 ? void 0 : _f.processosJuridicos, quantidadeDividas: quantidadeDividas, quantidadeDividasSerasa: quantidadeSerasa, quantidadeDividasBoaVista: quantidadeBoaVista, quantidadeChequesSemFundos: quantidadeCCFs, ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF, valorTotalDividasSerasa: valorTotalSerasa, valorTotalDividasBoaVista: valorTotalBoaVista, valorTotalProtestos: valorTotalProtestos, valorTotalDividas: valorTotalDividas, ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos }))))));
64864
+ !isLoading && (React.createElement(QuantidadeResultados, { data: data, quantidadeProtestos: quantidadeProtestos, quantidadeProcessos: (_k = data === null || data === void 0 ? void 0 : data.pieChartTotalConfig) === null || _k === void 0 ? void 0 : _k.processosJuridicos, quantidadeDividas: quantidadeDividas, quantidadeDividasSerasa: quantidadeSerasa, quantidadeDividasBoaVista: quantidadeBoaVista, quantidadeChequesSemFundos: quantidadeCCFs, ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF, valorTotalDividasSerasa: valorTotalSerasa, valorTotalDividasBoaVista: valorTotalBoaVista, valorTotalProtestos: valorTotalProtestos, valorTotalDividas: valorTotalDividas, ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos }))))));
64858
64865
  };
64859
64866
  var templateObject_1$6;
64860
64867
 
@@ -65614,42 +65621,59 @@ var RefinSerasa = function (_a) {
65614
65621
  .map(addNoValueContent)
65615
65622
  .map(function (pendencia) {
65616
65623
  var _a, _b;
65617
- return (__assign$2(__assign$2({}, pendencia), { valor: formatMoney((_a = pendencia.valor) === null || _a === void 0 ? void 0 : _a.replace(',', '.')), totalvalor: formatMoney((_b = pendencia.totalvalor) === null || _b === void 0 ? void 0 : _b.replace(',', '.')), vencimento: pendencia.vencimento.slice(0, 10) }));
65624
+ return (__assign$2(__assign$2({}, pendencia), { valor: formatMoney((_a = pendencia.valor) === null || _a === void 0 ? void 0 : _a.replace(",", ".")), totalvalor: formatMoney((_b = pendencia.totalvalor) === null || _b === void 0 ? void 0 : _b.replace(",", ".")), vencimento: pendencia.vencimento.slice(0, 10) }));
65618
65625
  });
65619
65626
  }, [response]);
65620
65627
  var pendencias = pendenciasData.filter(function (_a) {
65621
65628
  var categoria = _a.categoria;
65622
- return categoria === 'PENDÊNCIAS FINANCEIRAS';
65629
+ return categoria === "PENDÊNCIAS FINANCEIRAS";
65623
65630
  });
65624
65631
  var restricoes = pendenciasData.filter(function (_a) {
65625
65632
  var categoria = _a.categoria;
65626
- return categoria === 'RESTRIÇÕES FINANCEIRAS';
65633
+ return categoria === "RESTRIÇÕES FINANCEIRAS";
65627
65634
  });
65628
65635
  var dividasVencidas = pendenciasData.filter(function (_a) {
65629
65636
  var categoria = _a.categoria;
65630
- return categoria === 'DÍVIDAS VENCIDAS';
65637
+ return categoria === "DÍVIDAS VENCIDAS";
65631
65638
  });
65632
- var consultaRefinRealizada = React.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
65633
- ]);
65639
+ var consultaRefinRealizada = React.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]);
65634
65640
  React.useEffect(function () {
65635
65641
  var _a;
65636
65642
  (_a = refinSerasaRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
65637
65643
  }, [consultaRefinRealizada]);
65638
65644
  React.useEffect(function () {
65639
- response && setConsultasComplementares && setConsultasComplementares(function (prev) { return (__assign$2(__assign$2({}, prev), { refinSerasa: __assign$2(__assign$2({}, prev.refinSerasa), { data: response }) })); });
65645
+ response &&
65646
+ setConsultasComplementares &&
65647
+ setConsultasComplementares(function (prev) { return (__assign$2(__assign$2({}, prev), { refinSerasa: __assign$2(__assign$2({}, prev.refinSerasa), { data: response }) })); });
65640
65648
  }, [response]);
65641
- var _h = (((_e = (_d = response === null || response === void 0 ? void 0 : response.document) === null || _d === void 0 ? void 0 : _d.informacoes) === null || _e === void 0 ? void 0 : _e[0]) || {}), valorTotalPendenciasFinanceiras = _h.valorTotalPendenciasFinanceiras, valorTotalPendenciasRefin = _h.valorTotalPendenciasRefin, valorTotalPendenciasVencidas = _h.valorTotalPendenciasVencidas;
65649
+ var _h = ((_e = (_d = response === null || response === void 0 ? void 0 : response.document) === null || _d === void 0 ? void 0 : _d.informacoes) === null || _e === void 0 ? void 0 : _e[0]) || {}, valorTotalPendenciasFinanceiras = _h.valorTotalPendenciasFinanceiras, valorTotalPendenciasRefin = _h.valorTotalPendenciasRefin, valorTotalPendenciasVencidas = _h.valorTotalPendenciasVencidas;
65642
65650
  return consultaRefinRealizada ? (React.createElement(React.Fragment, null,
65643
- React.createElement(PendenciasList, { title: 'Pendencias Financeiras Serasa', subtitle: 'Confira as Pend\u00EAncias Financeiras deste documento', pendencias: pendencias, valorTotal: valorTotalPendenciasFinanceiras, innerRef: refinSerasaRef, isLoading: isLoading, error: error }),
65644
- React.createElement(PendenciasList, { title: 'Pend\u00EAncias Refin Serasa', subtitle: 'Confira as Restri\u00E7\u00F5es Financeiras deste documento', pendencias: restricoes, valorTotal: valorTotalPendenciasRefin, isLoading: isLoading, error: error }),
65645
- React.createElement(PendenciasList, { title: 'D\u00EDvidas Vencidas Serasa', subtitle: 'Confira as D\u00EDvidas Vencidas deste documento', pendencias: dividasVencidas, valorTotal: valorTotalPendenciasVencidas, isLoading: isLoading, error: error, icon: DividasVencidasSerasaIcon }))) : null;
65651
+ React.createElement(PendenciasList, { title: "Pendencias Financeiras Serasa", subtitle: "Confira as Pend\u00EAncias Financeiras deste documento", pendencias: pendencias, valorTotal: valorTotalPendenciasFinanceiras, innerRef: refinSerasaRef, isLoading: isLoading, error: error }),
65652
+ React.createElement(PendenciasList, { title: "Pend\u00EAncias Refin Serasa", subtitle: "Confira as Restri\u00E7\u00F5es Financeiras deste documento", pendencias: restricoes, valorTotal: valorTotalPendenciasRefin, isLoading: isLoading, error: error }),
65653
+ React.createElement(PendenciasList, { title: "D\u00EDvidas Vencidas Serasa", subtitle: "Confira as D\u00EDvidas Vencidas deste documento", pendencias: dividasVencidas, valorTotal: valorTotalPendenciasVencidas, isLoading: isLoading, error: error, icon: DividasVencidasSerasaIcon }))) : null;
65646
65654
  };
65647
65655
  var PendenciasList = function (_a) {
65648
65656
  var isLoading = _a.isLoading, error = _a.error, pendencias = _a.pendencias, valorTotal = _a.valorTotal, headerProps = __rest(_a, ["isLoading", "error", "pendencias", "valorTotal"]);
65649
- var totalFormatado = formatMoney(valorTotal === null || valorTotal === void 0 ? void 0 : valorTotal.toString().replace(',', '.'));
65650
- var description = pendencias.length ? "Foram encontrados ".concat(pendencias.length, " ocorr\u00EAncias ").concat(valorTotal && "no valor de ".concat(totalFormatado)) : 'Nenhuma ocorrência encontrada';
65657
+ var valorTotalSeguro = valorTotal !== null && valorTotal !== void 0 ? valorTotal : 0;
65658
+ var totalFormatado = formatMoney(valorTotal === null || valorTotal === void 0 ? void 0 : valorTotal.toString().replace(",", "."));
65659
+ var description = pendencias.length === 0
65660
+ ? "Nenhuma ocorrência encontrada"
65661
+ : pendencias.length === 1
65662
+ ? "Foi encontrada 1 ocorr\u00EAncia" +
65663
+ (valorTotalSeguro > 0 ? " no valor de ".concat(totalFormatado) : "")
65664
+ : "Foram encontradas ".concat(pendencias.length, " ocorr\u00EAncias") +
65665
+ (valorTotalSeguro > 0 ? " no valor de ".concat(totalFormatado) : "");
65666
+ var statusType = error
65667
+ ? "error"
65668
+ : pendencias.length === 0
65669
+ ? "success"
65670
+ : "error";
65651
65671
  return (React.createElement("div", null,
65652
- React.createElement(Header$1, __assign$2({ variant: isLoading ? 'loading' : error || pendencias.length ? 'error' : 'default', description: React.createElement(StatusMessage, { type: error ? 'error' : pendencias.length ? 'success' : 'default' }, (error === null || error === void 0 ? void 0 : error.message) || description), icon: PefinRefinSerasaIcon }, headerProps)),
65672
+ React.createElement(Header$1, __assign$2({ variant: isLoading
65673
+ ? "loading"
65674
+ : error || pendencias.length
65675
+ ? "error"
65676
+ : "default", description: React.createElement(StatusMessage, { type: statusType }, (error === null || error === void 0 ? void 0 : error.message) || description), icon: PefinRefinSerasaIcon }, headerProps)),
65653
65677
  React.createElement(Result, null, pendencias.map(function (pendencia, i) { return (React.createElement(ResultContent, { key: i, desktop: "repeat(5, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
65654
65678
  React.createElement(AddItemField, { name: "Tipo de Ocorr\u00EAncia", value: pendencia.ocorrencia }),
65655
65679
  React.createElement(AddItemField, { name: "Credor", value: pendencia.credor }),
@@ -2,7 +2,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
2
2
  if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
3
  return cooked;
4
4
  };
5
- import React from "react";
5
+ import React, { useContext, useEffect } from "react";
6
6
  import { useUltimaOcorrenciaCCF, useCalculation, useDividasPublicas, } from "./utils/chartUtils";
7
7
  import Header from "../interface/header";
8
8
  import StatusMessage from "../interface/statusMessage";
@@ -16,30 +16,38 @@ import ChevronDown from "../../assets/btn/chevronDown";
16
16
  import useChartData from "./hooks/useChartData";
17
17
  import { Result } from "../interface/result";
18
18
  import ResumoDeNegativacoesIcon from "../../assets/icones/resumoNegativacoes";
19
+ import { ConsultasComplementaresContext } from "../consultasComplementares";
19
20
  var Content = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: ", ";\n"], ["\n display: ", ";\n"])), function (props) { return (props.isOpen ? "block" : "none"); });
20
21
  var ChartSystem = function (_a) {
21
- var _b, _c, _d, _e, _f;
22
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k;
22
23
  var documento = _a.documento;
23
- var _g = useChartData(documento), data = _g.data, isLoading = _g.isLoading, error = _g.error;
24
+ var _l = useChartData(documento), data = _l.data, isLoading = _l.isLoading, error = _l.error, refetch = _l.refetch;
25
+ var ctxConsultasComplementares = useContext(ConsultasComplementaresContext);
24
26
  var errorMessage = typeof error === "string" ? error : error === null || error === void 0 ? void 0 : error.toString();
25
- var _h = useToggle(true), isOpen = _h[0], toggleOpen = _h[1];
27
+ var _m = useToggle(true), isOpen = _m[0], toggleOpen = _m[1];
26
28
  var ultimaOcorrenciaCCF = useUltimaOcorrenciaCCF();
27
29
  var quantidadeProtestos = ((_c = (_b = data === null || data === void 0 ? void 0 : data.protestos) === null || _b === void 0 ? void 0 : _b[(data === null || data === void 0 ? void 0 : data.protestos.length) - 1]) === null || _c === void 0 ? void 0 : _c.quantidade) || 0;
28
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;
29
- var _j = useDividasPublicas(), quantidadeDividas = _j.quantidade, valorTotalDividas = _j.valorTotal;
30
- var _k = useCalculation((data === null || data === void 0 ? void 0 : data.serasa) || []), quantidadeSerasa = _k.quantidade, valorTotalSerasa = _k.valorTotal;
31
- var _l = useCalculation((data === null || data === void 0 ? void 0 : data.boaVista) || []), quantidadeBoaVista = _l.quantidade, valorTotalBoaVista = _l.valorTotal;
31
+ var _o = useDividasPublicas(), quantidadeDividas = _o.quantidade, valorTotalDividas = _o.valorTotal;
32
+ var _p = useCalculation((data === null || data === void 0 ? void 0 : data.serasa) || []), quantidadeSerasa = _p.quantidade, valorTotalSerasa = _p.valorTotal;
33
+ var _q = useCalculation((data === null || data === void 0 ? void 0 : data.boaVista) || []), quantidadeBoaVista = _q.quantidade, valorTotalBoaVista = _q.valorTotal;
32
34
  var quantidadeCCFs = useCalculation((data === null || data === void 0 ? void 0 : data.ccfs) || []).quantidade;
33
35
  var ultimaOcorrenciaProtestos = "";
34
36
  if ((data === null || data === void 0 ? void 0 : data.protestos) && data.protestos.length > 0) {
35
37
  ultimaOcorrenciaProtestos = new Date(data.protestos[data.protestos.length - 1].data).toLocaleDateString();
36
38
  }
39
+ 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;
40
+ 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;
41
+ useEffect(function () {
42
+ if (consultaPefinBoaVista || consultaPefinSerasa)
43
+ refetch();
44
+ }, [consultaPefinBoaVista, consultaPefinSerasa]);
37
45
  return (React.createElement(React.Fragment, null,
38
46
  React.createElement(Header, { title: "Resumo de Negativa\u00E7\u00F5es", subtitle: "Veja a quantidade de ocorr\u00EAncias conforme o documento foi consultado ao longo do tempo", description: errorMessage && (React.createElement(StatusMessage, { type: "error" }, errorMessage)), variant: isLoading ? "loading" : "default", icon: ResumoDeNegativacoesIcon, actions: React.createElement(BtnWrapper, { onClick: toggleOpen }, isOpen ? React.createElement(ChevronUp, null) : React.createElement(ChevronDown, null)) }),
39
47
  React.createElement(Result, null,
40
48
  React.createElement(Content, { isOpen: isOpen },
41
49
  data && React.createElement(ChartContent, { dataInput: data }),
42
- !isLoading && (React.createElement(QuantidadeResultados, { data: data, quantidadeProtestos: quantidadeProtestos, quantidadeProcessos: (_f = data === null || data === void 0 ? void 0 : data.pieChartTotalConfig) === null || _f === void 0 ? void 0 : _f.processosJuridicos, quantidadeDividas: quantidadeDividas, quantidadeDividasSerasa: quantidadeSerasa, quantidadeDividasBoaVista: quantidadeBoaVista, quantidadeChequesSemFundos: quantidadeCCFs, ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF, valorTotalDividasSerasa: valorTotalSerasa, valorTotalDividasBoaVista: valorTotalBoaVista, valorTotalProtestos: valorTotalProtestos, valorTotalDividas: valorTotalDividas, ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos }))))));
50
+ !isLoading && (React.createElement(QuantidadeResultados, { data: data, quantidadeProtestos: quantidadeProtestos, quantidadeProcessos: (_k = data === null || data === void 0 ? void 0 : data.pieChartTotalConfig) === null || _k === void 0 ? void 0 : _k.processosJuridicos, quantidadeDividas: quantidadeDividas, quantidadeDividasSerasa: quantidadeSerasa, quantidadeDividasBoaVista: quantidadeBoaVista, quantidadeChequesSemFundos: quantidadeCCFs, ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF, valorTotalDividasSerasa: valorTotalSerasa, valorTotalDividasBoaVista: valorTotalBoaVista, valorTotalProtestos: valorTotalProtestos, valorTotalDividas: valorTotalDividas, ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos }))))));
43
51
  };
44
52
  export default ChartSystem;
45
53
  var templateObject_1;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  declare const RefinSerasa: React.FC<{
3
3
  documento: string;
4
4
  }>;
@@ -21,17 +21,17 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  return t;
22
22
  };
23
23
  /* eslint-disable react-hooks/exhaustive-deps */
24
- import React, { useContext, useEffect, useMemo, useRef } from 'react';
25
- import Header from '../interface/header';
26
- import AddItemField from '../common/addItem';
27
- import { Result, ResultContent } from '../interface/result';
28
- import { ConsultasComplementaresContext } from '../consultasComplementares';
29
- import { addNoValueContent } from '../../utils/string';
30
- import { useQuery } from '../webservice';
31
- import { formatMoney } from '../../utils/number';
32
- import StatusMessage from '../interface/statusMessage';
33
- import PefinRefinSerasaIcon from '../../assets/icones/pefinRefinSerasa';
34
- import DividasVencidasSerasaIcon from '../../assets/icones/dividasVencidasSerasa';
24
+ import React, { useContext, useEffect, useMemo, useRef } from "react";
25
+ import Header from "../interface/header";
26
+ import AddItemField from "../common/addItem";
27
+ import { Result, ResultContent } from "../interface/result";
28
+ import { ConsultasComplementaresContext } from "../consultasComplementares";
29
+ import { addNoValueContent } from "../../utils/string";
30
+ import { useQuery } from "../webservice";
31
+ import { formatMoney } from "../../utils/number";
32
+ import StatusMessage from "../interface/statusMessage";
33
+ import PefinRefinSerasaIcon from "../../assets/icones/pefinRefinSerasa";
34
+ import DividasVencidasSerasaIcon from "../../assets/icones/dividasVencidasSerasa";
35
35
  var RefinSerasa = function (_a) {
36
36
  var _b, _c, _d, _e;
37
37
  var documento = _a.documento;
@@ -45,42 +45,59 @@ var RefinSerasa = function (_a) {
45
45
  .map(addNoValueContent)
46
46
  .map(function (pendencia) {
47
47
  var _a, _b;
48
- return (__assign(__assign({}, pendencia), { valor: formatMoney((_a = pendencia.valor) === null || _a === void 0 ? void 0 : _a.replace(',', '.')), totalvalor: formatMoney((_b = pendencia.totalvalor) === null || _b === void 0 ? void 0 : _b.replace(',', '.')), vencimento: pendencia.vencimento.slice(0, 10) }));
48
+ return (__assign(__assign({}, pendencia), { valor: formatMoney((_a = pendencia.valor) === null || _a === void 0 ? void 0 : _a.replace(",", ".")), totalvalor: formatMoney((_b = pendencia.totalvalor) === null || _b === void 0 ? void 0 : _b.replace(",", ".")), vencimento: pendencia.vencimento.slice(0, 10) }));
49
49
  });
50
50
  }, [response]);
51
51
  var pendencias = pendenciasData.filter(function (_a) {
52
52
  var categoria = _a.categoria;
53
- return categoria === 'PENDÊNCIAS FINANCEIRAS';
53
+ return categoria === "PENDÊNCIAS FINANCEIRAS";
54
54
  });
55
55
  var restricoes = pendenciasData.filter(function (_a) {
56
56
  var categoria = _a.categoria;
57
- return categoria === 'RESTRIÇÕES FINANCEIRAS';
57
+ return categoria === "RESTRIÇÕES FINANCEIRAS";
58
58
  });
59
59
  var dividasVencidas = pendenciasData.filter(function (_a) {
60
60
  var categoria = _a.categoria;
61
- return categoria === 'DÍVIDAS VENCIDAS';
61
+ return categoria === "DÍVIDAS VENCIDAS";
62
62
  });
63
- 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
64
- ]);
63
+ 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]);
65
64
  useEffect(function () {
66
65
  var _a;
67
66
  (_a = refinSerasaRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
68
67
  }, [consultaRefinRealizada]);
69
68
  useEffect(function () {
70
- response && setConsultasComplementares && setConsultasComplementares(function (prev) { return (__assign(__assign({}, prev), { refinSerasa: __assign(__assign({}, prev.refinSerasa), { data: response }) })); });
69
+ response &&
70
+ setConsultasComplementares &&
71
+ setConsultasComplementares(function (prev) { return (__assign(__assign({}, prev), { refinSerasa: __assign(__assign({}, prev.refinSerasa), { data: response }) })); });
71
72
  }, [response]);
72
- var _h = (((_e = (_d = response === null || response === void 0 ? void 0 : response.document) === null || _d === void 0 ? void 0 : _d.informacoes) === null || _e === void 0 ? void 0 : _e[0]) || {}), valorTotalPendenciasFinanceiras = _h.valorTotalPendenciasFinanceiras, valorTotalPendenciasRefin = _h.valorTotalPendenciasRefin, valorTotalPendenciasVencidas = _h.valorTotalPendenciasVencidas;
73
+ var _h = ((_e = (_d = response === null || response === void 0 ? void 0 : response.document) === null || _d === void 0 ? void 0 : _d.informacoes) === null || _e === void 0 ? void 0 : _e[0]) || {}, valorTotalPendenciasFinanceiras = _h.valorTotalPendenciasFinanceiras, valorTotalPendenciasRefin = _h.valorTotalPendenciasRefin, valorTotalPendenciasVencidas = _h.valorTotalPendenciasVencidas;
73
74
  return consultaRefinRealizada ? (React.createElement(React.Fragment, null,
74
- React.createElement(PendenciasList, { title: 'Pendencias Financeiras Serasa', subtitle: 'Confira as Pend\u00EAncias Financeiras deste documento', pendencias: pendencias, valorTotal: valorTotalPendenciasFinanceiras, innerRef: refinSerasaRef, isLoading: isLoading, error: error }),
75
- React.createElement(PendenciasList, { title: 'Pend\u00EAncias Refin Serasa', subtitle: 'Confira as Restri\u00E7\u00F5es Financeiras deste documento', pendencias: restricoes, valorTotal: valorTotalPendenciasRefin, isLoading: isLoading, error: error }),
76
- React.createElement(PendenciasList, { title: 'D\u00EDvidas Vencidas Serasa', subtitle: 'Confira as D\u00EDvidas Vencidas deste documento', pendencias: dividasVencidas, valorTotal: valorTotalPendenciasVencidas, isLoading: isLoading, error: error, icon: DividasVencidasSerasaIcon }))) : null;
75
+ React.createElement(PendenciasList, { title: "Pendencias Financeiras Serasa", subtitle: "Confira as Pend\u00EAncias Financeiras deste documento", pendencias: pendencias, valorTotal: valorTotalPendenciasFinanceiras, innerRef: refinSerasaRef, isLoading: isLoading, error: error }),
76
+ React.createElement(PendenciasList, { title: "Pend\u00EAncias Refin Serasa", subtitle: "Confira as Restri\u00E7\u00F5es Financeiras deste documento", pendencias: restricoes, valorTotal: valorTotalPendenciasRefin, isLoading: isLoading, error: error }),
77
+ React.createElement(PendenciasList, { title: "D\u00EDvidas Vencidas Serasa", subtitle: "Confira as D\u00EDvidas Vencidas deste documento", pendencias: dividasVencidas, valorTotal: valorTotalPendenciasVencidas, isLoading: isLoading, error: error, icon: DividasVencidasSerasaIcon }))) : null;
77
78
  };
78
79
  var PendenciasList = function (_a) {
79
80
  var isLoading = _a.isLoading, error = _a.error, pendencias = _a.pendencias, valorTotal = _a.valorTotal, headerProps = __rest(_a, ["isLoading", "error", "pendencias", "valorTotal"]);
80
- var totalFormatado = formatMoney(valorTotal === null || valorTotal === void 0 ? void 0 : valorTotal.toString().replace(',', '.'));
81
- var description = pendencias.length ? "Foram encontrados ".concat(pendencias.length, " ocorr\u00EAncias ").concat(valorTotal && "no valor de ".concat(totalFormatado)) : 'Nenhuma ocorrência encontrada';
81
+ var valorTotalSeguro = valorTotal !== null && valorTotal !== void 0 ? valorTotal : 0;
82
+ var totalFormatado = formatMoney(valorTotal === null || valorTotal === void 0 ? void 0 : valorTotal.toString().replace(",", "."));
83
+ var description = pendencias.length === 0
84
+ ? "Nenhuma ocorrência encontrada"
85
+ : pendencias.length === 1
86
+ ? "Foi encontrada 1 ocorr\u00EAncia" +
87
+ (valorTotalSeguro > 0 ? " no valor de ".concat(totalFormatado) : "")
88
+ : "Foram encontradas ".concat(pendencias.length, " ocorr\u00EAncias") +
89
+ (valorTotalSeguro > 0 ? " no valor de ".concat(totalFormatado) : "");
90
+ var statusType = error
91
+ ? "error"
92
+ : pendencias.length === 0
93
+ ? "success"
94
+ : "error";
82
95
  return (React.createElement("div", null,
83
- React.createElement(Header, __assign({ variant: isLoading ? 'loading' : error || pendencias.length ? 'error' : 'default', description: React.createElement(StatusMessage, { type: error ? 'error' : pendencias.length ? 'success' : 'default' }, (error === null || error === void 0 ? void 0 : error.message) || description), icon: PefinRefinSerasaIcon }, headerProps)),
96
+ React.createElement(Header, __assign({ variant: isLoading
97
+ ? "loading"
98
+ : error || pendencias.length
99
+ ? "error"
100
+ : "default", description: React.createElement(StatusMessage, { type: statusType }, (error === null || error === void 0 ? void 0 : error.message) || description), icon: PefinRefinSerasaIcon }, headerProps)),
84
101
  React.createElement(Result, null, pendencias.map(function (pendencia, i) { return (React.createElement(ResultContent, { key: i, desktop: "repeat(5, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
85
102
  React.createElement(AddItemField, { name: "Tipo de Ocorr\u00EAncia", value: pendencia.ocorrencia }),
86
103
  React.createElement(AddItemField, { name: "Credor", value: pendencia.credor }),
@@ -32,7 +32,7 @@ export interface PendenciasPefinRefinSerasa {
32
32
  totalpendencias: string;
33
33
  totalcredores: string;
34
34
  totalvalor: string;
35
- categoria: 'PENDÊNCIAS FINANCEIRAS' | 'RESTRIÇÕES FINANCEIRAS' | 'DÍVIDAS VENCIDAS';
35
+ categoria: "PENDÊNCIAS FINANCEIRAS" | "RESTRIÇÕES FINANCEIRAS" | "DÍVIDAS VENCIDAS";
36
36
  modalidade: string;
37
37
  }
38
38
  export interface User {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credithub/harlan-components",
3
- "version": "1.18.3",
3
+ "version": "1.18.4",
4
4
  "description": "Provide a set of web components to be used in Harlan and other projects",
5
5
  "keywords": [
6
6
  "harlan",
File without changes
File without changes