@credithub/harlan-components 1.33.0 → 1.35.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 (50) hide show
  1. package/dist/components/adresses/addresses.d.ts +2 -2
  2. package/dist/components/adresses/addresses.js +33 -11
  3. package/dist/components/adresses/map.js +1 -1
  4. package/dist/components/bank-accounts/bank-accounts.js +32 -28
  5. package/dist/components/ccf/ccf.js +1 -1
  6. package/dist/components/chart/chartSystem.js +51 -29
  7. package/dist/components/chart/hooks/useChartData.d.ts +6 -0
  8. package/dist/components/chart/hooks/useChartData.js +57 -4
  9. package/dist/components/chart/utils/chartUtils.d.ts +0 -4
  10. package/dist/components/chart/utils/chartUtils.js +0 -16
  11. package/dist/components/consultaRfb.js +0 -1
  12. package/dist/components/consultaSimplesSection/consultaSimplesSection.js +5 -2
  13. package/dist/components/contacts/contacts.js +7 -4
  14. package/dist/components/dividasPublicas/dividasPublicas.js +40 -40
  15. package/dist/components/dominios/dominios.js +6 -6
  16. package/dist/components/dossie/dossie.js +21 -11
  17. package/dist/components/dossie/summary/cardsAndProducts.d.ts +6 -8
  18. package/dist/components/dossie/summary/cardsAndProducts.js +93 -25
  19. package/dist/components/dossie/summary/styles.d.ts +1 -0
  20. package/dist/components/dossie/summary/styles.js +33 -8
  21. package/dist/components/dossie/summary/summary.js +3 -3
  22. package/dist/components/dossie/summary/utils.js +12 -2
  23. package/dist/components/imoveis/imoveisService.js +26 -13
  24. package/dist/components/interface/header.d.ts +7 -3
  25. package/dist/components/interface/header.js +10 -5
  26. package/dist/components/interface/loadingBar.d.ts +1 -0
  27. package/dist/components/interface/loadingBar.js +8 -8
  28. package/dist/components/interface/section.d.ts +2 -0
  29. package/dist/components/interface/section.js +7 -6
  30. package/dist/components/liminar/liminar.js +25 -15
  31. package/dist/components/llama/llama.d.ts +6 -0
  32. package/dist/components/llama/llama.js +122 -0
  33. package/dist/components/partners/partnerList.js +1 -1
  34. package/dist/components/partners/partners.js +27 -7
  35. package/dist/components/pep/pep.js +13 -6
  36. package/dist/components/processos-juridicos/processosJuridicos.js +19 -13
  37. package/dist/components/protestos/protestos.js +53 -38
  38. package/dist/components/refinBoaVista/refinBoaVista.js +31 -15
  39. package/dist/components/refinSerasa/refinSerasa.js +25 -38
  40. package/dist/components/score/scoreService.js +27 -13
  41. package/dist/components/scr/scr.js +123 -59
  42. package/dist/components/section.d.ts +3 -0
  43. package/dist/components/section.js +93 -0
  44. package/dist/components/veiculos/veiculos.js +28 -12
  45. package/dist/components/webservice.d.ts +24 -29
  46. package/dist/components/webservice.js +152 -130
  47. package/dist/consultaSimples.js +2 -2
  48. package/lib/cjs/index.js +1309 -829
  49. package/lib/esm/index.js +1310 -830
  50. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- interface Addresses {
2
+ interface AddressesProps {
3
3
  apiKey: string;
4
4
  rfbResponse?: Document;
5
5
  }
6
- declare const Addresses: React.FC<Addresses>;
6
+ declare const Addresses: React.FC<AddressesProps>;
7
7
  export default Addresses;
@@ -22,17 +22,46 @@ import EnderecoIcon from '../../assets/icones/endereco';
22
22
  import { useGlobalData } from '../../contexts/globalDataContext';
23
23
  import { useConsultaRfb } from '../../hooks/useConsultaRfb';
24
24
  import XPathUtils from '../../utils/xpath';
25
- import React, { useContext, useState } from 'react';
25
+ import React, { useContext, useEffect, useState } from 'react';
26
26
  import { uniq } from 'underscore';
27
27
  import AddItemField from '../common/addItem';
28
28
  import { Result, ResultContent } from '../interface/result';
29
- import { Queries } from '../webservice';
29
+ import { Section } from '../section';
30
+ import { Queries, RequestStatus } from '../webservice';
30
31
  var Addresses = function () {
31
32
  var ctx = useContext(Queries.Finder);
32
- var Section = ctx.Section;
33
- var rfbResponse = useConsultaRfb().rfbResponse;
34
33
  var setData = useGlobalData().setData;
34
+ var rfbResponse = useConsultaRfb().rfbResponse;
35
35
  var _a = useState(false), dataUpdated = _a[0], setDataUpdated = _a[1];
36
+ useEffect(function () {
37
+ if (ctx.type === RequestStatus.Success && !dataUpdated && ctx.document) {
38
+ var data = ctx.document;
39
+ var _addresses = __spreadArray(__spreadArray([], ((data &&
40
+ XPathUtils.select('//enderecos/enderecos', data)) ||
41
+ []), true), ((!data &&
42
+ rfbResponse &&
43
+ XPathUtils.select('//RFB/enderecos/endereco', rfbResponse)) ||
44
+ []), true);
45
+ var addresses = uniq(_addresses.map(function (address) { return ({
46
+ type: XPathUtils.select('string(tipoLogradouro)', address),
47
+ address: XPathUtils.select('string(logradouro)', address),
48
+ number: XPathUtils.select('string(numero)', address),
49
+ zipcode: XPathUtils.select('string(cep)', address),
50
+ district: XPathUtils.select('string(bairro)', address),
51
+ city: XPathUtils.select('string(cidade)', address),
52
+ state: XPathUtils.select('string(uf)', address),
53
+ urlImage: '',
54
+ urlMaps: ''
55
+ }); }), function (e) { return e.address + e.district; });
56
+ if (addresses.length > 0) {
57
+ var addressState_1 = {
58
+ addresses: addresses
59
+ };
60
+ setData(function (prevState) { return (__assign(__assign({}, prevState), { addresses: addressState_1 })); });
61
+ setDataUpdated(true);
62
+ }
63
+ }
64
+ }, [ctx, rfbResponse, dataUpdated, setData]);
36
65
  var response = function (data) {
37
66
  var _addresses = __spreadArray(__spreadArray([], ((data && XPathUtils.select('//enderecos/enderecos', data)) ||
38
67
  []), true), ((!data &&
@@ -50,13 +79,6 @@ var Addresses = function () {
50
79
  urlImage: '',
51
80
  urlMaps: ''
52
81
  }); }), function (e) { return e.address + e.district; });
53
- if (!dataUpdated && addresses.length > 0) {
54
- var addressState_1 = {
55
- addresses: addresses
56
- };
57
- setData(function (prevState) { return (__assign(__assign({}, prevState), { addresses: addressState_1 })); });
58
- setDataUpdated(true);
59
- }
60
82
  return (React.createElement(Result, { resultContentStriped: true, className: "address" }, addresses === null || addresses === void 0 ? void 0 : addresses.map(function (address, index) { return (React.createElement(ResultContent, { desktop: "repeat(7, 1fr)", tablet: "repeat(4, 1fr)", mobile: "repeat(2, 1fr)", key: index },
61
83
  React.createElement(AddItemField, { name: "Tipo", value: address.type, style: { display: 'inline-block' } }),
62
84
  React.createElement(AddItemField, { name: "Endere\u00E7o", value: address.address, style: { display: 'inline-block' } }),
@@ -1,5 +1,5 @@
1
- import React, { useEffect, useState } from 'react';
2
1
  import { GoogleMap, LoadScript, Marker } from '@react-google-maps/api';
2
+ import React, { useEffect, useState } from 'react';
3
3
  import { getGeocode } from './getGeocode';
4
4
  var MapContainer = function (_a) {
5
5
  var address = _a.address, apiKey = _a.apiKey;
@@ -12,15 +12,15 @@ var __assign = (this && this.__assign) || function () {
12
12
  import ContasBancariasIcon from '../../assets/icones/contasBancarias';
13
13
  import { useGlobalData } from '../../contexts/globalDataContext';
14
14
  import XPathUtils from '../../utils/xpath';
15
- import React, { useContext, useState } from 'react';
15
+ import React, { useContext, useEffect, useState } from 'react';
16
16
  import { useTheme } from 'styled-components';
17
17
  import AddItemField from '../common/addItem';
18
18
  import { Result, ResultContent } from '../interface/result';
19
19
  import StatusMessage from '../interface/statusMessage';
20
- import { Queries } from '../webservice';
20
+ import { Section } from '../section';
21
+ import { Queries, RequestStatus } from '../webservice';
21
22
  var BankAccounts = function () {
22
23
  var ctx = useContext(Queries.Finder);
23
- var Section = ctx.Section;
24
24
  var setData = useGlobalData().setData;
25
25
  var _a = useState(false), dataUpdated = _a[0], setDataUpdated = _a[1];
26
26
  var theme = useTheme();
@@ -32,32 +32,36 @@ var BankAccounts = function () {
32
32
  conta: XPathUtils.select('string(conta)', account)
33
33
  }); });
34
34
  };
35
- return (React.createElement(Section, { title: 'Informações de Contas Bancárias', subtitle: 'Vejas as informações disponíveis de contas bancárias.', icon: ContasBancariasIcon, ctx: ctx, minimized: false, onSuccess: function (data) {
36
- var accounts = extractBankAccountData(data);
37
- var message = (accounts === null || accounts === void 0 ? void 0 : accounts.length)
38
- ? (accounts === null || accounts === void 0 ? void 0 : accounts.length) > 1
39
- ? "Encontrada ".concat(accounts === null || accounts === void 0 ? void 0 : accounts.length, " contas banc\u00E1rias")
40
- : 'Encontrada 1 conta bancária'
41
- : 'Não foram encontradas ocorrências';
42
- if (!dataUpdated) {
43
- if (accounts.length > 0) {
44
- var bankAccountsData_1 = {
45
- bankAccounts: accounts
46
- };
47
- setData(function (prevState) { return (__assign(__assign({}, prevState), { bankAccountsData: bankAccountsData_1 })); });
48
- }
35
+ useEffect(function () {
36
+ if (ctx.type === RequestStatus.Success && !dataUpdated && ctx.document) {
37
+ var accounts = extractBankAccountData(ctx.document);
38
+ if (accounts.length > 0) {
39
+ var bankAccountsData_1 = {
40
+ bankAccounts: accounts
41
+ };
42
+ setData(function (prevState) { return (__assign(__assign({}, prevState), { bankAccounts: bankAccountsData_1 })); });
49
43
  setDataUpdated(true);
50
44
  }
51
- return {
52
- children: accounts.length ? (React.createElement(Result, null, accounts.map(function (account, key) { return (React.createElement(ResultContent, { key: key },
53
- React.createElement(AddItemField, { name: "Banco", value: account.banco }),
54
- React.createElement(AddItemField, { name: "Ag\u00EAncia", value: account.agencia }),
55
- React.createElement(AddItemField, { name: "Conta", value: account.conta }))); }))) : null,
56
- description: React.createElement(StatusMessage, null, message),
57
- iconProps: {
58
- circleFill: (accounts === null || accounts === void 0 ? void 0 : accounts.length) ? theme.colors.erro : ''
59
- }
60
- };
61
- } }));
45
+ }
46
+ }, [ctx, dataUpdated, setData]);
47
+ var response = function (data) {
48
+ var accounts = extractBankAccountData(data);
49
+ var message = (accounts === null || accounts === void 0 ? void 0 : accounts.length)
50
+ ? (accounts === null || accounts === void 0 ? void 0 : accounts.length) > 1
51
+ ? "Encontrada ".concat(accounts === null || accounts === void 0 ? void 0 : accounts.length, " contas banc\u00E1rias")
52
+ : 'Encontrada 1 conta bancária'
53
+ : 'Não foram encontradas ocorrências';
54
+ return {
55
+ children: accounts.length ? (React.createElement(Result, null, accounts.map(function (account, key) { return (React.createElement(ResultContent, { key: key },
56
+ React.createElement(AddItemField, { name: "Banco", value: account.banco }),
57
+ React.createElement(AddItemField, { name: "Ag\u00EAncia", value: account.agencia }),
58
+ React.createElement(AddItemField, { name: "Conta", value: account.conta }))); }))) : null,
59
+ description: React.createElement(StatusMessage, null, message),
60
+ iconProps: {
61
+ circleFill: (accounts === null || accounts === void 0 ? void 0 : accounts.length) ? theme.colors.erro : ''
62
+ }
63
+ };
64
+ };
65
+ return (React.createElement(Section, { title: 'Informações de Contas Bancárias', subtitle: 'Vejas as informações disponíveis de contas bancárias.', icon: ContasBancariasIcon, ctx: ctx, minimized: false, onSuccess: response }));
62
66
  };
63
67
  export default BankAccounts;
@@ -15,11 +15,11 @@ import XPathUtils from '../../utils/xpath';
15
15
  import React, { useCallback, useContext, useState } from 'react';
16
16
  import { Result } from '../interface/result';
17
17
  import StatusMessage from '../interface/statusMessage';
18
+ import { Section } from '../section';
18
19
  import { Queries } from '../webservice';
19
20
  import CCFList from './ccfList';
20
21
  var CCF = function () {
21
22
  var ctx = useContext(Queries.CCF);
22
- var Section = ctx.Section;
23
23
  var setData = useGlobalData().setData;
24
24
  var _a = useState(false), dataUpdated = _a[0], setDataUpdated = _a[1];
25
25
  var mapNodeToCCFData = useCallback(function (node) { return ({
@@ -2,36 +2,33 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
2
2
  if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
3
  return cooked;
4
4
  };
5
- import React, { useContext, useEffect } from 'react';
6
- import { useUltimaOcorrenciaCCF, useCalculation, useDividasPublicas } from './utils/chartUtils';
7
- import Header from '../interface/header';
8
- import StatusMessage from '../interface/statusMessage';
9
- import useToggle from '../../hooks/useToggle';
10
- import styled from 'styled-components';
11
- import QuantidadeResultados from './quantityResult';
12
- import ChartContent from './chartContent';
13
- import BtnWrapper from '../../assets/btn/btnWrapper';
14
- import ChevronUp from '../../assets/btn/chevronUp';
15
- import ChevronDown from '../../assets/btn/chevronDown';
16
- import useChartData from './hooks/useChartData';
17
5
  import ResumoDeNegativacoesIcon from '../../assets/icones/resumoNegativacoes';
18
- import { ConsultasComplementaresContext } from '../consultasComplementares';
19
6
  import { converterParaFormatoValido } from '../../utils/date';
20
- import { PrintSectionWrapper } from '../common/printSectionWrapper';
7
+ import React, { useCallback, useContext, useEffect } from 'react';
8
+ import styled from 'styled-components';
9
+ import useToggle from '../../hooks/useToggle';
10
+ import { ConsultasComplementaresContext } from '../consultasComplementares';
11
+ import StatusMessage from '../interface/statusMessage';
12
+ import { Section } from '../section';
13
+ import { RequestStatus } from '../webservice';
14
+ import ChartContent from './chartContent';
15
+ import useChartData, { useDividasPublicas } from './hooks/useChartData';
16
+ import QuantidadeResultados from './quantityResult';
17
+ import { useCalculation, useUltimaOcorrenciaCCF } from './utils/chartUtils';
21
18
  var Content = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: ", ";\n padding: 0px 30px;\n\n @media print {\n display: block;\n }\n"], ["\n display: ", ";\n padding: 0px 30px;\n\n @media print {\n display: block;\n }\n"])), function (props) { return (props.isOpen ? 'block' : 'none'); });
22
19
  var ChartSystem = function (_a) {
23
- var _b, _c, _d, _e, _f, _g, _h, _j, _k;
20
+ var _b, _c, _d, _e, _f, _g, _h, _j;
24
21
  var documento = _a.documento;
25
- var _l = useChartData(documento), data = _l.data, isLoading = _l.isLoading, error = _l.error, refetch = _l.refetch;
22
+ var _k = useChartData(documento), data = _k.data, isLoading = _k.isLoading, error = _k.error, refetch = _k.refetch, chartDataProgress = _k.loadingProgress;
23
+ var _l = useDividasPublicas(), quantidadeDividas = _l.quantidade, valorTotalDividas = _l.valorTotal, dividasProgress = _l.loadingProgress;
26
24
  var ctxConsultasComplementares = useContext(ConsultasComplementaresContext);
27
- var errorMessage = typeof error === 'string' ? error : error === null || error === void 0 ? void 0 : error.toString();
28
- var _m = useToggle(true), isOpen = _m[0], toggleOpen = _m[1];
25
+ var errorMessage = typeof error === 'string' ? new Error(error) : error;
26
+ var isOpen = useToggle(true)[0];
29
27
  var ultimaOcorrenciaCCF = useUltimaOcorrenciaCCF();
30
28
  var quantidadeProtestos = ((_c = (_b = data === null || data === void 0 ? void 0 : data.protestos) === null || _b === void 0 ? void 0 : _b[(data === null || data === void 0 ? void 0 : data.protestos.length) - 1]) === null || _c === void 0 ? void 0 : _c.quantidade) || 0;
31
29
  var valorTotalProtestos = ((_e = (_d = data === null || data === void 0 ? void 0 : data.protestos) === null || _d === void 0 ? void 0 : _d[(data === null || data === void 0 ? void 0 : data.protestos.length) - 1]) === null || _e === void 0 ? void 0 : _e.valorTotal) || 0;
32
- var _o = useDividasPublicas(), quantidadeDividas = _o.quantidade, valorTotalDividas = _o.valorTotal;
33
- var _p = useCalculation((data === null || data === void 0 ? void 0 : data.serasa) || []), quantidadeSerasa = _p.quantidade, valorTotalSerasa = _p.valorTotal;
34
- var _q = useCalculation((data === null || data === void 0 ? void 0 : data.boaVista) || []), quantidadeBoaVista = _q.quantidade, valorTotalBoaVista = _q.valorTotal;
30
+ var _m = useCalculation((data === null || data === void 0 ? void 0 : data.serasa) || []), quantidadeSerasa = _m.quantidade, valorTotalSerasa = _m.valorTotal;
31
+ var _o = useCalculation((data === null || data === void 0 ? void 0 : data.boaVista) || []), quantidadeBoaVista = _o.quantidade, valorTotalBoaVista = _o.valorTotal;
35
32
  var quantidadeCCFs = useCalculation((data === null || data === void 0 ? void 0 : data.ccfs) || []).quantidade;
36
33
  var ultimaOcorrenciaProtestos = '';
37
34
  if ((data === null || data === void 0 ? void 0 : data.protestosCategory) && data.protestosCategory.length > 0) {
@@ -48,15 +45,40 @@ var ChartSystem = function (_a) {
48
45
  }
49
46
  var consultaPefinBoaVista = (_g = (_f = ctxConsultasComplementares === null || ctxConsultasComplementares === void 0 ? void 0 : ctxConsultasComplementares.consultasComplementares) === null || _f === void 0 ? void 0 : _f.refinBoaVista) === null || _g === void 0 ? void 0 : _g.data;
50
47
  var consultaPefinSerasa = (_j = (_h = ctxConsultasComplementares === null || ctxConsultasComplementares === void 0 ? void 0 : ctxConsultasComplementares.consultasComplementares) === null || _h === void 0 ? void 0 : _h.refinSerasa) === null || _j === void 0 ? void 0 : _j.data;
51
- useEffect(function () {
52
- if (consultaPefinBoaVista || consultaPefinSerasa)
48
+ var handleRefetch = useCallback(function () {
49
+ if ((consultaPefinBoaVista || consultaPefinSerasa) && !isLoading) {
53
50
  refetch();
54
- }, [consultaPefinBoaVista, consultaPefinSerasa, refetch]);
55
- return (React.createElement(PrintSectionWrapper, null,
56
- React.createElement(Header, { title: "Resumo de Negativa\u00E7\u00F5es", subtitle: "Veja a quantidade de ocorr\u00EAncias conforme o documento foi consultado ao longo do tempo", description: errorMessage && (React.createElement(StatusMessage, { type: "error" }, errorMessage)), variant: isLoading ? 'loading' : 'default', icon: ResumoDeNegativacoesIcon, actions: React.createElement(BtnWrapper, { onClick: toggleOpen }, isOpen ? React.createElement(ChevronUp, null) : React.createElement(ChevronDown, null)) }),
57
- React.createElement(Content, { isOpen: isOpen },
58
- data && React.createElement(ChartContent, { dataInput: data }),
59
- !isLoading && (React.createElement(QuantidadeResultados, { data: data, quantidadeProtestos: quantidadeProtestos, quantidadeProcessos: (_k = data === null || data === void 0 ? void 0 : data.pieChartTotalConfig) === null || _k === void 0 ? void 0 : _k.processosJuridicos, quantidadeDividas: quantidadeDividas, quantidadeDividasSerasa: quantidadeSerasa, quantidadeDividasBoaVista: quantidadeBoaVista, quantidadeChequesSemFundos: quantidadeCCFs, ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF, valorTotalDividasSerasa: valorTotalSerasa, valorTotalDividasBoaVista: valorTotalBoaVista, valorTotalProtestos: valorTotalProtestos, valorTotalDividas: valorTotalDividas, ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos })))));
51
+ }
52
+ }, [consultaPefinBoaVista, consultaPefinSerasa, refetch, isLoading]);
53
+ useEffect(function () {
54
+ handleRefetch();
55
+ }, [handleRefetch]);
56
+ var loadingProgress = (chartDataProgress + dividasProgress) / 2;
57
+ return (React.createElement(Section, { ctx: {
58
+ response: undefined,
59
+ type: isLoading
60
+ ? RequestStatus.Loading
61
+ : error
62
+ ? RequestStatus.Error
63
+ : RequestStatus.Success,
64
+ error: errorMessage || null,
65
+ refetch: refetch,
66
+ document: data,
67
+ progress: loadingProgress,
68
+ Section: Section
69
+ }, title: "Resumo de Negativa\u00E7\u00F5es", subtitle: "Veja a quantidade de ocorr\u00EAncias conforme o documento foi consultado ao longo do tempo", icon: ResumoDeNegativacoesIcon, onSuccess: function () {
70
+ var _a;
71
+ return (React.createElement(React.Fragment, null,
72
+ React.createElement(Content, { isOpen: isOpen },
73
+ data && React.createElement(ChartContent, { dataInput: data }),
74
+ React.createElement(QuantidadeResultados, { data: data, quantidadeProtestos: quantidadeProtestos, quantidadeProcessos: (_a = data === null || data === void 0 ? void 0 : data.pieChartTotalConfig) === null || _a === void 0 ? void 0 : _a.processosJuridicos, quantidadeDividas: quantidadeDividas, quantidadeDividasSerasa: quantidadeSerasa, quantidadeDividasBoaVista: quantidadeBoaVista, quantidadeChequesSemFundos: quantidadeCCFs, ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF, valorTotalDividasSerasa: valorTotalSerasa, valorTotalDividasBoaVista: valorTotalBoaVista, valorTotalProtestos: valorTotalProtestos, valorTotalDividas: valorTotalDividas, ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos }))));
75
+ }, isError: function (err) { return ({
76
+ children: React.createElement(React.Fragment, null),
77
+ description: (React.createElement(StatusMessage, { type: "error" },
78
+ "Erro ao realizar a an\u00E1lise: ",
79
+ err.message)),
80
+ variant: 'error'
81
+ }); } }));
60
82
  };
61
83
  export default ChartSystem;
62
84
  var templateObject_1;
@@ -1,8 +1,14 @@
1
1
  import { DataInput } from '../../../components/chart/types/iChart';
2
+ export declare const useDividasPublicas: () => {
3
+ loadingProgress: number;
4
+ quantidade: number;
5
+ valorTotal: number;
6
+ };
2
7
  declare const useChartData: (documento: string) => {
3
8
  data: DataInput | null;
4
9
  isLoading: boolean;
5
10
  error: string | Error | null;
6
11
  refetch: () => void;
12
+ loadingProgress: number;
7
13
  };
8
14
  export default useChartData;
@@ -1,12 +1,51 @@
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
+ };
1
12
  import { Queries, RequestStatus, useQuery } from '../../../components/webservice';
13
+ import XPathUtils from '../../../utils/xpath';
2
14
  import { useContext, useEffect, useMemo, useState } from 'react';
3
15
  import { processData, processProtestData } from '../utils/dataProcessing';
16
+ export var useDividasPublicas = function () {
17
+ var ctxFinder = useContext(Queries.Finder);
18
+ var _a = useState(0), loadingProgress = _a[0], setLoadingProgress = _a[1]; // Add loading progress state
19
+ useEffect(function () {
20
+ if ((ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.type) === RequestStatus.Loading) {
21
+ setLoadingProgress(function (prev) { return Math.min(prev + 15, 90); }); // Simulate progress
22
+ }
23
+ else if ((ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.type) === RequestStatus.Success ||
24
+ (ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.type) === RequestStatus.Error) {
25
+ setLoadingProgress(100); // Set progress to complete
26
+ }
27
+ }, [ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.type]);
28
+ var dividasPublicasData = useMemo(function () {
29
+ if ((ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.type) === RequestStatus.Success) {
30
+ return {
31
+ quantidade: XPathUtils.select('number(//dividas/resumo/quantidade_dividas)', ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.document) || 0,
32
+ valorTotal: XPathUtils.select('number(//dividas/resumo/valor_total_dividas)', ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.document) || 0
33
+ };
34
+ }
35
+ return {
36
+ quantidade: 0,
37
+ valorTotal: 0
38
+ };
39
+ }, [ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.type]);
40
+ return __assign(__assign({}, dividasPublicasData), { loadingProgress: loadingProgress });
41
+ };
4
42
  var useChartData = function (documento) {
5
43
  var _a = useState(null), data = _a[0], setData = _a[1];
6
44
  var _b = useState(null), errorState = _b[0], setErrorState = _b[1];
7
- var _c = useQuery("SELECT FROM 'DOCUMENTHISTORY'.'BASICHISTORY'", {
45
+ var _c = useState(0), loadingProgress = _c[0], setLoadingProgress = _c[1]; // Add loading progress state
46
+ var _d = useQuery("SELECT FROM 'DOCUMENTHISTORY'.'BASICHISTORY'", {
8
47
  documento: documento
9
- }), response = _c.response, queryError = _c.error, isLoading = _c.isLoading, refetch = _c.refetch;
48
+ }), response = _d.response, queryError = _d.error, isLoading = _d.isLoading, refetch = _d.refetch;
10
49
  var ctxProtestos = useContext(Queries.Protestos);
11
50
  var ctxCCF = useContext(Queries.CCF);
12
51
  var ctxProcessosJuridicos = useContext(Queries.ProcessosJuridicos);
@@ -26,7 +65,7 @@ var useChartData = function (documento) {
26
65
  ].every(function (status) { return status !== RequestStatus.Loading; });
27
66
  }, [ctxProtestos, ctxCCF, ctxProcessosJuridicos]);
28
67
  var dadosProtestos = useMemo(function () {
29
- if ((ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.type) === RequestStatus.Success && ctxProtestos.data) {
68
+ if ((ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.type) === RequestStatus.Success && ctxProtestos.document) {
30
69
  return processProtestData(ctxProtestos.document);
31
70
  }
32
71
  return [];
@@ -36,6 +75,14 @@ var useChartData = function (documento) {
36
75
  refetch();
37
76
  }
38
77
  }, [liveQueriesIsFinish, refetch]);
78
+ useEffect(function () {
79
+ if (isLoading) {
80
+ setLoadingProgress(function (prev) { return Math.min(prev + 15, 90); }); // Simulate loading progress
81
+ }
82
+ else if (!isLoading && (queryError || response)) {
83
+ setLoadingProgress(100); // Set progress to complete
84
+ }
85
+ }, [isLoading, queryError, response]);
39
86
  useEffect(function () {
40
87
  if (!isLoading &&
41
88
  !queryError &&
@@ -60,6 +107,12 @@ var useChartData = function (documento) {
60
107
  quantidadeProcessosJuridicos,
61
108
  dadosProtestos
62
109
  ]);
63
- return { data: data, isLoading: isLoading, error: errorState || queryError, refetch: refetch };
110
+ return {
111
+ data: data,
112
+ isLoading: isLoading,
113
+ error: errorState || queryError,
114
+ refetch: refetch,
115
+ loadingProgress: loadingProgress
116
+ };
64
117
  };
65
118
  export default useChartData;
@@ -5,7 +5,3 @@ export declare const useCalculation: (itens: ItemCalculo[]) => {
5
5
  dataMaisRecente: string;
6
6
  };
7
7
  export declare const useUltimaOcorrenciaCCF: () => string | undefined;
8
- export declare const useDividasPublicas: () => {
9
- quantidade: number;
10
- valorTotal: number;
11
- };
@@ -20,19 +20,3 @@ export var useUltimaOcorrenciaCCF = function () {
20
20
  }, [ctxCCF === null || ctxCCF === void 0 ? void 0 : ctxCCF.type]);
21
21
  return ultimaOcorrenciaCCF;
22
22
  };
23
- export var useDividasPublicas = function () {
24
- var ctxFinder = useContext(Queries.Finder);
25
- var dividasPublicasData = useMemo(function () {
26
- if ((ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.type) === RequestStatus.Success) {
27
- return {
28
- quantidade: XPathUtils.select('number(//dividas/resumo/quantidade_dividas)', ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.document) || 0,
29
- valorTotal: XPathUtils.select('number(//dividas/resumo/valor_total_dividas)', ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.document) || 0
30
- };
31
- }
32
- return {
33
- quantidade: 0,
34
- valorTotal: 0
35
- };
36
- }, [ctxFinder === null || ctxFinder === void 0 ? void 0 : ctxFinder.type]);
37
- return dividasPublicasData;
38
- };
@@ -14,7 +14,6 @@ export var ConsultaRfbProvider = function (_a) {
14
14
  queryFallback.refetch();
15
15
  }
16
16
  }, [enableFallback]);
17
- console.log('query.isLoading', query.isLoading);
18
17
  return (React.createElement(ConsultaRfbContext.Provider, { value: {
19
18
  rfbResponse: (_e = (_c = (_b = queryFallback === null || queryFallback === void 0 ? void 0 : queryFallback.response) === null || _b === void 0 ? void 0 : _b.document) !== null && _c !== void 0 ? _c : (_d = query === null || query === void 0 ? void 0 : query.response) === null || _d === void 0 ? void 0 : _d.document) !== null && _e !== void 0 ? _e : undefined,
20
19
  executeFallback: executeFallback,
@@ -76,7 +76,10 @@ var ConsultaSimplesSection = function (_a) {
76
76
  return (React.createElement(Section, __assign({ title: "Consulta Simples", subtitle: "Consulta de informa\u00E7\u00F5es do documento.", description: React.createElement(React.Fragment, null,
77
77
  React.createElement(StatusMessage, null, format(new Date(), "dd/MM/yyyy 'às' HH:mm")),
78
78
  React.createElement(StatusMessage, { type: "found" }, formatDocument(documento)),
79
- isError && (React.createElement(StatusMessage, { type: statusType }, ctx === null || ctx === void 0 ? void 0 : ctx.error.message)),
80
- possuiPendenciaText.length ? (possuiPendenciaText.map(function (text) { return (React.createElement(StatusMessage, { key: text, type: "error" }, text)); })) : (React.createElement(StatusMessage, { type: statusType }, "Nenhum registro encontrado"))), onClose: onClose, icon: ConsultaSimplesIcon, variant: isLoading ? 'loading' : 'default' }, rest), children));
79
+ isError && (ctx === null || ctx === void 0 ? void 0 : ctx.error) && (React.createElement(StatusMessage, { type: statusType }, ctx.error.message)),
80
+ possuiPendenciaText.length ? (possuiPendenciaText.map(function (text) { return (React.createElement(StatusMessage, { key: text, type: "error" }, text)); })) : (React.createElement(StatusMessage, { type: statusType }, "Nenhum registro encontrado"))), onClose: onClose, icon: ConsultaSimplesIcon, variant: isLoading ? 'loading' : 'default', ctx: ctx, loadingProps: {
81
+ percentage: (ctx === null || ctx === void 0 ? void 0 : ctx.progress) || 0,
82
+ hidden: !isLoading
83
+ } }, rest), children));
81
84
  };
82
85
  export default ConsultaSimplesSection;
@@ -27,10 +27,11 @@ import { useGlobalData } from '../../contexts/globalDataContext';
27
27
  import { useConsultaRfb } from '../../hooks/useConsultaRfb';
28
28
  import { phoneMask } from '../../utils/number';
29
29
  import XPathUtils from '../../utils/xpath';
30
- import React, { useContext, useEffect } from 'react';
30
+ import React, { useCallback, useContext, useEffect } from 'react';
31
31
  import styled from 'styled-components';
32
32
  import Button from '../common/button';
33
33
  import { Result, ResultContent } from '../interface/result';
34
+ import { Section } from '../section';
34
35
  import { Queries, RequestStatus } from '../webservice';
35
36
  import ContactLikeDislikeSection from './contactLikeDislikeSection';
36
37
  export var ContactType;
@@ -43,9 +44,8 @@ var Contacts = function (_a) {
43
44
  var onClickConsultarEmail = _a.onClickConsultarEmail;
44
45
  var ctx = useContext(Queries.Finder);
45
46
  var rfbResponse = useConsultaRfb().rfbResponse;
46
- var Section = ctx.Section;
47
47
  var setData = useGlobalData().setData;
48
- useEffect(function () {
48
+ var updateData = useCallback(function () {
49
49
  if (ctx.type === RequestStatus.Success && ctx.document) {
50
50
  var telefones = XPathUtils.selectArray('//telefones/*/*', ctx.document).map(function (telefone) { return ({
51
51
  type: ContactType.TELEFONE,
@@ -62,7 +62,10 @@ var Contacts = function (_a) {
62
62
  setData(function (prevState) { return (__assign(__assign({}, prevState), { contacts: contactState_1.contacts })); });
63
63
  }
64
64
  }
65
- }, [ctx.type]);
65
+ }, [ctx.type, ctx.document]);
66
+ useEffect(function () {
67
+ updateData();
68
+ }, [updateData]);
66
69
  return (React.createElement(Section, { ctx: ctx, title: "Contato", subtitle: "Informa\u00E7\u00F5es de contato do documento pesquisado.", description: "(Telefone, e-mail e outros)", minimized: false, icon: ContatoIcon, onSuccess: function (data) {
67
70
  var _a;
68
71
  var document = XPathUtils.select('string(//cpf|//cnpj)', data);
@@ -11,56 +11,56 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import DividasVencidasSerasaIcon from '../../assets/icones/dividasVencidasSerasa';
13
13
  import { useGlobalData } from '../../contexts/globalDataContext';
14
- import { parseDate } from '../../utils/date';
15
14
  import { formatMoney } from '../../utils/number';
16
15
  import XPathUtils from '../../utils/xpath';
17
- import React, { useContext, useState } from 'react';
16
+ import React, { useContext, useEffect, useState } from 'react';
18
17
  import { Result } from '../interface/result';
19
18
  import StatusMessage from '../interface/statusMessage';
20
- import { Queries } from '../webservice';
19
+ import { Section } from '../section';
20
+ import { Queries, RequestStatus } from '../webservice';
21
21
  import DividasPublicasList from './dividasPublicasList';
22
+ var dividaTypes = [
23
+ { type: 'FGTS', path: '//dividas/fgts/divida' },
24
+ { type: 'Previdenciária', path: '//dividas/previdenciaria/divida' },
25
+ { type: 'Dívida Ativa União', path: '//dividas/ativa-geral/divida' }
26
+ ];
27
+ var parseDividas = function (document) {
28
+ return dividaTypes.flatMap(function (_a) {
29
+ var type = _a.type, path = _a.path;
30
+ var dividasArray = XPathUtils.selectArray(path, document);
31
+ return dividasArray.map(function (divida) { return ({
32
+ nomeDoDevedor: XPathUtils.select('string(./nome_devedor)', divida),
33
+ tipoDePessoa: XPathUtils.select('string(./tipo_pessoa)', divida),
34
+ tipoDeDevedor: XPathUtils.select('string(./tipo_devedor)', divida),
35
+ unidadeResponsavel: XPathUtils.select('string(./unidade_responsavel)', divida),
36
+ uFDaUnidadeResponsavel: XPathUtils.select('string(./uf_unidade_responsavel)', divida),
37
+ numeroDeInscricaoDaDivida: XPathUtils.select('string(./numero_inscricao)', divida),
38
+ tipoDaSituacaoDaInscricao: XPathUtils.select('string(./tipo_situacao_inscricao)', divida),
39
+ situacaoDaInscricao: XPathUtils.select('string(./situacao_inscricao)', divida),
40
+ dataDeInscricao: XPathUtils.select('string(./data_inscricao)', divida),
41
+ indicadorAjuizado: XPathUtils.select('string(./indicador_ajuizado)', divida),
42
+ valorConsolidado: formatMoney(XPathUtils.select('string(./valor_consolidado)', divida)),
43
+ tipoDeDivida: type
44
+ }); });
45
+ });
46
+ };
22
47
  var DividasPublicas = function () {
23
48
  var ctx = useContext(Queries.Finder);
24
- var Section = ctx.Section;
25
49
  var setData = useGlobalData().setData;
26
50
  var _a = useState(false), dataUpdated = _a[0], setDataUpdated = _a[1];
27
- var dividaTypes = [
28
- { type: 'FGTS', path: '//dividas/fgts/divida' },
29
- { type: 'Previdenciária', path: '//dividas/previdenciaria/divida' },
30
- { type: 'Dívida Ativa União', path: '//dividas/ativa-geral/divida' }
31
- ];
32
- return (React.createElement(Section, { title: "D\u00EDvidas P\u00FAblicas", icon: DividasVencidasSerasaIcon, subtitle: "Veja as d\u00EDvidas p\u00FAblicas com a Uni\u00E3o (ativa, FGTS e previdenci\u00E1ria).", onSuccess: function (document) {
33
- var parseDividas = function (document) {
34
- return dividaTypes.flatMap(function (_a) {
35
- var type = _a.type, path = _a.path;
36
- return XPathUtils.selectArray(path, document).map(function (divida) { return ({
37
- nomeDoDevedor: XPathUtils.select('string(./nome_devedor)', divida),
38
- tipoDePessoa: XPathUtils.select('string(./tipo_pessoa)', divida),
39
- tipoDeDevedor: XPathUtils.select('string(./tipo_devedor)', divida),
40
- unidadeResponsavel: XPathUtils.select('string(./unidade_responsavel)', divida),
41
- uFDaUnidadeResponsavel: XPathUtils.select('string(./uf_unidade_responsavel)', divida),
42
- numeroDeInscricaoDaDivida: XPathUtils.select('string(./numero_inscricao)', divida),
43
- tipoDaSituacaoDaInscricao: XPathUtils.select('string(./tipo_situacao_inscricao)', divida),
44
- situacaoDaInscricao: XPathUtils.select('string(./situacao_inscricao)', divida),
45
- dataDeInscricao: XPathUtils.select('string(./data_inscricao)', divida),
46
- indicadorAjuizado: XPathUtils.select('string(./indicador_ajuizado)', divida),
47
- valorConsolidado: formatMoney(XPathUtils.select('string(./valor_consolidado)', divida)),
48
- tipoDeDivida: type
49
- }); });
50
- });
51
- };
51
+ useEffect(function () {
52
+ if (ctx.type !== RequestStatus.Success || dataUpdated || !ctx.document) {
53
+ return;
54
+ }
55
+ var dividas = parseDividas(ctx.document);
56
+ if (!dataUpdated) {
57
+ var dividasPublicas_1 = XPathUtils.select('number(//dividas/resumo/valor_total_dividas)', ctx.document) || 0;
58
+ setData(function (prevState) { return (__assign(__assign({}, prevState), { dividas: dividas, dividasPublicas: dividasPublicas_1 })); });
59
+ setDataUpdated(true);
60
+ }
61
+ }, [ctx, dataUpdated, setData]);
62
+ return (React.createElement(Section, { ctx: ctx, title: "D\u00EDvidas P\u00FAblicas", icon: DividasVencidasSerasaIcon, subtitle: "Veja as d\u00EDvidas p\u00FAblicas com a Uni\u00E3o (ativa, FGTS e previdenci\u00E1ria).", onSuccess: function (document) {
52
63
  var dividas = parseDividas(document);
53
- if (!dataUpdated) {
54
- var dividasPublicas_1 = XPathUtils.select('number(//dividas/resumo/valor_total_dividas)', document) || 0;
55
- if (dividas.length > 0 || dividasPublicas_1) {
56
- setData(function (prevState) { return (__assign(__assign({}, prevState), { dividas: dividas, dividasPublicas: dividasPublicas_1 })); });
57
- }
58
- setDataUpdated(true);
59
- }
60
- dividas.sort(function (a, b) {
61
- return parseDate(b.dataDeInscricao).getTime() -
62
- parseDate(a.dataDeInscricao).getTime();
63
- });
64
64
  var totalOcorrencias = dividas.length;
65
65
  var children = totalOcorrencias ? (React.createElement(Result, null,
66
66
  React.createElement(DividasPublicasList, { dividas: dividas }))) : null;
@@ -2,18 +2,18 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
2
2
  if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
3
  return cooked;
4
4
  };
5
+ import DominiosIcon from '../../assets/icones/dominios';
5
6
  import React, { useContext } from 'react';
6
- import { Queries } from '../webservice';
7
- import { Result, ResultContent } from '../interface/result';
8
- import AddItemField from '../common/addItem';
9
7
  import styled from 'styled-components';
8
+ import AddItemField from '../common/addItem';
9
+ import { Result, ResultContent } from '../interface/result';
10
10
  import StatusMessage from '../interface/statusMessage';
11
- import DominiosIcon from '../../assets/icones/dominios';
11
+ import { Section } from '../section';
12
+ import { Queries } from '../webservice';
12
13
  var Link = styled.a(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n color: inherit;\n text-decoration: none;\n"], ["\n color: inherit;\n text-decoration: none;\n"])));
13
14
  var Dominios = function () {
14
15
  var ctx = useContext(Queries.Dominios);
15
- var Section = ctx.Section;
16
- return (React.createElement(Section, { title: "Dom\u00EDnios na Internet", subtitle: "Informa\u00E7\u00F5es de dom\u00EDnios na internet.", icon: DominiosIcon, onSuccess: function (document) {
16
+ return (React.createElement(Section, { ctx: ctx, title: "Dom\u00EDnios na Internet", subtitle: "Informa\u00E7\u00F5es de dom\u00EDnios na internet.", icon: DominiosIcon, onSuccess: function (document) {
17
17
  return {
18
18
  children: document.length ? (React.createElement(Result, { resultContentStriped: false }, document.map(function (data) { return (React.createElement(ResultContent, { desktop: "1fr 1fr 1fr", tablet: "1fr 1fr", mobile: "1fr 1fr", key: data },
19
19
  React.createElement(AddItemField, { name: "Dom\u00EDnio", value: React.createElement(Link, { href: "https://www.".concat(data), target: "_blank", rel: "noreferrer" }, data) }))); }))) : null,