@credithub/harlan-components 1.62.4 → 1.62.6

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.
@@ -18,65 +18,73 @@ import { Queries, RequestStatus } from '../webservice';
18
18
  import ProcessosJuridicosList from './processosJuridicosList';
19
19
  var ProcessosJuridicos = function (_a) {
20
20
  var onClickConsultarProcessoJuridico = _a.onClickConsultarProcessoJuridico;
21
+ console.log('Processos Juridicos Renderizou');
21
22
  var ctx = useContext(Queries.ProcessosJuridicos);
22
23
  var setData = useGlobalData().setData;
23
24
  var processedRef = useRef(false);
24
25
  var ctxHashRef = useRef('');
25
26
  useEffect(function () {
26
- var _a;
27
+ var _a, _b;
27
28
  var currentCtxHash = JSON.stringify({
28
29
  type: ctx.type,
29
- documentId: ctx.document ? true : false
30
+ documentId: Boolean(ctx.document)
30
31
  });
31
- var cleanup = undefined;
32
32
  if (currentCtxHash === ctxHashRef.current && processedRef.current) {
33
- return undefined;
33
+ return;
34
34
  }
35
35
  ctxHashRef.current = currentCtxHash;
36
- if ((ctx.type === RequestStatus.Error || ctx.type === RequestStatus.Empty) &&
37
- !processedRef.current) {
38
- var timer_1 = setTimeout(function () {
39
- if (ctx.type === RequestStatus.Error ||
40
- ctx.type === RequestStatus.Empty) {
41
- setData(function (prevState) {
42
- var _a;
43
- if (((_a = prevState.processosJuridicosData) === null || _a === void 0 ? void 0 : _a.isLoaded) &&
44
- Array.isArray(prevState.processosJuridicosData.empresa) &&
45
- prevState.processosJuridicosData.empresa.length === 0) {
46
- return prevState;
47
- }
48
- return __assign(__assign({}, prevState), { processosJuridicosData: {
49
- empresa: [],
50
- isLoaded: true
51
- } });
52
- });
53
- processedRef.current = true;
36
+ if (ctx.type === RequestStatus.Error && !processedRef.current) {
37
+ setData(function (prevState) {
38
+ var _a;
39
+ if (((_a = prevState.processosJuridicosData) === null || _a === void 0 ? void 0 : _a.isLoaded) &&
40
+ Array.isArray(prevState.processosJuridicosData.empresa) &&
41
+ prevState.processosJuridicosData.empresa.length === 0) {
42
+ return prevState;
54
43
  }
55
- }, 300);
56
- cleanup = function () { return clearTimeout(timer_1); };
44
+ return __assign(__assign({}, prevState), { processosJuridicosData: {
45
+ empresa: [],
46
+ isLoaded: true
47
+ } });
48
+ });
49
+ processedRef.current = true;
50
+ return;
57
51
  }
58
52
  if (ctx.type === RequestStatus.Success &&
59
- !processedRef.current &&
60
- ctx.document) {
61
- var qtyProcessos_1 = (_a = ctx.document.empresa) === null || _a === void 0 ? void 0 : _a.length;
62
- if (qtyProcessos_1) {
53
+ ctx.document &&
54
+ !processedRef.current) {
55
+ var documentData_1 = ctx.document;
56
+ var qtyProcessos_1 = (_b = (_a = documentData_1.empresa) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
57
+ if (qtyProcessos_1 > 0) {
63
58
  var processosJuridicosData_1 = {
64
- empresa: ctx.document.empresa,
59
+ empresa: documentData_1.empresa,
65
60
  isLoaded: true
66
61
  };
67
62
  setData(function (prevState) {
68
63
  var _a;
69
64
  if (((_a = prevState.processosJuridicosData) === null || _a === void 0 ? void 0 : _a.isLoaded) &&
70
65
  JSON.stringify(prevState.processosJuridicosData.empresa) ===
71
- JSON.stringify(processosJuridicosData_1.empresa)) {
66
+ JSON.stringify(documentData_1.empresa)) {
67
+ return prevState;
68
+ }
69
+ return __assign(__assign({}, prevState), { processosJuridicos: qtyProcessos_1, processosJuridicosData: processosJuridicosData_1 });
70
+ });
71
+ }
72
+ else {
73
+ setData(function (prevState) {
74
+ var _a;
75
+ if (((_a = prevState.processosJuridicosData) === null || _a === void 0 ? void 0 : _a.isLoaded) &&
76
+ Array.isArray(prevState.processosJuridicosData.empresa) &&
77
+ prevState.processosJuridicosData.empresa.length === 0) {
72
78
  return prevState;
73
79
  }
74
- return __assign(__assign({}, prevState), { processosJuridicos: qtyProcessos_1 || 0, processosJuridicosData: processosJuridicosData_1 });
80
+ return __assign(__assign({}, prevState), { processosJuridicosData: {
81
+ empresa: [],
82
+ isLoaded: true
83
+ } });
75
84
  });
76
- processedRef.current = true;
77
85
  }
86
+ processedRef.current = true;
78
87
  }
79
- return cleanup;
80
88
  }, [ctx.type, ctx.document, setData]);
81
89
  useEffect(function () {
82
90
  if (ctx.type === RequestStatus.Loading) {
@@ -6,21 +6,17 @@ export declare function useRefinSerasa(documento: string): {
6
6
  pendencias: {
7
7
  valor: string;
8
8
  totalvalor: string;
9
- vencimento: string;
10
- ocorrencia: string;
11
- entrada: string;
12
- informante: string;
9
+ categoria: string;
10
+ avalista: boolean;
11
+ comprador: boolean;
12
+ fiador: boolean;
13
13
  contrato: string;
14
- avalista: string;
14
+ data_ocorrencia: string;
15
+ origem: string;
16
+ titulo_ocorrencia: string;
17
+ base_origem: string;
15
18
  cidade: string;
16
19
  uf: string;
17
- situacao: string;
18
- credor: string;
19
- orgaoemissor: string;
20
- totalpendencias: string;
21
- totalcredores: string;
22
- categoria: "PEND\u00CANCIAS FINANCEIRAS" | "RESTRI\u00C7\u00D5ES FINANCEIRAS" | "D\u00CDVIDAS VENCIDAS";
23
- modalidade: string;
24
20
  }[];
25
21
  consultaRealizada: boolean;
26
22
  loadingProgress: number;
@@ -9,6 +9,15 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
12
21
  import PefinRefinSerasaIcon from '../../assets/icones/pefinRefinSerasa';
13
22
  import { useGlobalData } from '../../contexts/globalDataContext';
14
23
  import { formatMoney } from '../../utils/number';
@@ -36,13 +45,14 @@ export function useRefinSerasa(documento) {
36
45
  return isNaN(parsed) ? '0' : valorFinal;
37
46
  };
38
47
  var pendenciasData = useMemo(function () {
39
- var _a, _b, _c;
40
- 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)) || [])
41
- .map(addNoValueContent)
42
- .map(function (pendencia) {
43
- var _a;
44
- return (__assign(__assign({}, pendencia), { valor: clearValue(pendencia.valor), totalvalor: clearValue(pendencia.totalvalor), vencimento: (_a = pendencia === null || pendencia === void 0 ? void 0 : pendencia.vencimento) === null || _a === void 0 ? void 0 : _a.slice(0, 10) }));
45
- });
48
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
49
+ if (!response)
50
+ return [];
51
+ var pefin = ((_d = (_c = (_b = (_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.dados) === null || _b === void 0 ? void 0 : _b.pefin) === null || _c === void 0 ? void 0 : _c.registro) === null || _d === void 0 ? void 0 : _d.map(function (registro) { return (__assign(__assign({}, registro), { categoria: 'PENDÊNCIAS FINANCEIRAS' })); })) || [];
52
+ var refin = ((_h = (_g = (_f = (_e = response === null || response === void 0 ? void 0 : response.document) === null || _e === void 0 ? void 0 : _e.dados) === null || _f === void 0 ? void 0 : _f.refin) === null || _g === void 0 ? void 0 : _g.registro) === null || _h === void 0 ? void 0 : _h.map(function (registro) { return (__assign(__assign({}, registro), { categoria: 'RESTRIÇÕES FINANCEIRAS' })); })) || [];
53
+ var pendenciasVencidas = ((_m = (_l = (_k = (_j = response === null || response === void 0 ? void 0 : response.document) === null || _j === void 0 ? void 0 : _j.dados) === null || _k === void 0 ? void 0 : _k.pendencias_vencidas) === null || _l === void 0 ? void 0 : _l.registro) === null || _m === void 0 ? void 0 : _m.map(function (registro) { return (__assign(__assign({}, registro), { categoria: 'DÍVIDAS VENCIDAS' })); })) || [];
54
+ return __spreadArray(__spreadArray(__spreadArray([], pefin, true), refin, true), pendenciasVencidas, true).map(addNoValueContent)
55
+ .map(function (pendencia) { return (__assign(__assign({}, pendencia), { valor: clearValue(pendencia.valor), totalvalor: clearValue(pendencia.valor) })); });
46
56
  }, [response]);
47
57
  var pendencias = pendenciasData.filter(function (_a) {
48
58
  var categoria = _a.categoria;
@@ -87,8 +97,20 @@ var RefinSerasa = function (_a) {
87
97
  behavior: 'smooth'
88
98
  });
89
99
  }, [consultaRealizada]);
90
- var totalPendencias = useMemo(function () { var _a, _b, _c; return ((_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.total) || 0; }, [response === null || response === void 0 ? void 0 : response.document]);
91
- var valorTotalPendencias = useMemo(function () { var _a, _b, _c; return ((_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.valorTotalPendencias) || 0; }, [response === null || response === void 0 ? void 0 : response.document]);
100
+ var totalPendencias = useMemo(function () {
101
+ var _a, _b, _c, _d, _e;
102
+ var resumo = (_b = (_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.dados) === null || _b === void 0 ? void 0 : _b.resumo;
103
+ return (((_c = resumo === null || resumo === void 0 ? void 0 : resumo.pefin) === null || _c === void 0 ? void 0 : _c.quantidade) || 0) +
104
+ (((_d = resumo === null || resumo === void 0 ? void 0 : resumo.refin) === null || _d === void 0 ? void 0 : _d.quantidade) || 0) +
105
+ (((_e = resumo === null || resumo === void 0 ? void 0 : resumo.pendencias_vencidas) === null || _e === void 0 ? void 0 : _e.quantidade) || 0);
106
+ }, [response === null || response === void 0 ? void 0 : response.document]);
107
+ var valorTotalPendencias = useMemo(function () {
108
+ var _a, _b, _c, _d, _e, _f, _g, _h;
109
+ var resumo = (_b = (_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.dados) === null || _b === void 0 ? void 0 : _b.resumo;
110
+ return (Number((_d = (_c = resumo === null || resumo === void 0 ? void 0 : resumo.pefin) === null || _c === void 0 ? void 0 : _c.valor_total) === null || _d === void 0 ? void 0 : _d.replace('.', '').replace(',', '.')) || 0) +
111
+ (Number((_f = (_e = resumo === null || resumo === void 0 ? void 0 : resumo.refin) === null || _e === void 0 ? void 0 : _e.valor_total) === null || _f === void 0 ? void 0 : _f.replace('.', '').replace(',', '.')) || 0) +
112
+ (Number((_h = (_g = resumo === null || resumo === void 0 ? void 0 : resumo.pendencias_vencidas) === null || _g === void 0 ? void 0 : _g.valor_total) === null || _h === void 0 ? void 0 : _h.replace('.', '').replace(',', '.')) || 0);
113
+ }, [response === null || response === void 0 ? void 0 : response.document]);
92
114
  var description = totalPendencias === 0
93
115
  ? 'Não há ocorrência de Pefin/Refin Serasa'
94
116
  : totalPendencias === 1
@@ -107,21 +129,20 @@ var RefinSerasa = function (_a) {
107
129
  Section: Section,
108
130
  progress: loadingProgress
109
131
  }, title: "Pefin/Refin e Contratos Vencidos Serasa", subtitle: "Confira as Pend\u00EAncias Financeiras deste documento", icon: PefinRefinSerasaIcon, description: !error && (React.createElement(StatusMessage, { type: totalPendencias === 0 ? 'default' : 'error' }, description)), variant: totalPendencias === 0 ? 'default' : 'error', onSuccess: function () { return (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" },
110
- React.createElement(AddItemField, { name: "Tipo de Ocorr\u00EAncia", value: pendencia.ocorrencia }),
111
- React.createElement(AddItemField, { name: "Credor", value: pendencia.credor }),
112
- React.createElement(AddItemField, { name: "Data de Entrada", value: pendencia.entrada }),
113
- React.createElement(AddItemField, { name: "Data de Vencimento", value: pendencia.vencimento }),
114
- React.createElement(AddItemField, { name: "Valor", value: pendencia.valor }),
115
- React.createElement(AddItemField, { name: "Informante", value: pendencia.informante }),
116
- React.createElement(AddItemField, { name: "N\u00FAmero de Contrato", value: pendencia.contrato }),
117
- React.createElement(AddItemField, { name: "Avalista", value: pendencia.avalista }),
118
- React.createElement(AddItemField, { name: "Cidade", value: pendencia.cidade }),
119
- React.createElement(AddItemField, { name: "UF", value: pendencia.uf }),
120
- React.createElement(AddItemField, { name: "Situa\u00E7\u00E3o", value: pendencia.situacao }),
121
- React.createElement(AddItemField, { name: "Org\u00E3o Emissor", value: pendencia.orgaoemissor }),
122
- React.createElement(AddItemField, { name: "Total de Pend\u00EAncias", value: pendencia.totalpendencias }),
123
- React.createElement(AddItemField, { name: "Valor Total", value: pendencia.totalvalor }),
124
- React.createElement(AddItemField, { name: "Categoria", value: pendencia.categoria }))); }))); }, isError: function (err) { return ({
132
+ React.createElement(AddItemField, { name: "Tipo de Ocorr\u00EAncia", value: pendencia === null || pendencia === void 0 ? void 0 : pendencia.titulo_ocorrencia }),
133
+ React.createElement(AddItemField, { name: "Credor", value: pendencia === null || pendencia === void 0 ? void 0 : pendencia.origem }),
134
+ React.createElement(AddItemField, { name: "Data de Entrada", value: pendencia === null || pendencia === void 0 ? void 0 : pendencia.data_ocorrencia }),
135
+ React.createElement(AddItemField, { name: "Valor", value: pendencia === null || pendencia === void 0 ? void 0 : pendencia.valor }),
136
+ React.createElement(AddItemField, { name: "N\u00FAmero de Contrato", value: pendencia === null || pendencia === void 0 ? void 0 : pendencia.contrato }),
137
+ React.createElement(AddItemField, { name: "Avalista", value: (pendencia === null || pendencia === void 0 ? void 0 : pendencia.avalista) ? 'Sim' : 'Não' }),
138
+ React.createElement(AddItemField, { name: "Comprador", value: (pendencia === null || pendencia === void 0 ? void 0 : pendencia.comprador) ? 'Sim' : 'Não' }),
139
+ React.createElement(AddItemField, { name: "Fiador", value: (pendencia === null || pendencia === void 0 ? void 0 : pendencia.fiador) ? 'Sim' : 'Não' }),
140
+ React.createElement(AddItemField, { name: "Cidade", value: pendencia === null || pendencia === void 0 ? void 0 : pendencia.cidade }),
141
+ React.createElement(AddItemField, { name: "UF", value: pendencia === null || pendencia === void 0 ? void 0 : pendencia.uf }),
142
+ React.createElement(AddItemField, { name: "Org\u00E3o Emissor", value: "SerasaExperian-Pefin" }),
143
+ React.createElement(AddItemField, { name: "Total de Pend\u00EAncias", value: "1" }),
144
+ React.createElement(AddItemField, { name: "Valor Total", value: pendencia === null || pendencia === void 0 ? void 0 : pendencia.totalvalor }),
145
+ React.createElement(AddItemField, { name: "Categoria", value: pendencia === null || pendencia === void 0 ? void 0 : pendencia.categoria }))); }))); }, isError: function (err) { return ({
125
146
  children: React.createElement(React.Fragment, null),
126
147
  description: (React.createElement(StatusMessage, { type: "error" },
127
148
  "Erro ao realizar a consulta: ",