@credithub/harlan-components 1.2.0 → 1.3.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.
Files changed (93) hide show
  1. package/lib/cjs/components/adresses/adresses.js +1 -1
  2. package/lib/cjs/components/adresses/getGeocode.js +15 -16
  3. package/lib/cjs/components/bank-accounts/bank-accounts.d.ts +1 -1
  4. package/lib/cjs/components/bank-accounts/bank-accounts.js +8 -10
  5. package/lib/cjs/components/ccf/ccf.d.ts +2 -5
  6. package/lib/cjs/components/ccf/ccf.js +59 -22
  7. package/lib/cjs/components/ccf/ccfList.d.ts +1 -2
  8. package/lib/cjs/components/ccf/ccfList.js +2 -3
  9. package/lib/cjs/components/contacts/contactLikeDislikeSection.d.ts +8 -0
  10. package/lib/cjs/components/contacts/contactLikeDislikeSection.js +89 -0
  11. package/lib/cjs/components/contacts/contacts.d.ts +6 -2
  12. package/lib/cjs/components/contacts/contacts.js +15 -12
  13. package/lib/cjs/components/dossie/dossie.d.ts +1 -1
  14. package/lib/cjs/components/dossie/dossie.js +9 -5
  15. package/lib/cjs/components/interface/loading.d.ts +2 -0
  16. package/lib/cjs/components/interface/loading.js +14 -0
  17. package/lib/cjs/components/interface/section.js +1 -1
  18. package/lib/cjs/components/partners/partner-dividas-publicas.d.ts +5 -0
  19. package/lib/cjs/components/partners/partner-dividas-publicas.js +15 -0
  20. package/lib/cjs/components/partners/partner-protestos.d.ts +5 -0
  21. package/lib/cjs/components/partners/partner-protestos.js +15 -0
  22. package/lib/cjs/components/partners/partner-rfb-status.d.ts +5 -0
  23. package/lib/cjs/components/partners/partner-rfb-status.js +15 -0
  24. package/lib/cjs/components/partners/partnerList.d.ts +4 -4
  25. package/lib/cjs/components/partners/partnerList.js +2 -2
  26. package/lib/cjs/components/partners/partners.js +13 -6
  27. package/lib/cjs/components/processos-juridicos/envolvidosList.d.ts +2 -1
  28. package/lib/cjs/components/processos-juridicos/envolvidosList.js +1 -1
  29. package/lib/cjs/components/processos-juridicos/processosJuridicos.d.ts +2 -4
  30. package/lib/cjs/components/processos-juridicos/processosJuridicos.js +40 -14
  31. package/lib/cjs/components/processos-juridicos/processosJuridicosList.d.ts +3 -11
  32. package/lib/cjs/components/processos-juridicos/processosJuridicosList.js +34 -8
  33. package/lib/cjs/components/processos-juridicos/types.d.ts +27 -0
  34. package/lib/cjs/components/processos-juridicos/types.js +2 -0
  35. package/lib/cjs/components/protestos/protestos.js +7 -6
  36. package/lib/cjs/components/reclameAqui/reclameAquiCarousel.js +9 -9
  37. package/lib/cjs/components/webservice.d.ts +40 -0
  38. package/lib/cjs/components/webservice.js +102 -17
  39. package/lib/cjs/consultaSimples.d.ts +8 -0
  40. package/lib/cjs/consultaSimples.js +25 -0
  41. package/lib/cjs/index.d.ts +7 -3
  42. package/lib/cjs/index.js +7 -1
  43. package/lib/cjs/utils/number.d.ts +1 -0
  44. package/lib/cjs/utils/number.js +10 -1
  45. package/lib/esm/components/adresses/adresses.js +1 -1
  46. package/lib/esm/components/adresses/getGeocode.js +15 -13
  47. package/lib/esm/components/bank-accounts/bank-accounts.d.ts +1 -1
  48. package/lib/esm/components/bank-accounts/bank-accounts.js +11 -13
  49. package/lib/esm/components/ccf/ccf.d.ts +2 -5
  50. package/lib/esm/components/ccf/ccf.js +38 -24
  51. package/lib/esm/components/ccf/ccfList.d.ts +1 -2
  52. package/lib/esm/components/ccf/ccfList.js +2 -3
  53. package/lib/esm/components/contacts/contactLikeDislikeSection.d.ts +8 -0
  54. package/lib/esm/components/contacts/contactLikeDislikeSection.js +61 -0
  55. package/lib/esm/components/contacts/contacts.d.ts +6 -2
  56. package/lib/esm/components/contacts/contacts.js +15 -13
  57. package/lib/esm/components/dossie/dossie.d.ts +1 -1
  58. package/lib/esm/components/dossie/dossie.js +10 -6
  59. package/lib/esm/components/interface/loading.d.ts +2 -0
  60. package/lib/esm/components/interface/loading.js +8 -0
  61. package/lib/esm/components/interface/section.js +1 -1
  62. package/lib/esm/components/partners/partner-dividas-publicas.d.ts +5 -0
  63. package/lib/esm/components/partners/partner-dividas-publicas.js +10 -0
  64. package/lib/esm/components/partners/partner-protestos.d.ts +5 -0
  65. package/lib/esm/components/partners/partner-protestos.js +10 -0
  66. package/lib/esm/components/partners/partner-rfb-status.d.ts +5 -0
  67. package/lib/esm/components/partners/partner-rfb-status.js +10 -0
  68. package/lib/esm/components/partners/partnerList.d.ts +4 -4
  69. package/lib/esm/components/partners/partnerList.js +2 -2
  70. package/lib/esm/components/partners/partners.js +13 -6
  71. package/lib/esm/components/processos-juridicos/envolvidosList.d.ts +2 -1
  72. package/lib/esm/components/processos-juridicos/envolvidosList.js +1 -1
  73. package/lib/esm/components/processos-juridicos/processosJuridicos.d.ts +2 -4
  74. package/lib/esm/components/processos-juridicos/processosJuridicos.js +19 -16
  75. package/lib/esm/components/processos-juridicos/processosJuridicosList.d.ts +3 -11
  76. package/lib/esm/components/processos-juridicos/processosJuridicosList.js +33 -7
  77. package/lib/esm/components/processos-juridicos/types.d.ts +27 -0
  78. package/lib/esm/components/processos-juridicos/types.js +1 -0
  79. package/lib/esm/components/protestos/protestos.js +7 -6
  80. package/lib/esm/components/reclameAqui/reclameAquiCarousel.js +9 -9
  81. package/lib/esm/components/webservice.d.ts +40 -0
  82. package/lib/esm/components/webservice.js +100 -17
  83. package/lib/esm/consultaSimples.d.ts +8 -0
  84. package/lib/esm/consultaSimples.js +20 -0
  85. package/lib/esm/index.d.ts +7 -3
  86. package/lib/esm/index.js +7 -3
  87. package/lib/esm/utils/number.d.ts +1 -0
  88. package/lib/esm/utils/number.js +8 -0
  89. package/package.json +1 -2
  90. /package/lib/cjs/components/{resultWithoutInformation/ResultWithoutInformation.d.ts → interface/resultWithoutInformation.d.ts} +0 -0
  91. /package/lib/cjs/components/{resultWithoutInformation/ResultWithoutInformation.js → interface/resultWithoutInformation.js} +0 -0
  92. /package/lib/esm/components/{resultWithoutInformation/ResultWithoutInformation.d.ts → interface/resultWithoutInformation.d.ts} +0 -0
  93. /package/lib/esm/components/{resultWithoutInformation/ResultWithoutInformation.js → interface/resultWithoutInformation.js} +0 -0
package/lib/cjs/index.js CHANGED
@@ -17,11 +17,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.BankAccounts = exports.Addresses = exports.ProcessosJuridicos = exports.Dossie = exports.CCF = exports.Protestos = exports.Partners = exports.Contacts = exports.AddItemField = exports.Header = exports.Section = void 0;
20
+ exports.ResultWithoutInformation = exports.BankAccounts = exports.Addresses = exports.ProcessosJuridicos = exports.Dossie = exports.CCF = exports.Protestos = exports.Partners = exports.Contacts = exports.AddItemField = exports.Loading = exports.Header = exports.Section = void 0;
21
21
  var section_1 = require("./components/interface/section");
22
22
  Object.defineProperty(exports, "Section", { enumerable: true, get: function () { return __importDefault(section_1).default; } });
23
23
  var header_1 = require("./components/interface/header");
24
24
  Object.defineProperty(exports, "Header", { enumerable: true, get: function () { return __importDefault(header_1).default; } });
25
+ var loading_1 = require("./components/interface/loading");
26
+ Object.defineProperty(exports, "Loading", { enumerable: true, get: function () { return __importDefault(loading_1).default; } });
25
27
  var addItem_1 = require("./components/common/addItem");
26
28
  Object.defineProperty(exports, "AddItemField", { enumerable: true, get: function () { return __importDefault(addItem_1).default; } });
27
29
  var contacts_1 = require("./components/contacts/contacts");
@@ -40,4 +42,8 @@ var adresses_1 = require("./components/adresses/adresses");
40
42
  Object.defineProperty(exports, "Addresses", { enumerable: true, get: function () { return __importDefault(adresses_1).default; } });
41
43
  var bank_accounts_1 = require("./components/bank-accounts/bank-accounts");
42
44
  Object.defineProperty(exports, "BankAccounts", { enumerable: true, get: function () { return __importDefault(bank_accounts_1).default; } });
45
+ var resultWithoutInformation_1 = require("./components/interface/resultWithoutInformation");
46
+ Object.defineProperty(exports, "ResultWithoutInformation", { enumerable: true, get: function () { return __importDefault(resultWithoutInformation_1).default; } });
47
+ __exportStar(require("./components/webservice"), exports);
43
48
  __exportStar(require("./components/interface/result"), exports);
49
+ __exportStar(require("./consultaSimples"), exports);
@@ -1 +1,2 @@
1
1
  export declare const formatMoney: (value: string | number) => string;
2
+ export declare const phoneMask: (value: string) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatMoney = void 0;
3
+ exports.phoneMask = exports.formatMoney = void 0;
4
4
  var formatMoney = function (value) {
5
5
  return new Intl.NumberFormat('pt-BR', {
6
6
  style: 'currency',
@@ -8,3 +8,12 @@ var formatMoney = function (value) {
8
8
  }).format(Number(value));
9
9
  };
10
10
  exports.formatMoney = formatMoney;
11
+ var phoneMask = function (value) {
12
+ if (!value)
13
+ return "";
14
+ value = value.replace(/\D/g, '');
15
+ value = value.replace(/(\d{2})(\d)/, "($1) $2");
16
+ value = value.replace(/(\d)(\d{4})$/, "$1-$2");
17
+ return value;
18
+ };
19
+ exports.phoneMask = phoneMask;
@@ -9,7 +9,7 @@ var Addresses = function (_a) {
9
9
  var apiKey = _a.apiKey;
10
10
  var ctx = useContext(Queries.Finder);
11
11
  var Section = ctx.Section;
12
- return (React.createElement(Section, { title: "Endere\u00E7os", subtitle: "Localiza\u00E7\u00E3o", description: "Endere\u00E7amento e Mapa", ctx: ctx, onLoading: function () { return React.createElement(React.Fragment, null, "Carregando..."); }, onError: function () { return React.createElement(React.Fragment, null, "Erro"); }, onSuccess: function (data) {
12
+ return (React.createElement(Section, { title: "Endere\u00E7os", subtitle: "Localiza\u00E7\u00E3o", description: "Endere\u00E7amento e Mapa", ctx: ctx, onError: function () { return React.createElement(React.Fragment, null, "Erro"); }, onSuccess: function (data) {
13
13
  var _addresses = XPathUtils.select("//enderecos/enderecos", data);
14
14
  var addresses = _addresses.map(function (address) { return ({
15
15
  type: XPathUtils.select('string(//tipoLogradouro)', address),
@@ -34,33 +34,35 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
34
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
35
  }
36
36
  };
37
- import axios from "axios";
38
37
  export function getGeocode(address, apiKey) {
39
38
  return __awaiter(this, void 0, void 0, function () {
40
- var response, results, location_1, error_1;
39
+ var url, response, data, results, location_1, error_1;
41
40
  return __generator(this, function (_a) {
42
41
  switch (_a.label) {
43
42
  case 0:
44
- _a.trys.push([0, 2, , 3]);
45
- return [4 /*yield*/, axios.get("https://maps.googleapis.com/maps/api/geocode/json", {
46
- params: {
47
- address: address,
48
- key: apiKey,
49
- },
50
- })];
43
+ _a.trys.push([0, 3, , 4]);
44
+ url = new URL("https://maps.googleapis.com/maps/api/geocode/json");
45
+ url.search = new URLSearchParams({ address: address, key: apiKey }).toString();
46
+ return [4 /*yield*/, fetch(url)];
51
47
  case 1:
52
48
  response = _a.sent();
53
- results = response.data.results;
54
- if (results.length > 0) {
49
+ if (!response.ok) {
50
+ throw new Error("Erro na requisi\u00E7\u00E3o: ".concat(response.status));
51
+ }
52
+ return [4 /*yield*/, response.json()];
53
+ case 2:
54
+ data = _a.sent();
55
+ results = data.results;
56
+ if (results && results.length > 0) {
55
57
  location_1 = results[0].geometry.location;
56
58
  return [2 /*return*/, { lat: location_1.lat, lng: location_1.lng }];
57
59
  }
58
60
  return [2 /*return*/, null];
59
- case 2:
61
+ case 3:
60
62
  error_1 = _a.sent();
61
63
  console.error("Erro ao obter geocódigo:", error_1);
62
64
  return [2 /*return*/, null];
63
- case 3: return [2 /*return*/];
65
+ case 4: return [2 /*return*/];
64
66
  }
65
67
  });
66
68
  });
@@ -1,3 +1,3 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  declare const BankAccounts: () => React.JSX.Element;
3
3
  export default BankAccounts;
@@ -1,23 +1,21 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
  import { useContext } from "react";
3
3
  import { Queries } from "../webservice";
4
- import { Result } from '../interface/result';
5
- import AddItemField from '../common/addItem';
6
- import XPathUtils from '../../utils/xpath';
7
- import ResultWithoutInformation from '../resultWithoutInformation/ResultWithoutInformation';
4
+ import { Result } from "../interface/result";
5
+ import AddItemField from "../common/addItem";
6
+ import XPathUtils from "../../utils/xpath";
7
+ import ResultWithoutInformation from "../interface/resultWithoutInformation";
8
8
  var BankAccounts = function () {
9
9
  var ctx = useContext(Queries.Finder);
10
10
  var Section = ctx.Section;
11
- return (React.createElement(Section, { title: 'Informações de Contas Bancárias', subtitle: 'Vejas as informações disponíveis de contas bancárias', ctx: ctx, onSuccess: function (data) {
12
- var accounts = XPathUtils.select('//bank-info/node', data);
11
+ return (React.createElement(Section, { title: "Informações de Contas Bancárias", subtitle: "Vejas as informações disponíveis de contas bancárias", ctx: ctx, onSuccess: function (data) {
12
+ var accounts = XPathUtils.select("//bank-info/node", data);
13
13
  if (!(accounts === null || accounts === void 0 ? void 0 : accounts.length))
14
14
  return React.createElement(ResultWithoutInformation, null);
15
- return (React.createElement(Result, null, accounts.map(function (account, key) {
16
- return React.createElement(Result, { key: key, isContainer: true },
17
- React.createElement(AddItemField, { name: "Banco", value: XPathUtils.select('string(banco)', account) }),
18
- React.createElement(AddItemField, { name: "Ag\u00EAncia", value: XPathUtils.select('string(agencia)', account) }),
19
- React.createElement(AddItemField, { name: "Conta", value: XPathUtils.select('string(conta)', account) }));
20
- })));
15
+ return (React.createElement(Result, null, accounts.map(function (account, key) { return (React.createElement(Result, { key: key, isContainer: true },
16
+ React.createElement(AddItemField, { name: "Banco", value: XPathUtils.select("string(banco)", account) }),
17
+ React.createElement(AddItemField, { name: "Ag\u00EAncia", value: XPathUtils.select("string(agencia)", account) }),
18
+ React.createElement(AddItemField, { name: "Conta", value: XPathUtils.select("string(conta)", account) }))); })));
21
19
  } }));
22
20
  };
23
21
  export default BankAccounts;
@@ -1,6 +1,3 @@
1
- import React from 'react';
2
- import { CCFData } from './ccfList';
3
- declare const CCF: React.FC<{
4
- data: CCFData[];
5
- }>;
1
+ import React from "react";
2
+ declare const CCF: () => React.JSX.Element;
6
3
  export default CCF;
@@ -1,26 +1,40 @@
1
- import React from 'react';
2
- import Header from '../interface/header';
3
- import { Result } from '../interface/result';
4
- import CCFList from './ccfList';
5
- import classNames from 'classnames';
6
- import HeaderAction from '../common/headerAction';
7
- import useToggle from '../../hooks/useToggle';
8
- var CCF = function (_a) {
9
- var data = _a.data;
10
- var _b = useToggle(false), isOpen = _b[0], toggleOpen = _b[1];
11
- if (!(data === null || data === void 0 ? void 0 : data.length))
12
- return (React.createElement(Result, null,
13
- React.createElement(Header, { title: "Cheques Sem Fundos" }),
14
- React.createElement(CCFList, { data: data })));
15
- return (React.createElement(Result, null,
16
- React.createElement(Header, { title: "Cheques Sem Fundo Em Institui\u00E7\u00E3o Banc\u00E1ria", subtitle: "Detalhes Acerca De Cheques Sem Fundo Emitidos", description: "Foram localizados ".concat(data.reduce(function (acc, _a) {
17
- var quantidadeDeOcorrencias = _a.quantidadeDeOcorrencias;
18
- return acc + quantidadeDeOcorrencias;
19
- }, 0), " cheques sem fundo em institui\u00E7\u00F5es banc\u00E1rias."),
20
- //style={{ background: 'url("images/textures/brilliant.png"), linear-gradient(rgb(247, 8, 8), rgb(255, 255, 255) 160%)' }}
21
- className: classNames({
22
- 'gradient-error': data === null || data === void 0 ? void 0 : data.length
23
- }), actions: React.createElement(HeaderAction, { iconClass: isOpen ? "minus-square-o" : "plus-square-o", onClick: toggleOpen }) }),
24
- isOpen && (React.createElement(CCFList, { data: data }))));
1
+ import React, { useContext } from "react";
2
+ import { Queries } from "../webservice";
3
+ import { Result } from "../interface/result";
4
+ import classNames from "classnames";
5
+ import XPathUtils from "../../utils/xpath";
6
+ import CCFList from "./ccfList";
7
+ import ResultWithoutInformation from "../interface/resultWithoutInformation";
8
+ var CCF = function () {
9
+ var ctx = useContext(Queries.CCF);
10
+ var Section = ctx.Section;
11
+ var mapNodeToCCFData = function (node) { return ({
12
+ banco: XPathUtils.select("string(./banco)", node),
13
+ agencia: XPathUtils.select("string(./agencia)", node),
14
+ quantidadeDeOcorrencias: parseInt(XPathUtils.select("string(./qteOcorrencias)", node), 10),
15
+ ultimaOcorrencia: XPathUtils.select("string(./ultimo)", node),
16
+ motivo: XPathUtils.select("string(./motivo)", node),
17
+ }); };
18
+ var calculateTotalOcorrencias = function (ccfData) {
19
+ return ccfData.reduce(function (acc, item) { return acc + item.quantidadeDeOcorrencias; }, 0);
20
+ };
21
+ return (React.createElement(Section, { ctx: ctx, title: "Cheques Sem Fundo Em Institui\u00E7\u00E3o Banc\u00E1ria", subtitle: "Detalhes Acerca De Cheques Sem Fundo Emitidos", onLoading: function () { return React.createElement(React.Fragment, null, "Carregando..."); }, onError: function () { return React.createElement(React.Fragment, null, "Erro"); }, onSuccess: function (data) {
22
+ var allItems = XPathUtils.select("//list/*", data);
23
+ var filteredItems = allItems.filter(function (node) {
24
+ return node.nodeName.startsWith("item");
25
+ });
26
+ var ccfData = filteredItems.map(mapNodeToCCFData);
27
+ var totalOcorrencias = calculateTotalOcorrencias(ccfData);
28
+ var children = totalOcorrencias ? (React.createElement(Result, null, ccfData.map(function (ccf, key) { return (React.createElement(CCFList, { key: key, data: [ccf] })); }))) : (React.createElement(ResultWithoutInformation, null));
29
+ return {
30
+ children: children,
31
+ className: classNames({ "gradient-error": totalOcorrencias > 0 }),
32
+ description: totalOcorrencias
33
+ ? totalOcorrencias === 1
34
+ ? "Encontrado um cheque sem fundo."
35
+ : "Encontrados ".concat(totalOcorrencias, " cheques sem fundo.")
36
+ : "Não há ocorrência de cheques sem fundo.",
37
+ };
38
+ } }));
25
39
  };
26
40
  export default CCF;
@@ -1,11 +1,10 @@
1
1
  import React from "react";
2
2
  export type CCFData = {
3
3
  banco: string;
4
- codigoBancario: string;
5
4
  agencia: string;
6
5
  quantidadeDeOcorrencias: number;
7
6
  ultimaOcorrencia: string;
8
- alinea: string;
7
+ motivo: string;
9
8
  };
10
9
  declare const CCFList: React.FC<{
11
10
  data: CCFData[];
@@ -5,14 +5,13 @@ var CCFItem = memo(function (_a) {
5
5
  var ccf = _a.ccf;
6
6
  return (React.createElement("div", { className: "content-layout" },
7
7
  React.createElement(AddCffField, { name: "Banco", value: ccf.banco }),
8
- React.createElement(AddCffField, { name: "C\u00F3digo Banc\u00E1rio", value: ccf.codigoBancario }),
9
8
  React.createElement(AddCffField, { name: "Ag\u00EAncia", value: ccf.agencia }),
10
9
  React.createElement(AddCffField, { name: "Qtde. Ocorr\u00EAncias", value: ccf.quantidadeDeOcorrencias }),
11
10
  React.createElement(AddCffField, { name: "\u00DAltima Ocorr\u00EAncia (h\u00E1 24 dias)", value: ccf.ultimaOcorrencia }),
12
- React.createElement(AddCffField, { name: "Al\u00EDnea", value: ccf.alinea })));
11
+ React.createElement(AddCffField, { name: "Al\u00EDnea", value: ccf.motivo })));
13
12
  });
14
13
  var CCFList = function (_a) {
15
14
  var data = _a.data;
16
- return (React.createElement(Result, { isContainer: true, contentClassName: 'container-layout' }, (data === null || data === void 0 ? void 0 : data.length) ? data.map(function (ccf, i) { return (React.createElement(CCFItem, { key: i, ccf: ccf })); }) : (React.createElement(AddCffField, { name: "Informa\u00E7\u00E3o", value: "N\u00E3o foi encontrado registros de Cheques Sem Fundos para o documento consultado." }))));
15
+ return (React.createElement(Result, { isContainer: true, contentClassName: "container-layout" }, (data === null || data === void 0 ? void 0 : data.length) ? (data.map(function (ccf, i) { return React.createElement(CCFItem, { key: i, ccf: ccf }); })) : (React.createElement(AddCffField, { name: "Informa\u00E7\u00E3o", value: "N\u00E3o foi encontrado registros de Cheques Sem Fundos para o documento consultado." }))));
17
16
  };
18
17
  export default CCFList;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { Contact } from "./contacts";
3
+ interface ContactLikeDislikeSectionProps extends Omit<Contact & {
4
+ document: string;
5
+ }, "onClickLike" | "onClickDislike"> {
6
+ }
7
+ declare const ContactLikeDislikeSection: React.FC<ContactLikeDislikeSectionProps>;
8
+ export default ContactLikeDislikeSection;
@@ -0,0 +1,61 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import React, { memo, useEffect, useState } from "react";
13
+ import AddItemField from "../common/addItem";
14
+ import ContactsLikeDislike from "./contactsLikeDislike";
15
+ import { useMutation, useQuery } from "../webservice";
16
+ import Loading from "../interface/loading";
17
+ var ContactLikeDislikeSection = function (props) {
18
+ var _a, _b, _c;
19
+ var _d = useState({
20
+ likes: undefined,
21
+ dislikes: undefined,
22
+ likePressed: false,
23
+ dislikePressed: false,
24
+ }), likesDislikes = _d[0], setLikesDislikes = _d[1];
25
+ var isTelefone = props.type === "Telefone";
26
+ var _e = useQuery("SELECT FROM 'ContactsLikesDislikes'.'".concat(isTelefone ? "Phone" : "Email", "'"), (_a = {},
27
+ _a[isTelefone ? "phone" : "email"] = props.value,
28
+ _a.document = props.document,
29
+ _a)), isLoading = _e.isLoading, response = _e.response;
30
+ var mutateLike = useMutation("SELECT FROM 'ContactsLikesDislikes'.'Like".concat(isTelefone ? "Phone" : "Email", "'"), (_b = {},
31
+ _b[isTelefone ? "phone" : "email"] = props.value,
32
+ _b.document = props.document,
33
+ _b)).mutate;
34
+ var mutateDislike = useMutation("SELECT FROM 'ContactsLikesDislikes'.'Dislike".concat(isTelefone ? "Phone" : "Email", "'"), (_c = {},
35
+ _c[isTelefone ? "phone" : "email"] = props.value,
36
+ _c.document = props.document,
37
+ _c)).mutate;
38
+ useEffect(function () {
39
+ if (response === null || response === void 0 ? void 0 : response.document)
40
+ setLikesDislikes(function (prev) {
41
+ var _a, _b;
42
+ return (__assign(__assign({}, prev), { likes: (_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.likes, dislikes: (_b = response === null || response === void 0 ? void 0 : response.document) === null || _b === void 0 ? void 0 : _b.dislikes }));
43
+ });
44
+ }, [response === null || response === void 0 ? void 0 : response.document]);
45
+ var handleLikeDislike = function (mutateFunction, type) {
46
+ var likeOrDislikePressed = likesDislikes[(type + "Pressed")];
47
+ if (!likeOrDislikePressed) {
48
+ mutateFunction();
49
+ setLikesDislikes(function (prev) {
50
+ var _a;
51
+ return (__assign(__assign({}, prev), (_a = {}, _a[type] = (prev[type] || 0) + 1, _a[type + "Pressed"] = true, _a)));
52
+ });
53
+ }
54
+ };
55
+ return isLoading ? (React.createElement(Loading, null)) : (React.createElement(ContactField, __assign({}, props, { likes: likesDislikes === null || likesDislikes === void 0 ? void 0 : likesDislikes.likes, dislikes: likesDislikes === null || likesDislikes === void 0 ? void 0 : likesDislikes.dislikes, onClickLike: function () { return handleLikeDislike(mutateLike, "likes"); }, onClickDislike: function () { return handleLikeDislike(mutateDislike, "dislikes"); } })));
56
+ };
57
+ var ContactField = memo(function (contact) {
58
+ return (React.createElement(AddItemField, { name: contact.type, value: contact.value },
59
+ React.createElement(ContactsLikeDislike, { likes: contact === null || contact === void 0 ? void 0 : contact.likes, dislikes: contact === null || contact === void 0 ? void 0 : contact.dislikes, onClickLike: contact.onClickLike, onClickDislike: contact.onClickDislike })));
60
+ });
61
+ export default ContactLikeDislikeSection;
@@ -1,7 +1,11 @@
1
1
  import React from "react";
2
+ export declare enum ContactType {
3
+ TELEFONE = "Telefone",
4
+ EMAIL = "Email"
5
+ }
2
6
  export type Contact = {
3
- tipo: string;
4
- valor: string;
7
+ type: ContactType;
8
+ value: string;
5
9
  likes?: number;
6
10
  dislikes?: number;
7
11
  onClickLike: () => void;
@@ -7,24 +7,30 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
7
7
  }
8
8
  return to.concat(ar || Array.prototype.slice.call(from));
9
9
  };
10
- import React, { memo, useContext } from "react";
10
+ import React, { useContext } from "react";
11
11
  import { Result } from "../interface/result";
12
- import AddItemField from "../common/addItem";
13
- import ContactsLikeDislike from "./contactsLikeDislike";
14
12
  import { Queries } from "../webservice";
15
13
  import XPathUtils from "../../utils/xpath";
14
+ import { phoneMask } from "../../utils/number";
15
+ import ContactLikeDislikeSection from "./contactLikeDislikeSection";
16
+ export var ContactType;
17
+ (function (ContactType) {
18
+ ContactType["TELEFONE"] = "Telefone";
19
+ ContactType["EMAIL"] = "Email";
20
+ })(ContactType || (ContactType = {}));
16
21
  var Contacts = function (_a) {
17
22
  var onClickConsutarEmail = _a.onClickConsutarEmail;
18
23
  var ctx = useContext(Queries.Finder);
19
24
  var Section = ctx.Section;
20
- return (React.createElement(Section, { ctx: ctx, title: "Contato", subtitle: "Meios De Contato", description: "Telefone, e-mail e outros", onError: function () { return React.createElement(React.Fragment, null, "Erro"); }, onLoading: function () { return React.createElement(React.Fragment, null, "Carregando"); }, onSuccess: function (data) {
21
- var telefones = __spreadArray(__spreadArray([], XPathUtils.select('//telefones/fixos/fixos', data), true), XPathUtils.select('//telefones/moveis/moveis', data), true).map(function (telefone) { return ({ tipo: 'Telefone', valor: XPathUtils.select('string(./telefone)', telefone) }); });
22
- var emails = XPathUtils.select('//emails/emails', data).map(function (email) { return ({ tipo: 'Email', valor: XPathUtils.select('string(./email)', email) }); });
25
+ return (React.createElement(Section, { ctx: ctx, title: "Contato", subtitle: "Meios De Contato", description: "Telefone, e-mail e outros", onSuccess: function (data) {
26
+ var document = XPathUtils.select('string(//cpf|//cnpj)', data);
27
+ var telefones = __spreadArray(__spreadArray([], XPathUtils.select('//telefones/fixos/fixos', data), true), XPathUtils.select('//telefones/moveis/moveis', data), true).map(function (telefone) { return ({ type: 'Telefone', value: phoneMask(XPathUtils.select('string(./telefone)', telefone)) }); });
28
+ var emails = XPathUtils.select('//emails/emails', data).map(function (email) { return ({ type: 'Email', value: XPathUtils.select('string(./email)', email) }); });
23
29
  var contacts = __spreadArray(__spreadArray([], telefones, true), emails, true);
24
30
  var children = (React.createElement(Result, null,
25
- React.createElement(Result, { isContainer: true }, contacts.map(function (_a, key) {
26
- var tipo = _a.tipo, valor = _a.valor;
27
- return (React.createElement(ContactField, { key: key, tipo: tipo, valor: valor, onClickLike: console.log, onClickDislike: console.log }));
31
+ React.createElement(Result, { isContainer: true, contentClassName: "contacts-container" }, contacts.map(function (_a, key) {
32
+ var type = _a.type, value = _a.value;
33
+ return (React.createElement(ContactLikeDislikeSection, { key: key, type: type, value: value, document: document }));
28
34
  }))));
29
35
  return {
30
36
  children: children,
@@ -33,8 +39,4 @@ var Contacts = function (_a) {
33
39
  };
34
40
  } }));
35
41
  };
36
- var ContactField = memo(function (contact) {
37
- return (React.createElement(AddItemField, { name: contact.tipo, value: contact.valor },
38
- React.createElement(ContactsLikeDislike, { likes: contact === null || contact === void 0 ? void 0 : contact.likes, dislikes: contact === null || contact === void 0 ? void 0 : contact.dislikes, onClickLike: contact.onClickLike, onClickDislike: contact.onClickDislike })));
39
- });
40
42
  export default Contacts;
@@ -28,7 +28,7 @@ interface DossieUiProps {
28
28
  [name: string]: {};
29
29
  }[];
30
30
  };
31
- reclameAquiData?: Omit<ReclameAquiCarouselProps, 'nome' | 'cnpj'>[];
31
+ reclameAquiData?: Omit<ReclameAquiCarouselProps, "nome" | "cnpj">[];
32
32
  onOpenNewTransactionModal: () => void;
33
33
  }
34
34
  declare const Dossie: React.FC<DossieUiProps>;
@@ -16,7 +16,7 @@ import { Summary } from "./summary/summary";
16
16
  import { TransactionsTable } from "./transactionTable/transactionTable";
17
17
  import { Carrousel } from "./carrousel/carrousel";
18
18
  import { Result } from "../interface/result";
19
- import { ReclameAquiCarousel } from "../reclameAqui/reclameAquiCarousel";
19
+ import { ReclameAquiCarousel, } from "../reclameAqui/reclameAquiCarousel";
20
20
  import { Queries } from "../webservice";
21
21
  import XPathUtils from "../../utils/xpath";
22
22
  import { formatCnpj, formatCpf } from "../../utils/string";
@@ -24,14 +24,18 @@ var Dossie = function (_a) {
24
24
  var _b = _a.reclameAquiData, reclameAquiData = _b === void 0 ? [] : _b;
25
25
  var ctx = useContext(Queries.Finder);
26
26
  var Section = ctx.Section;
27
- return (React.createElement(Section, { ctx: ctx, hideHeader: true, onError: function () { return React.createElement(React.Fragment, null, "Erro"); }, onLoading: function () { return React.createElement(React.Fragment, null, "Carregando..."); }, onSuccess: function (data) {
28
- var isPF = !!XPathUtils.select('string(//cadastro/cpf)', data);
29
- var name = isPF ? XPathUtils.select('string(//cadastro/nome)', data) : XPathUtils.select('string(//cadastro/razaoSocial)', data);
30
- var document = isPF ? formatCpf(XPathUtils.select('string(//cadastro/cpf)', data)) : formatCnpj(XPathUtils.select('string(//cadastro/cnpj)', data));
27
+ return (React.createElement(Section, { ctx: ctx, hideHeader: true, onSuccess: function (data) {
28
+ var isPF = !!XPathUtils.select("string(//cadastro/cpf)", data);
29
+ var name = isPF
30
+ ? XPathUtils.select("string(//cadastro/nome)", data)
31
+ : XPathUtils.select("string(//cadastro/razaoSocial)", data);
32
+ var document = isPF
33
+ ? formatCpf(XPathUtils.select("string(//cadastro/cpf)", data))
34
+ : formatCnpj(XPathUtils.select("string(//cadastro/cnpj)", data));
31
35
  return (React.createElement(Result, null,
32
36
  React.createElement("div", { className: cn("dossie-grid", "dossie") },
33
37
  reclameAquiData && !isPF ? (React.createElement(ReclameAquiCarousel, { data: reclameAquiData === null || reclameAquiData === void 0 ? void 0 : reclameAquiData.map(function (empresa) { return (__assign(__assign({}, empresa), { nome: name, cnpj: document })); }) })) : (React.createElement(Carrousel, { name: name, document: document })),
34
- React.createElement(TransactionsTable, { events: XPathUtils.select('//historico/consulta', data) })),
38
+ React.createElement(TransactionsTable, { events: XPathUtils.select("//historico/consulta", data) })),
35
39
  React.createElement(Summary, { finderResponse: data })));
36
40
  } }));
37
41
  };
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export default function Loading(): React.JSX.Element;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export default function Loading() {
3
+ return (React.createElement(React.Fragment, null,
4
+ React.createElement("span", { className: "saving" },
5
+ React.createElement("span", null, " ."),
6
+ React.createElement("span", null, "."),
7
+ React.createElement("span", null, "."))));
8
+ }
@@ -35,6 +35,6 @@ var Section = function (_a) {
35
35
  React.createElement(HeaderAction, { iconClass: isOpen ? "minus-square-o" : "plus-square-o", onClick: toggleOpen }),
36
36
  onClose && (React.createElement(HeaderAction, { iconClass: "times-circle", onClick: onClose })),
37
37
  actions) }),
38
- isOpen && React.createElement("div", { className: sectionContentClass }, children)));
38
+ React.createElement("div", { className: sectionContentClass, hidden: !isOpen }, children)));
39
39
  };
40
40
  export default Section;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ declare const PartnerDividasPublicas: ({ documento }: {
3
+ documento: string;
4
+ }) => string | React.JSX.Element;
5
+ export default PartnerDividasPublicas;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import Loading from "../interface/loading";
3
+ import { useQuery } from "../webservice";
4
+ import XPathUtils from '../../utils/xpath';
5
+ var PartnerDividasPublicas = function (_a) {
6
+ var documento = _a.documento;
7
+ var _b = useQuery("SELECT FROM 'DIVIDASUNIAO'.'CONSULTA'", { documento: documento }), isLoading = _b.isLoading, error = _b.error, response = _b.response;
8
+ return isLoading ? React.createElement(Loading, null) : error ? 'Houve um erro ao obter a informação.' : XPathUtils.select('string(//quantidade_dividas)', response === null || response === void 0 ? void 0 : response.document);
9
+ };
10
+ export default PartnerDividasPublicas;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ declare const PartnerProtestos: ({ documento }: {
3
+ documento: string;
4
+ }) => string | React.JSX.Element;
5
+ export default PartnerProtestos;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import Loading from "../interface/loading";
3
+ import { useQuery } from "../webservice";
4
+ import XPathUtils from '../../utils/xpath';
5
+ var PartnerProtestos = function (_a) {
6
+ var documento = _a.documento;
7
+ var _b = useQuery("SELECT FROM 'APICENPROT'.'PRINT'", { documento: documento }), isLoading = _b.isLoading, error = _b.error, response = _b.response;
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
+ };
10
+ export default PartnerProtestos;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ declare const PartnerRFBStatus: ({ documento }: {
3
+ documento: string;
4
+ }) => string | React.JSX.Element;
5
+ export default PartnerRFBStatus;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import Loading from "../interface/loading";
3
+ import { useQuery } from "../webservice";
4
+ import XPathUtils from '../../utils/xpath';
5
+ var PartnerRFBStatus = function (_a) {
6
+ var documento = _a.documento;
7
+ var _b = useQuery("SELECT FROM 'RFB'.'CERTIDAO'", { documento: documento }), isLoading = _b.isLoading, error = _b.error, response = _b.response;
8
+ return isLoading ? React.createElement(Loading, null) : error ? 'Houve um erro ao obter a informação.' : XPathUtils.select('string(//situacao)', response === null || response === void 0 ? void 0 : response.document);
9
+ };
10
+ export default PartnerRFBStatus;
@@ -1,12 +1,12 @@
1
- import React from "react";
1
+ import React, { ReactNode } from "react";
2
2
  export type Partner = {
3
3
  nome: string;
4
4
  cargo?: string;
5
5
  cpf?: string;
6
6
  cnpj?: string;
7
- protestos: number;
8
- receitaStatus: string;
9
- dividasPublicas: number;
7
+ protestos: ReactNode;
8
+ receitaStatus: ReactNode;
9
+ dividasPublicas: ReactNode;
10
10
  onClickCpfCnpj?: (doc?: string) => void;
11
11
  };
12
12
  type PartnerListProps = {
@@ -7,9 +7,9 @@ var PartnerList = memo(function (_a) {
7
7
  return (React.createElement("div", { key: key, className: "content partners-grid" },
8
8
  React.createElement(PartnerField, { name: partner.cnpj ? "Empresa" : (_a = partner.cargo) !== null && _a !== void 0 ? _a : "", value: partner.nome }),
9
9
  React.createElement(PartnerField, { name: partner.cnpj ? "CNPJ" : "CPF", value: (_b = (partner.cnpj || partner.cpf)) !== null && _b !== void 0 ? _b : "", onClick: function () { var _a, _b; return (_a = partner.onClickCpfCnpj) === null || _a === void 0 ? void 0 : _a.call(partner, (_b = (partner.cnpj || partner.cpf)) !== null && _b !== void 0 ? _b : ""); } }),
10
- React.createElement(PartnerField, { name: "Protestos", value: partner.protestos.toString() }),
10
+ React.createElement(PartnerField, { name: "Protestos", value: partner === null || partner === void 0 ? void 0 : partner.protestos }),
11
11
  React.createElement(PartnerField, { name: "Receita Status", value: partner.receitaStatus }),
12
- React.createElement(PartnerField, { name: "Dividas P\u00FAblicas", value: partner.dividasPublicas.toString() })));
12
+ React.createElement(PartnerField, { name: "Dividas P\u00FAblicas", value: partner.dividasPublicas })));
13
13
  })));
14
14
  });
15
15
  export default PartnerList;
@@ -4,10 +4,14 @@ import PartnerList from "./partnerList";
4
4
  import { Queries } from "../webservice";
5
5
  import XPathUtils from "../../utils/xpath";
6
6
  import { formatCnpj, formatCpf, isCnpj } from "../../utils/string";
7
+ import PartnerRFBStatus from "./partner-rfb-status";
8
+ import PartnerProtestos from "./partner-protestos";
9
+ import PartnerDividasPublicas from "./partner-dividas-publicas";
10
+ import ResultWithoutInformation from "../interface/resultWithoutInformation";
7
11
  var Partners = function () {
8
12
  var ctx = useContext(Queries.Finder);
9
13
  var Section = ctx.Section;
10
- return (React.createElement(Section, { ctx: ctx, title: "Quadro Societ\u00E1rio", subtitle: "S\u00F3cios/Empresas A Qual Faz Parte", onLoading: function () { return React.createElement(React.Fragment, null, "Carregando..."); }, onError: function () { return React.createElement(React.Fragment, null, "Erro"); }, onSuccess: function (data) {
14
+ return (React.createElement(Section, { ctx: ctx, title: "Quadro Societ\u00E1rio", subtitle: "S\u00F3cios/Empresas A Qual Faz Parte", onError: function () { return React.createElement(React.Fragment, null, "Erro"); }, onSuccess: function (data) {
11
15
  var partners = XPathUtils.select('//participacoesEmpresas/participacoesEmpresas', data).map(function (partner) {
12
16
  var documento = XPathUtils.select('string(documento)', partner);
13
17
  return {
@@ -15,13 +19,16 @@ var Partners = function () {
15
19
  cpf: (!isCnpj(documento) && formatCpf(documento)) || '',
16
20
  cargo: XPathUtils.select('string(qualificacaoSocio)', partner),
17
21
  cnpj: (isCnpj(documento) && formatCnpj(documento)) || '',
18
- receitaStatus: 'Ativa',
19
- dividasPublicas: 0,
20
- protestos: 0
22
+ receitaStatus: React.createElement(PartnerRFBStatus, { documento: documento }),
23
+ dividasPublicas: React.createElement(PartnerDividasPublicas, { documento: documento }),
24
+ protestos: React.createElement(PartnerProtestos, { documento: documento })
21
25
  };
22
26
  });
23
- return (React.createElement(Result, null,
24
- React.createElement(PartnerList, { partners: partners })));
27
+ var children = (partners === null || partners === void 0 ? void 0 : partners.length) ? (React.createElement(Result, null,
28
+ React.createElement(PartnerList, { partners: partners }))) : React.createElement(ResultWithoutInformation, null);
29
+ return {
30
+ children: children
31
+ };
25
32
  } }));
26
33
  };
27
34
  export default Partners;
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
+ import { EnvolvidoUltimaMovimentacao } from './types';
2
3
  export type Envolvido = {
3
4
  nome: string;
4
5
  envolvimento: string;
5
6
  };
6
7
  declare const EnvolvidosList: React.FC<{
7
- envolvidos: Envolvido[];
8
+ envolvidos: EnvolvidoUltimaMovimentacao[];
8
9
  }>;
9
10
  export default EnvolvidosList;