@credithub/harlan-components 1.45.1 → 1.46.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.
@@ -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),