@credithub/harlan-components 1.24.1 → 1.24.3

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.
@@ -21,17 +21,16 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  return t;
22
22
  };
23
23
  /* eslint-disable react-hooks/exhaustive-deps */
24
+ import PefinRefinSerasaIcon from '../../assets/icones/pefinRefinSerasa';
25
+ import { formatMoney } from '../../utils/number';
26
+ import { addNoValueContent } from '../../utils/string';
24
27
  import React, { useContext, useEffect, useMemo, useRef } from 'react';
25
- import Header from '../interface/header';
26
28
  import AddItemField from '../common/addItem';
27
- import { Result, ResultContent } from '../interface/result';
28
29
  import { ConsultasComplementaresContext } from '../consultasComplementares';
29
- import { addNoValueContent } from '../../utils/string';
30
- import { useQuery } from '../webservice';
31
- import { formatMoney } from '../../utils/number';
30
+ import Header from '../interface/header';
31
+ import { Result, ResultContent } from '../interface/result';
32
32
  import StatusMessage from '../interface/statusMessage';
33
- import PefinRefinSerasaIcon from '../../assets/icones/pefinRefinSerasa';
34
- import DividasVencidasSerasaIcon from '../../assets/icones/dividasVencidasSerasa';
33
+ import { useQuery } from '../webservice';
35
34
  var RefinSerasa = function (_a) {
36
35
  var _b, _c, _d, _e;
37
36
  var documento = _a.documento;
@@ -39,27 +38,26 @@ var RefinSerasa = function (_a) {
39
38
  var consultasComplementaresContext = useContext(ConsultasComplementaresContext);
40
39
  var _f = consultasComplementaresContext !== null && consultasComplementaresContext !== void 0 ? consultasComplementaresContext : {}, consultasComplementares = _f.consultasComplementares, setConsultasComplementares = _f.setConsultasComplementares;
41
40
  var _g = useQuery("SELECT FROM 'PROTESTOS'.'SERASA'", { documento: documento }, !!((_b = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinSerasa) === null || _b === void 0 ? void 0 : _b.consultaRealizada)), response = _g.response, isLoading = _g.isLoading, error = _g.error;
42
- var clearValue = function (value) { var _a; return (_a = value === null || value === void 0 ? void 0 : value.replace('.', '')) === null || _a === void 0 ? void 0 : _a.replace(',', '.'); };
41
+ var clearValue = function (value) {
42
+ var semPontos = value === null || value === void 0 ? void 0 : value.replace(/\./g, '');
43
+ return semPontos === null || semPontos === void 0 ? void 0 : semPontos.replace(',', '.');
44
+ };
43
45
  var pendenciasData = useMemo(function () {
44
46
  var _a, _b, _c;
45
47
  return ((response && ((_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.informacoes) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.bello)) || [])
46
48
  .map(addNoValueContent)
47
49
  .map(function (pendencia) {
48
50
  var _a;
49
- return (__assign(__assign({}, pendencia), { valor: formatMoney(clearValue(pendencia.valor)), totalvalor: formatMoney(clearValue(pendencia.totalvalor)), vencimento: (_a = pendencia === null || pendencia === void 0 ? void 0 : pendencia.vencimento) === null || _a === void 0 ? void 0 : _a.slice(0, 10) }));
51
+ var valorLimpo = clearValue(pendencia.valor);
52
+ var totalvalorLimpo = clearValue(pendencia.totalvalor);
53
+ return __assign(__assign({}, pendencia), { valor: formatMoney(valorLimpo), totalvalor: formatMoney(totalvalorLimpo), vencimento: (_a = pendencia === null || pendencia === void 0 ? void 0 : pendencia.vencimento) === null || _a === void 0 ? void 0 : _a.slice(0, 10) });
50
54
  });
51
55
  }, [response]);
52
56
  var pendencias = pendenciasData.filter(function (_a) {
53
57
  var categoria = _a.categoria;
54
- return categoria === 'PENDÊNCIAS FINANCEIRAS';
55
- });
56
- var restricoes = pendenciasData.filter(function (_a) {
57
- var categoria = _a.categoria;
58
- return categoria === 'RESTRIÇÕES FINANCEIRAS';
59
- });
60
- var dividasVencidas = pendenciasData.filter(function (_a) {
61
- var categoria = _a.categoria;
62
- return categoria === 'DÍVIDAS VENCIDAS';
58
+ return categoria === 'PENDÊNCIAS FINANCEIRAS' ||
59
+ categoria === 'RESTRIÇÕES FINANCEIRAS' ||
60
+ categoria === 'DÍVIDAS VENCIDAS';
63
61
  });
64
62
  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
63
  useEffect(function () {
@@ -71,11 +69,9 @@ var RefinSerasa = function (_a) {
71
69
  setConsultasComplementares &&
72
70
  setConsultasComplementares(function (prev) { return (__assign(__assign({}, prev), { refinSerasa: __assign(__assign({}, prev.refinSerasa), { data: response }) })); });
73
71
  }, [response]);
74
- 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;
72
+ var valorTotalPendenciasFinanceiras = (((_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;
75
73
  return consultaRefinRealizada ? (React.createElement(React.Fragment, null,
76
- 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 }),
77
- 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 }),
78
- 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;
74
+ React.createElement(PendenciasList, { title: "Pefin/Refin e Contratos Vencidos Serasa", subtitle: "Confira as Pend\u00EAncias Financeiras deste documento", pendencias: pendencias, valorTotal: valorTotalPendenciasFinanceiras, innerRef: refinSerasaRef, isLoading: isLoading, error: error }))) : null;
79
75
  };
80
76
  var PendenciasList = function (_a) {
81
77
  var isLoading = _a.isLoading, error = _a.error, pendencias = _a.pendencias, valorTotal = _a.valorTotal, headerProps = __rest(_a, ["isLoading", "error", "pendencias", "valorTotal"]);
@@ -93,6 +89,7 @@ var PendenciasList = function (_a) {
93
89
  : pendencias.length === 0
94
90
  ? 'success'
95
91
  : 'error';
92
+ pendencias.map(function (pendencia, i) { });
96
93
  return (React.createElement("div", null,
97
94
  React.createElement(Header, __assign({ variant: isLoading
98
95
  ? 'loading'
@@ -99,7 +99,7 @@ function getResumoDeModalidades(scr) {
99
99
  var _a;
100
100
  return ({
101
101
  modalidade: !/^Limite/.test(modalidade)
102
- ? "Cr\u00E9ditos baixados como ".concat((_a = vencimento === null || vencimento === void 0 ? void 0 : vencimento.descricao) === null || _a === void 0 ? void 0 : _a.toLowerCase())
102
+ ? "Cr\u00E9ditos ".concat((_a = vencimento === null || vencimento === void 0 ? void 0 : vencimento.descricao) === null || _a === void 0 ? void 0 : _a.toLowerCase())
103
103
  : vencimento === null || vencimento === void 0 ? void 0 : vencimento.descricao,
104
104
  valor: vencimento === null || vencimento === void 0 ? void 0 : vencimento.valor
105
105
  });
@@ -198,7 +198,7 @@ var Section = function (_a) {
198
198
  React.createElement(StatusMessage, { type: "warning" }, err.message))),
199
199
  actions: (React.createElement(React.Fragment, null,
200
200
  React.createElement(Button, { onClick: function () { return ctx.refetch(); } }, "Tentar Novamente")))
201
- }); } : _b, _c = _a.onLoading, onLoading = _c === void 0 ? function () { return React.createElement(React.Fragment, null); } : _c, ctx = _a.ctx, children = _a.children, className = _a.className, _d = _a.hideHeader, hideHeader = _d === void 0 ? false : _d, _e = _a.minimized, minimized = _e === void 0 ? true : _e, headerProps = __rest(_a, ["onSuccess", "isError", "onLoading", "ctx", "children", "className", "hideHeader", "minimized"]);
201
+ }); } : _b, _c = _a.onLoading, onLoading = _c === void 0 ? function () { return React.createElement(React.Fragment, null); } : _c, ctx = _a.ctx, className = _a.className, _d = _a.hideHeader, hideHeader = _d === void 0 ? false : _d, _e = _a.minimized, minimized = _e === void 0 ? true : _e, headerProps = __rest(_a, ["onSuccess", "isError", "onLoading", "ctx", "className", "hideHeader", "minimized"]);
202
202
  var _f = useToggle(!minimized), isOpen = _f[0], toggleOpen = _f[1];
203
203
  if (!ctx)
204
204
  return null;