@credithub/harlan-components 1.44.5 → 1.45.0
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/dist/components/protestos/protestos.js +10 -2
- package/lib/cjs/index.js +10 -2
- package/lib/esm/index.js +10 -2
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ import { useGlobalData } from '../../contexts/globalDataContext';
|
|
|
22
22
|
import { formatDatePtBrToDate } from '../../utils/date';
|
|
23
23
|
import { extractIntegerFromText } from '../../utils/number';
|
|
24
24
|
import XPathUtils from '../../utils/xpath';
|
|
25
|
-
import React, { useContext, useEffect, useState } from 'react';
|
|
25
|
+
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
26
26
|
import styled from 'styled-components';
|
|
27
27
|
import StatusMessage from '../interface/statusMessage';
|
|
28
28
|
import Section from '../section';
|
|
@@ -38,8 +38,15 @@ var byDate = function (protesto, protesto2) {
|
|
|
38
38
|
};
|
|
39
39
|
var Protestos = function () {
|
|
40
40
|
var ctx = useContext(Queries.Protestos);
|
|
41
|
+
var ctxLiminar = useContext(Queries.Liminar);
|
|
41
42
|
var setData = useGlobalData().setData;
|
|
42
43
|
var _a = useState(false), dataUpdated = _a[0], setDataUpdated = _a[1];
|
|
44
|
+
var total = useMemo(function () {
|
|
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;
|
|
48
|
+
return 0;
|
|
49
|
+
}, [ctxLiminar.type]);
|
|
43
50
|
useEffect(function () {
|
|
44
51
|
if (ctx.type !== RequestStatus.Success || dataUpdated || !ctx.document) {
|
|
45
52
|
return;
|
|
@@ -72,7 +79,8 @@ var Protestos = function () {
|
|
|
72
79
|
}, [ctx, setData, dataUpdated]);
|
|
73
80
|
return (React.createElement(Section, { ctx: ctx, title: "Apontamentos na Central de Protestos (CENPROT)", subtitle: "Consulta de protestos de cr\u00E9dito, imposto e gerais.", icon: ProtestosIcon, onSuccess: function (data) {
|
|
74
81
|
var registrosText = XPathUtils.select('string(//registros)', data);
|
|
75
|
-
var
|
|
82
|
+
var haveExeption = XPathUtils.select('string(//raw)', data) != 'false';
|
|
83
|
+
var registros = haveExeption ? extractIntegerFromText(registrosText) + total : extractIntegerFromText(registrosText);
|
|
76
84
|
var protestosDeCredito = XPathUtils.selectArray('//body//protesto', data).filter(function (protesto) {
|
|
77
85
|
return REGEX_PROTESTOS_DE_CREDITO.test(XPathUtils.select('string(./nomeCedente)', protesto));
|
|
78
86
|
});
|