@credithub/harlan-components 1.16.3 → 1.18.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/lib/cjs/index.js CHANGED
@@ -13677,7 +13677,7 @@ var PartnerRFBStatus = function (_a) {
13677
13677
 
13678
13678
  var PartnerProtestos = function (_a) {
13679
13679
  var documento = _a.documento;
13680
- var _b = useQuery("SELECT FROM 'APICENPROT'.'PRINT'", { documento: documento }), isLoading = _b.isLoading, error = _b.error, response = _b.response;
13680
+ var _b = useQuery("SELECT FROM 'IEPTB'.'IEPTBHARLAN'", { documento: documento }), isLoading = _b.isLoading, error = _b.error, response = _b.response;
13681
13681
  return isLoading ? React.createElement(Loading, null) : error ? 'Houve um erro ao obter a informação.' : XPathUtils.select('string(//registros)', response === null || response === void 0 ? void 0 : response.document);
13682
13682
  };
13683
13683
 
@@ -13802,6 +13802,42 @@ var ProtestosCategory = function (_a) {
13802
13802
  };
13803
13803
  var templateObject_1$i;
13804
13804
 
13805
+ var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
13806
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13807
+ return new (P || (P = Promise))(function (resolve, reject) {
13808
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13809
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13810
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13811
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13812
+ });
13813
+ };
13814
+ var __generator$1 = (undefined && undefined.__generator) || function (thisArg, body) {
13815
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13816
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13817
+ function verb(n) { return function (v) { return step([n, v]); }; }
13818
+ function step(op) {
13819
+ if (f) throw new TypeError("Generator is already executing.");
13820
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
13821
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
13822
+ if (y = 0, t) op = [op[0] & 2, t.value];
13823
+ switch (op[0]) {
13824
+ case 0: case 1: t = op; break;
13825
+ case 4: _.label++; return { value: op[1], done: false };
13826
+ case 5: _.label++; y = op[1]; op = [0]; continue;
13827
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
13828
+ default:
13829
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
13830
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
13831
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
13832
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
13833
+ if (t[2]) _.ops.pop();
13834
+ _.trys.pop(); continue;
13835
+ }
13836
+ op = body.call(thisArg, _);
13837
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
13838
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
13839
+ }
13840
+ };
13805
13841
  var ProtestoItem = React.memo(function (_a) {
13806
13842
  var protesto = _a.protesto;
13807
13843
  var getField = function (path, formatter) {
@@ -13811,15 +13847,54 @@ var ProtestoItem = React.memo(function (_a) {
13811
13847
  var formatBooleanField = function (value) {
13812
13848
  return value === "true" ? "Sim" : "Não";
13813
13849
  };
13814
- return (React.createElement(ResultContent, { desktop: "repeat(7, 1fr)", tablet: "repeat(4, 1fr)", mobile: "repeat(2, 1fr)" },
13850
+ return (React.createElement(ResultContent, { desktop: "repeat(8, 1fr)", tablet: "repeat(4, 1fr)", mobile: "repeat(2, 1fr)" },
13815
13851
  React.createElement(AddItemField, { name: "Quem Protestou", value: getField("./nomeCedente") }),
13816
13852
  React.createElement(AddItemField, { name: "Atrav\u00E9s De", value: getField("./nomeApresentante") }),
13817
13853
  React.createElement(AddItemField, { name: "CPF/CNPJ Protestado", value: formatDocument(getField("./cpfCnpj")) }),
13818
13854
  React.createElement(AddItemField, { name: "Data Do Protesto", value: getField("./dataProtesto") }),
13819
13855
  React.createElement(AddItemField, { name: "Possui Anu\u00EAncia", value: formatBooleanField(getField("./temAnuencia")) }),
13820
13856
  React.createElement(AddItemField, { name: "Anu\u00EAncia Vencida", value: formatBooleanField(getField("./anuenciaVencida")) }),
13821
- React.createElement(AddItemField, { name: "Valor Do Protesto", value: formatMoney(getField("./valor")) })));
13857
+ React.createElement(AddItemField, { name: "Valor Do Protesto", value: formatMoney(getField("./valor")) }),
13858
+ React.createElement(Instrumento, { nm_chave: getField("./nm_chave") })));
13822
13859
  });
13860
+ var Instrumento = function (_a) {
13861
+ var nm_chave = _a.nm_chave;
13862
+ var client = React.useContext(WebService);
13863
+ var _b = React.useState(), error = _b[0], setError = _b[1];
13864
+ var _c = React.useState(false), isLoading = _c[0], setIsLoading = _c[1];
13865
+ if (!nm_chave)
13866
+ return null;
13867
+ return React.createElement(Button$1, { onClick: function () { return __awaiter$1(void 0, void 0, void 0, function () {
13868
+ var request, pdfWindow, e_1;
13869
+ return __generator$1(this, function (_a) {
13870
+ switch (_a.label) {
13871
+ case 0:
13872
+ setIsLoading(true);
13873
+ _a.label = 1;
13874
+ case 1:
13875
+ _a.trys.push([1, 4, 5, 6]);
13876
+ return [4 /*yield*/, client.request("SELECT FROM 'IEPTB'.'PDF'", { nm_chave: nm_chave })];
13877
+ case 2: return [4 /*yield*/, (_a.sent()).json()];
13878
+ case 3:
13879
+ request = _a.sent();
13880
+ pdfWindow = window.open('', '_blank');
13881
+ if (!pdfWindow)
13882
+ return [2 /*return*/];
13883
+ pdfWindow.document.write("<iframe width='100%' height='100%' src='data:application/pdf;base64,".concat(request === null || request === void 0 ? void 0 : request.instrumentoProtesto, "'></iframe>"));
13884
+ return [3 /*break*/, 6];
13885
+ case 4:
13886
+ e_1 = _a.sent();
13887
+ console.error(e_1);
13888
+ setError(true);
13889
+ return [3 /*break*/, 6];
13890
+ case 5:
13891
+ setIsLoading(false);
13892
+ return [7 /*endfinally*/];
13893
+ case 6: return [2 /*return*/];
13894
+ }
13895
+ });
13896
+ }); }, disabled: isLoading }, error ? 'Instrumento não Localizado' : 'Instrumento');
13897
+ };
13823
13898
  /**
13824
13899
  * const ProtestosList: React.FC<{
13825
13900
  protestos: ProtestoData[]
@@ -13893,14 +13968,15 @@ var Protestos = function () {
13893
13968
  });
13894
13969
  };
13895
13970
  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) {
13971
+ var byDate = function (protesto, protesto2) { var _a, _b; return ((_a = formatDatePtBrToDate(XPathUtils.select("string(./dataProtesto)", protesto2))) === null || _a === void 0 ? void 0 : _a.getTime()) - ((_b = formatDatePtBrToDate(XPathUtils.select("string(./dataProtesto)", protesto))) === null || _b === void 0 ? void 0 : _b.getTime()); };
13896
13972
  var registros = XPathUtils.select("number(//registros)", data);
13897
- var protestosDeCredito = filterProtestos(REGEX_PROTESTOS_DE_CREDITO, data);
13898
- var protestosDeImposto = filterProtestos(REGEX_PROTESTOS_DE_IMPOSTO, data);
13973
+ var protestosDeCredito = filterProtestos(REGEX_PROTESTOS_DE_CREDITO, data).sort(byDate);
13974
+ var protestosDeImposto = filterProtestos(REGEX_PROTESTOS_DE_IMPOSTO, data).sort(byDate);
13899
13975
  var protestosGerais = XPathUtils.selectArray("//body//protesto", data).filter(function (protesto) {
13900
13976
  var nomeCedente = XPathUtils.select("string(./nomeCedente)", protesto);
13901
13977
  return (!REGEX_PROTESTOS_DE_IMPOSTO.test(nomeCedente) &&
13902
13978
  !REGEX_PROTESTOS_DE_CREDITO.test(nomeCedente));
13903
- });
13979
+ }).sort(byDate);
13904
13980
  var elements = [
13905
13981
  {
13906
13982
  total: protestosDeCredito === null || protestosDeCredito === void 0 ? void 0 : protestosDeCredito.length,
@@ -65350,10 +65426,18 @@ var ConsultaSimples = function (_a) {
65350
65426
  React.createElement(Veiculos, { documento: documento })),
65351
65427
  React.createElement(Protestos, null),
65352
65428
  React.createElement(CCF, null),
65429
+ React.createElement(DividasPublicas, null),
65353
65430
  React.createElement(ProcessosJuridicos, { onClickConsultarProcessoJuridico: onClickConsultarProcessoJuridico })))))))))))));
65354
65431
  };
65355
65432
  var templateObject_1;
65356
65433
 
65434
+ var DividasVencidasSerasaIcon = function (_a) {
65435
+ var _b = _a.className, className = _b === void 0 ? "" : _b, _c = _a.size, size = _c === void 0 ? 30 : _c, _d = _a.circleFill, circleFill = _d === void 0 ? theme.colors.azulCredithub : _d;
65436
+ return (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, fill: "none", viewBox: "0 0 30 30", className: className },
65437
+ React.createElement("circle", { cx: "15", cy: "15", r: "15", fill: circleFill }),
65438
+ React.createElement("path", { fill: "#fff", d: "M15 19.4L13.4 21a.948.948 0 01-.7.275A.948.948 0 0112 21a.948.948 0 01-.275-.7c0-.283.092-.517.275-.7l1.6-1.6-1.6-1.6a.948.948 0 01-.275-.7c0-.283.092-.517.275-.7a.948.948 0 01.7-.275c.283 0 .517.092.7.275l1.6 1.6 1.6-1.6a.948.948 0 01.7-.275c.283 0 .517.092.7.275a.948.948 0 01.275.7.948.948 0 01-.275.7L16.4 18l1.6 1.6a.948.948 0 01.275.7.948.948 0 01-.275.7.948.948 0 01-.7.275.948.948 0 01-.7-.275L15 19.4zM8 25c-.55 0-1.02-.196-1.412-.587A1.926 1.926 0 016 23V9c0-.55.196-1.02.588-1.412A1.926 1.926 0 018 7h1V6c0-.283.096-.52.287-.713A.968.968 0 0110 5c.283 0 .52.096.713.287.191.192.287.43.287.713v1h8V6c0-.283.096-.52.288-.713A.968.968 0 0120 5c.283 0 .52.096.712.287.192.192.288.43.288.713v1h1c.55 0 1.02.196 1.413.588.391.391.587.862.587 1.412v14c0 .55-.196 1.02-.587 1.413A1.926 1.926 0 0122 25H8zm0-2h14V13H8v10zm0-12h14V9H8v2z" })));
65439
+ };
65440
+
65357
65441
  var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
65358
65442
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
65359
65443
  if (ar || !(i in from)) {
@@ -65366,7 +65450,7 @@ var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from
65366
65450
  var DividasPublicas = function () {
65367
65451
  var ctx = React.useContext(Queries.Finder);
65368
65452
  var Section = ctx.Section;
65369
- return (React.createElement(Section, { title: "Dividas P\u00FAblicas", subtitle: "Vejas As D\u00EDvidas P\u00FAblicas Com A Uni\u00E3o (Ativa, Fgts E Previdenciaria)", onSuccess: function (document) {
65453
+ return (React.createElement(Section, { title: "Dividas P\u00FAblicas", icon: DividasVencidasSerasaIcon, subtitle: "Vejas As D\u00EDvidas P\u00FAblicas Com A Uni\u00E3o (Ativa, Fgts E Previdenciaria)", onSuccess: function (document) {
65370
65454
  var parseDividas = function (tipo) { return function (divida) { return ({
65371
65455
  nomeDoDevedor: XPathUtils.select('string(./nome_devedor)', divida),
65372
65456
  tipoDePessoa: XPathUtils.select('string(./tipo_pessoa)', divida),
@@ -65382,31 +65466,35 @@ var DividasPublicas = function () {
65382
65466
  tipoDeDivida: tipo
65383
65467
  }); }; };
65384
65468
  var dividas = __spreadArray(__spreadArray(__spreadArray([], XPathUtils.selectArray('//dividas/fgts/divida', document).map(parseDividas('FGTS')), true), XPathUtils.selectArray('//dividas/previdenciaria/divida', document).map(parseDividas('Previdenciária')), true), XPathUtils.selectArray('//dividas/ativa-geral/divida', document).map(parseDividas('Divida Ativa União')), true);
65385
- var children = (React.createElement(Result, null,
65386
- React.createElement(DividasPublicasList, { dividas: dividas })));
65469
+ var totalOcorrencias = dividas === null || dividas === void 0 ? void 0 : dividas.length;
65470
+ var children = totalOcorrencias ? (React.createElement(Result, null,
65471
+ React.createElement(DividasPublicasList, { dividas: dividas }))) : null;
65387
65472
  return {
65388
65473
  children: children,
65389
- className: ((dividas === null || dividas === void 0 ? void 0 : dividas.length) && "gradient-error") || "",
65390
- description: (dividas === null || dividas === void 0 ? void 0 : dividas.length) ? "".concat(dividas === null || dividas === void 0 ? void 0 : dividas.length, " d\u00EDvidas encontradas") : 'Nenhuma dívida pública encontrada'
65474
+ variant: totalOcorrencias ? 'error' : 'default',
65475
+ description: (React.createElement(StatusMessage, { type: totalOcorrencias ? 'error' : 'default' }, totalOcorrencias
65476
+ ? totalOcorrencias === 1
65477
+ ? "Encontrado uma dívida pública"
65478
+ : "".concat(totalOcorrencias, " d\u00EDvidas encontradas")
65479
+ : "Nenhuma dívida pública encontrada"))
65391
65480
  };
65392
65481
  } }));
65393
65482
  };
65394
65483
  var DividasPublicasList = React.memo(function (_a) {
65395
65484
  var dividas = _a.dividas;
65396
- return (React.createElement(React.Fragment, null, dividas.map(function (divida, i) { return (React.createElement("div", { className: "container", key: i },
65397
- React.createElement("div", { className: "content" },
65398
- React.createElement(AddItemField, { name: "Nome do Devedor", value: divida.nomeDoDevedor }),
65399
- React.createElement(AddItemField, { name: "Tipo de Pessoa", value: divida.tipoDePessoa }),
65400
- React.createElement(AddItemField, { name: "Tipo de Devedor", value: divida.tipoDeDevedor }),
65401
- React.createElement(AddItemField, { name: "Unidade Respons\u00E1vel", value: divida.unidadeResponsavel }),
65402
- React.createElement(AddItemField, { name: "UF da Unidade Respons\u00E1vel", value: divida.uFDaUnidadeResponsavel }),
65403
- React.createElement(AddItemField, { name: "N\u00FAmero de inscri\u00E7\u00E3o da D\u00EDvida", value: divida.numeroDeInscricaoDaDivida }),
65404
- React.createElement(AddItemField, { name: "Tipo da Situa\u00E7\u00E3o da Inscri\u00E7\u00E3o", value: divida.tipoDaSituacaoDaInscricao }),
65405
- React.createElement(AddItemField, { name: "Situa\u00E7\u00E3o da Inscri\u00E7\u00E3o", value: divida.situacaoDaInscricao }),
65406
- React.createElement(AddItemField, { name: "Data de Inscri\u00E7\u00E3o", value: divida.dataDeInscricao }),
65407
- React.createElement(AddItemField, { name: "Indicador Aju\u00EDzado", value: divida.indicadorAjuizado }),
65408
- React.createElement(AddItemField, { name: "Valor consolidado", value: divida.valorConsolidado }),
65409
- React.createElement(AddItemField, { name: "Tipo de D\u00EDvida", value: divida.tipoDeDivida })))); })));
65485
+ return (React.createElement(Result, null, dividas.map(function (divida, i) { return (React.createElement(ResultContent, { desktop: "repeat(7, 1fr)", tablet: "repeat(3, 1fr)", mobile: "repeat(1, 1fr)", key: i, className: "content" },
65486
+ React.createElement(AddItemField, { name: "Nome do Devedor", value: divida.nomeDoDevedor }),
65487
+ React.createElement(AddItemField, { name: "Tipo de Pessoa", value: divida.tipoDePessoa }),
65488
+ React.createElement(AddItemField, { name: "Tipo de Devedor", value: divida.tipoDeDevedor }),
65489
+ React.createElement(AddItemField, { name: "Unidade Respons\u00E1vel", value: divida.unidadeResponsavel }),
65490
+ React.createElement(AddItemField, { name: "UF da Unidade Respons\u00E1vel", value: divida.uFDaUnidadeResponsavel }),
65491
+ React.createElement(AddItemField, { name: "N\u00FAmero de inscri\u00E7\u00E3o da D\u00EDvida", value: divida.numeroDeInscricaoDaDivida }),
65492
+ React.createElement(AddItemField, { name: "Tipo da Situa\u00E7\u00E3o da Inscri\u00E7\u00E3o", value: divida.tipoDaSituacaoDaInscricao }),
65493
+ React.createElement(AddItemField, { name: "Situa\u00E7\u00E3o da Inscri\u00E7\u00E3o", value: divida.situacaoDaInscricao }),
65494
+ React.createElement(AddItemField, { name: "Data de Inscri\u00E7\u00E3o", value: divida.dataDeInscricao }),
65495
+ React.createElement(AddItemField, { name: "Indicador Aju\u00EDzado", value: divida.indicadorAjuizado }),
65496
+ React.createElement(AddItemField, { name: "Valor consolidado", value: divida.valorConsolidado }),
65497
+ React.createElement(AddItemField, { name: "Tipo de D\u00EDvida", value: divida.tipoDeDivida }))); })));
65410
65498
  });
65411
65499
 
65412
65500
  var PessoaPoliticamenteExposta = function () {
@@ -65451,13 +65539,6 @@ var PefinRefinSerasaIcon = function (_a) {
65451
65539
  React.createElement("path", { stroke: "#fff", strokeLinecap: "round", strokeWidth: "2", d: "M23 25L5 7" })));
65452
65540
  };
65453
65541
 
65454
- var DividasVencidasSerasaIcon = function (_a) {
65455
- var _b = _a.className, className = _b === void 0 ? "" : _b, _c = _a.size, size = _c === void 0 ? 30 : _c, _d = _a.circleFill, circleFill = _d === void 0 ? theme.colors.azulCredithub : _d;
65456
- return (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, fill: "none", viewBox: "0 0 30 30", className: className },
65457
- React.createElement("circle", { cx: "15", cy: "15", r: "15", fill: circleFill }),
65458
- React.createElement("path", { fill: "#fff", d: "M15 19.4L13.4 21a.948.948 0 01-.7.275A.948.948 0 0112 21a.948.948 0 01-.275-.7c0-.283.092-.517.275-.7l1.6-1.6-1.6-1.6a.948.948 0 01-.275-.7c0-.283.092-.517.275-.7a.948.948 0 01.7-.275c.283 0 .517.092.7.275l1.6 1.6 1.6-1.6a.948.948 0 01.7-.275c.283 0 .517.092.7.275a.948.948 0 01.275.7.948.948 0 01-.275.7L16.4 18l1.6 1.6a.948.948 0 01.275.7.948.948 0 01-.275.7.948.948 0 01-.7.275.948.948 0 01-.7-.275L15 19.4zM8 25c-.55 0-1.02-.196-1.412-.587A1.926 1.926 0 016 23V9c0-.55.196-1.02.588-1.412A1.926 1.926 0 018 7h1V6c0-.283.096-.52.287-.713A.968.968 0 0110 5c.283 0 .52.096.713.287.191.192.287.43.287.713v1h8V6c0-.283.096-.52.288-.713A.968.968 0 0120 5c.283 0 .52.096.712.287.192.192.288.43.288.713v1h1c.55 0 1.02.196 1.413.588.391.391.587.862.587 1.412v14c0 .55-.196 1.02-.587 1.413A1.926 1.926 0 0122 25H8zm0-2h14V13H8v10zm0-12h14V9H8v2z" })));
65459
- };
65460
-
65461
65542
  var __assign$2 = (undefined && undefined.__assign) || function () {
65462
65543
  __assign$2 = Object.assign || function(t) {
65463
65544
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from "react";
2
- declare const Button: React.FC<React.HTMLAttributes<HTMLButtonElement> & {
2
+ declare const Button: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & {
3
3
  smallContent?: ReactNode;
4
4
  }>;
5
5
  export default Button;
@@ -10,13 +10,15 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
10
10
  import React, { memo, useContext } from "react";
11
11
  import { Queries } from "../webservice";
12
12
  import XPathUtils from "../../utils/xpath";
13
- import { Result } from "../interface/result";
13
+ import { Result, ResultContent } from "../interface/result";
14
14
  import AddItemField from "../common/addItem";
15
15
  import { formatMoney } from "../../utils/number";
16
+ import DividasVencidasSerasaIcon from "../../assets/icones/dividasVencidasSerasa";
17
+ import StatusMessage from "../interface/statusMessage";
16
18
  var DividasPublicas = function () {
17
19
  var ctx = useContext(Queries.Finder);
18
20
  var Section = ctx.Section;
19
- return (React.createElement(Section, { title: "Dividas P\u00FAblicas", subtitle: "Vejas As D\u00EDvidas P\u00FAblicas Com A Uni\u00E3o (Ativa, Fgts E Previdenciaria)", onSuccess: function (document) {
21
+ return (React.createElement(Section, { title: "Dividas P\u00FAblicas", icon: DividasVencidasSerasaIcon, subtitle: "Vejas As D\u00EDvidas P\u00FAblicas Com A Uni\u00E3o (Ativa, Fgts E Previdenciaria)", onSuccess: function (document) {
20
22
  var parseDividas = function (tipo) { return function (divida) { return ({
21
23
  nomeDoDevedor: XPathUtils.select('string(./nome_devedor)', divida),
22
24
  tipoDePessoa: XPathUtils.select('string(./tipo_pessoa)', divida),
@@ -32,30 +34,34 @@ var DividasPublicas = function () {
32
34
  tipoDeDivida: tipo
33
35
  }); }; };
34
36
  var dividas = __spreadArray(__spreadArray(__spreadArray([], XPathUtils.selectArray('//dividas/fgts/divida', document).map(parseDividas('FGTS')), true), XPathUtils.selectArray('//dividas/previdenciaria/divida', document).map(parseDividas('Previdenciária')), true), XPathUtils.selectArray('//dividas/ativa-geral/divida', document).map(parseDividas('Divida Ativa União')), true);
35
- var children = (React.createElement(Result, null,
36
- React.createElement(DividasPublicasList, { dividas: dividas })));
37
+ var totalOcorrencias = dividas === null || dividas === void 0 ? void 0 : dividas.length;
38
+ var children = totalOcorrencias ? (React.createElement(Result, null,
39
+ React.createElement(DividasPublicasList, { dividas: dividas }))) : null;
37
40
  return {
38
41
  children: children,
39
- className: ((dividas === null || dividas === void 0 ? void 0 : dividas.length) && "gradient-error") || "",
40
- description: (dividas === null || dividas === void 0 ? void 0 : dividas.length) ? "".concat(dividas === null || dividas === void 0 ? void 0 : dividas.length, " d\u00EDvidas encontradas") : 'Nenhuma dívida pública encontrada'
42
+ variant: totalOcorrencias ? 'error' : 'default',
43
+ description: (React.createElement(StatusMessage, { type: totalOcorrencias ? 'error' : 'default' }, totalOcorrencias
44
+ ? totalOcorrencias === 1
45
+ ? "Encontrado uma dívida pública"
46
+ : "".concat(totalOcorrencias, " d\u00EDvidas encontradas")
47
+ : "Nenhuma dívida pública encontrada"))
41
48
  };
42
49
  } }));
43
50
  };
44
51
  var DividasPublicasList = memo(function (_a) {
45
52
  var dividas = _a.dividas;
46
- return (React.createElement(React.Fragment, null, dividas.map(function (divida, i) { return (React.createElement("div", { className: "container", key: i },
47
- React.createElement("div", { className: "content" },
48
- React.createElement(AddItemField, { name: "Nome do Devedor", value: divida.nomeDoDevedor }),
49
- React.createElement(AddItemField, { name: "Tipo de Pessoa", value: divida.tipoDePessoa }),
50
- React.createElement(AddItemField, { name: "Tipo de Devedor", value: divida.tipoDeDevedor }),
51
- React.createElement(AddItemField, { name: "Unidade Respons\u00E1vel", value: divida.unidadeResponsavel }),
52
- React.createElement(AddItemField, { name: "UF da Unidade Respons\u00E1vel", value: divida.uFDaUnidadeResponsavel }),
53
- React.createElement(AddItemField, { name: "N\u00FAmero de inscri\u00E7\u00E3o da D\u00EDvida", value: divida.numeroDeInscricaoDaDivida }),
54
- React.createElement(AddItemField, { name: "Tipo da Situa\u00E7\u00E3o da Inscri\u00E7\u00E3o", value: divida.tipoDaSituacaoDaInscricao }),
55
- React.createElement(AddItemField, { name: "Situa\u00E7\u00E3o da Inscri\u00E7\u00E3o", value: divida.situacaoDaInscricao }),
56
- React.createElement(AddItemField, { name: "Data de Inscri\u00E7\u00E3o", value: divida.dataDeInscricao }),
57
- React.createElement(AddItemField, { name: "Indicador Aju\u00EDzado", value: divida.indicadorAjuizado }),
58
- React.createElement(AddItemField, { name: "Valor consolidado", value: divida.valorConsolidado }),
59
- React.createElement(AddItemField, { name: "Tipo de D\u00EDvida", value: divida.tipoDeDivida })))); })));
53
+ return (React.createElement(Result, null, dividas.map(function (divida, i) { return (React.createElement(ResultContent, { desktop: "repeat(7, 1fr)", tablet: "repeat(3, 1fr)", mobile: "repeat(1, 1fr)", key: i, className: "content" },
54
+ React.createElement(AddItemField, { name: "Nome do Devedor", value: divida.nomeDoDevedor }),
55
+ React.createElement(AddItemField, { name: "Tipo de Pessoa", value: divida.tipoDePessoa }),
56
+ React.createElement(AddItemField, { name: "Tipo de Devedor", value: divida.tipoDeDevedor }),
57
+ React.createElement(AddItemField, { name: "Unidade Respons\u00E1vel", value: divida.unidadeResponsavel }),
58
+ React.createElement(AddItemField, { name: "UF da Unidade Respons\u00E1vel", value: divida.uFDaUnidadeResponsavel }),
59
+ React.createElement(AddItemField, { name: "N\u00FAmero de inscri\u00E7\u00E3o da D\u00EDvida", value: divida.numeroDeInscricaoDaDivida }),
60
+ React.createElement(AddItemField, { name: "Tipo da Situa\u00E7\u00E3o da Inscri\u00E7\u00E3o", value: divida.tipoDaSituacaoDaInscricao }),
61
+ React.createElement(AddItemField, { name: "Situa\u00E7\u00E3o da Inscri\u00E7\u00E3o", value: divida.situacaoDaInscricao }),
62
+ React.createElement(AddItemField, { name: "Data de Inscri\u00E7\u00E3o", value: divida.dataDeInscricao }),
63
+ React.createElement(AddItemField, { name: "Indicador Aju\u00EDzado", value: divida.indicadorAjuizado }),
64
+ React.createElement(AddItemField, { name: "Valor consolidado", value: divida.valorConsolidado }),
65
+ React.createElement(AddItemField, { name: "Tipo de D\u00EDvida", value: divida.tipoDeDivida }))); })));
60
66
  });
61
67
  export default DividasPublicas;
@@ -4,7 +4,7 @@ import { useQuery } from "../webservice";
4
4
  import XPathUtils from '../../utils/xpath';
5
5
  var PartnerProtestos = function (_a) {
6
6
  var documento = _a.documento;
7
- var _b = useQuery("SELECT FROM 'APICENPROT'.'PRINT'", { documento: documento }), isLoading = _b.isLoading, error = _b.error, response = _b.response;
7
+ var _b = useQuery("SELECT FROM 'IEPTB'.'IEPTBHARLAN'", { documento: documento }), isLoading = _b.isLoading, error = _b.error, response = _b.response;
8
8
  return isLoading ? React.createElement(Loading, null) : error ? 'Houve um erro ao obter a informação.' : XPathUtils.select('string(//registros)', response === null || response === void 0 ? void 0 : response.document);
9
9
  };
10
10
  export default PartnerProtestos;
@@ -15,6 +15,7 @@ import ProtestosCreditoIcon from "../../assets/icones/protestosCredito";
15
15
  import ProtestosImpostosIcon from "../../assets/icones/protestosImpostos";
16
16
  import StatusMessage from "../interface/statusMessage";
17
17
  import styled from "styled-components";
18
+ import { formatDatePtBrToDate } from "../../utils/string";
18
19
  var ResultProtestos = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n row-gap: 20px;\n margin-top: 20px;\n"], ["\n display: flex;\n flex-direction: column;\n row-gap: 20px;\n margin-top: 20px;\n"])));
19
20
  var Protestos = function () {
20
21
  var ctx = useContext(Queries.Protestos);
@@ -25,14 +26,15 @@ var Protestos = function () {
25
26
  });
26
27
  };
27
28
  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) {
29
+ var byDate = function (protesto, protesto2) { var _a, _b; return ((_a = formatDatePtBrToDate(XPathUtils.select("string(./dataProtesto)", protesto2))) === null || _a === void 0 ? void 0 : _a.getTime()) - ((_b = formatDatePtBrToDate(XPathUtils.select("string(./dataProtesto)", protesto))) === null || _b === void 0 ? void 0 : _b.getTime()); };
28
30
  var registros = XPathUtils.select("number(//registros)", data);
29
- var protestosDeCredito = filterProtestos(REGEX_PROTESTOS_DE_CREDITO, data);
30
- var protestosDeImposto = filterProtestos(REGEX_PROTESTOS_DE_IMPOSTO, data);
31
+ var protestosDeCredito = filterProtestos(REGEX_PROTESTOS_DE_CREDITO, data).sort(byDate);
32
+ var protestosDeImposto = filterProtestos(REGEX_PROTESTOS_DE_IMPOSTO, data).sort(byDate);
31
33
  var protestosGerais = XPathUtils.selectArray("//body//protesto", data).filter(function (protesto) {
32
34
  var nomeCedente = XPathUtils.select("string(./nomeCedente)", protesto);
33
35
  return (!REGEX_PROTESTOS_DE_IMPOSTO.test(nomeCedente) &&
34
36
  !REGEX_PROTESTOS_DE_CREDITO.test(nomeCedente));
35
- });
37
+ }).sort(byDate);
36
38
  var elements = [
37
39
  {
38
40
  total: protestosDeCredito === null || protestosDeCredito === void 0 ? void 0 : protestosDeCredito.length,
@@ -13,6 +13,9 @@ export type ProtestoData = {
13
13
  export declare const ProtestoItem: React.MemoExoticComponent<({ protesto }: {
14
14
  protesto: Node;
15
15
  }) => React.JSX.Element>;
16
+ export declare const Instrumento: ({ nm_chave }: {
17
+ nm_chave?: string | undefined;
18
+ }) => React.JSX.Element | null;
16
19
  export declare const ProtestosList: React.FC<{
17
20
  protestos: Node[];
18
21
  }>;
@@ -1,9 +1,47 @@
1
- import React, { memo } from "react";
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import React, { memo, useContext } from "react";
2
38
  import AddItemField from "../common/addItem";
3
39
  import XPathUtils from "../../utils/xpath";
4
40
  import { formatMoney } from "../../utils/number";
5
41
  import { ResultContent } from "../interface/result";
6
42
  import { formatDocument } from "../../utils/string";
43
+ import Button from "../common/button";
44
+ import { WebService } from "../webservice";
7
45
  export var ProtestoItem = memo(function (_a) {
8
46
  var protesto = _a.protesto;
9
47
  var getField = function (path, formatter) {
@@ -13,15 +51,54 @@ export var ProtestoItem = memo(function (_a) {
13
51
  var formatBooleanField = function (value) {
14
52
  return value === "true" ? "Sim" : "Não";
15
53
  };
16
- return (React.createElement(ResultContent, { desktop: "repeat(7, 1fr)", tablet: "repeat(4, 1fr)", mobile: "repeat(2, 1fr)" },
54
+ return (React.createElement(ResultContent, { desktop: "repeat(8, 1fr)", tablet: "repeat(4, 1fr)", mobile: "repeat(2, 1fr)" },
17
55
  React.createElement(AddItemField, { name: "Quem Protestou", value: getField("./nomeCedente") }),
18
56
  React.createElement(AddItemField, { name: "Atrav\u00E9s De", value: getField("./nomeApresentante") }),
19
57
  React.createElement(AddItemField, { name: "CPF/CNPJ Protestado", value: formatDocument(getField("./cpfCnpj")) }),
20
58
  React.createElement(AddItemField, { name: "Data Do Protesto", value: getField("./dataProtesto") }),
21
59
  React.createElement(AddItemField, { name: "Possui Anu\u00EAncia", value: formatBooleanField(getField("./temAnuencia")) }),
22
60
  React.createElement(AddItemField, { name: "Anu\u00EAncia Vencida", value: formatBooleanField(getField("./anuenciaVencida")) }),
23
- React.createElement(AddItemField, { name: "Valor Do Protesto", value: formatMoney(getField("./valor")) })));
61
+ React.createElement(AddItemField, { name: "Valor Do Protesto", value: formatMoney(getField("./valor")) }),
62
+ React.createElement(Instrumento, { nm_chave: getField("./nm_chave") })));
24
63
  });
64
+ export var Instrumento = function (_a) {
65
+ var nm_chave = _a.nm_chave;
66
+ var client = useContext(WebService);
67
+ var _b = React.useState(), error = _b[0], setError = _b[1];
68
+ var _c = React.useState(false), isLoading = _c[0], setIsLoading = _c[1];
69
+ if (!nm_chave)
70
+ return null;
71
+ return React.createElement(Button, { onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
72
+ var request, pdfWindow, e_1;
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0:
76
+ setIsLoading(true);
77
+ _a.label = 1;
78
+ case 1:
79
+ _a.trys.push([1, 4, 5, 6]);
80
+ return [4 /*yield*/, client.request("SELECT FROM 'IEPTB'.'PDF'", { nm_chave: nm_chave })];
81
+ case 2: return [4 /*yield*/, (_a.sent()).json()];
82
+ case 3:
83
+ request = _a.sent();
84
+ pdfWindow = window.open('', '_blank');
85
+ if (!pdfWindow)
86
+ return [2 /*return*/];
87
+ pdfWindow.document.write("<iframe width='100%' height='100%' src='data:application/pdf;base64,".concat(request === null || request === void 0 ? void 0 : request.instrumentoProtesto, "'></iframe>"));
88
+ return [3 /*break*/, 6];
89
+ case 4:
90
+ e_1 = _a.sent();
91
+ console.error(e_1);
92
+ setError(true);
93
+ return [3 /*break*/, 6];
94
+ case 5:
95
+ setIsLoading(false);
96
+ return [7 /*endfinally*/];
97
+ case 6: return [2 /*return*/];
98
+ }
99
+ });
100
+ }); }, disabled: isLoading }, error ? 'Instrumento não Localizado' : 'Instrumento');
101
+ };
25
102
  export var ProtestosList = function (_a) {
26
103
  var protestos = _a.protestos;
27
104
  return (React.createElement(ResultContent, null, (protestos === null || protestos === void 0 ? void 0 : protestos.length) ? (protestos.map(function (protesto, i) { return (React.createElement(ProtestoItem, { key: i, protesto: protesto })); })) : (React.createElement(AddItemField, { name: "Informa\u00E7\u00E3o", value: "N\u00E3o h\u00E1 registros de protestos." }))));
@@ -3,7 +3,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
3
3
  return cooked;
4
4
  };
5
5
  import React from "react";
6
- import { Contacts, Partners, Dossie, Addresses, CCF, Protestos, ProcessosJuridicos, BankAccounts, WebServiceProvider, Queries, RefinSerasa, RefinBoaVista, Veiculos, ChartSystem, } from "./";
6
+ import { Contacts, Partners, Dossie, Addresses, CCF, Protestos, ProcessosJuridicos, BankAccounts, WebServiceProvider, Queries, RefinSerasa, RefinBoaVista, Veiculos, ChartSystem, DividasPublicas, } from "./";
7
7
  import { ConsultasComplementaresProvider, } from "./components/consultasComplementares";
8
8
  import ConsultaSCR from "./components/scr/scr";
9
9
  import ConsultaScore from "./components/score/scoreService";
@@ -50,6 +50,7 @@ var ConsultaSimples = function (_a) {
50
50
  React.createElement(Veiculos, { documento: documento })),
51
51
  React.createElement(Protestos, null),
52
52
  React.createElement(CCF, null),
53
+ React.createElement(DividasPublicas, null),
53
54
  React.createElement(ProcessosJuridicos, { onClickConsultarProcessoJuridico: onClickConsultarProcessoJuridico })))))))))))));
54
55
  };
55
56
  export default ConsultaSimples;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credithub/harlan-components",
3
- "version": "1.16.3",
3
+ "version": "1.18.0",
4
4
  "description": "Provide a set of web components to be used in Harlan and other projects",
5
5
  "keywords": [
6
6
  "harlan",