@credithub/harlan-components 1.32.0 → 1.34.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 (54) hide show
  1. package/dist/assets/btn/buttonAtualizarDadosRfb.d.ts +3 -0
  2. package/dist/assets/btn/buttonAtualizarDadosRfb.js +10 -0
  3. package/dist/components/adresses/addresses.d.ts +2 -2
  4. package/dist/components/adresses/addresses.js +34 -12
  5. package/dist/components/adresses/map.js +1 -1
  6. package/dist/components/bank-accounts/bank-accounts.js +32 -28
  7. package/dist/components/ccf/ccf.js +2 -2
  8. package/dist/components/chart/chartSystem.js +51 -29
  9. package/dist/components/chart/hooks/useChartData.d.ts +6 -0
  10. package/dist/components/chart/hooks/useChartData.js +57 -4
  11. package/dist/components/chart/utils/chartUtils.d.ts +0 -4
  12. package/dist/components/chart/utils/chartUtils.js +0 -16
  13. package/dist/components/common/button.d.ts +1 -0
  14. package/dist/components/common/button.js +11 -24
  15. package/dist/components/consultaRfb.d.ts +2 -0
  16. package/dist/components/consultaRfb.js +17 -14
  17. package/dist/components/consultaSimplesSection/consultaSimplesSection.js +2 -2
  18. package/dist/components/contacts/contacts.js +8 -5
  19. package/dist/components/dividasPublicas/dividasPublicas.js +40 -40
  20. package/dist/components/dominios/dominios.js +17 -6
  21. package/dist/components/dossie/dossie.js +20 -10
  22. package/dist/components/dossie/summary/cardsAndProducts.d.ts +6 -8
  23. package/dist/components/dossie/summary/cardsAndProducts.js +94 -26
  24. package/dist/components/dossie/summary/styles.d.ts +12 -0
  25. package/dist/components/dossie/summary/styles.js +38 -0
  26. package/dist/components/dossie/summary/summary.js +7 -16
  27. package/dist/components/dossie/summary/utils.js +12 -2
  28. package/dist/components/imoveis/imoveisService.js +26 -13
  29. package/dist/components/interface/header.js +3 -3
  30. package/dist/components/interface/loadingBar.js +3 -6
  31. package/dist/components/interface/section.d.ts +2 -0
  32. package/dist/components/interface/section.js +7 -6
  33. package/dist/components/liminar/liminar.js +25 -15
  34. package/dist/components/llama/llama.d.ts +6 -0
  35. package/dist/components/llama/llama.js +122 -0
  36. package/dist/components/partners/partnerList.js +1 -1
  37. package/dist/components/partners/partners.js +28 -8
  38. package/dist/components/pep/pep.js +13 -6
  39. package/dist/components/processos-juridicos/processosJuridicos.js +19 -13
  40. package/dist/components/protestos/protestos.js +54 -39
  41. package/dist/components/refinBoaVista/refinBoaVista.js +31 -15
  42. package/dist/components/refinSerasa/refinSerasa.js +25 -38
  43. package/dist/components/score/scoreService.js +27 -13
  44. package/dist/components/scr/scr.js +123 -59
  45. package/dist/components/section.d.ts +3 -0
  46. package/dist/components/section.js +91 -0
  47. package/dist/components/veiculos/veiculos.js +28 -12
  48. package/dist/components/webservice.d.ts +22 -29
  49. package/dist/components/webservice.js +92 -131
  50. package/dist/consultaSimples.js +2 -2
  51. package/dist/hooks/useConsultaRfb.d.ts +1 -0
  52. package/lib/cjs/index.js +1448 -1030
  53. package/lib/esm/index.js +1449 -1031
  54. package/package.json +1 -1
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
1
  var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
2
  if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
3
  return cooked;
@@ -23,63 +22,79 @@ import { useGlobalData } from '../../contexts/globalDataContext';
23
22
  import { formatDatePtBrToDate } from '../../utils/date';
24
23
  import { extractIntegerFromText } from '../../utils/number';
25
24
  import XPathUtils from '../../utils/xpath';
26
- import React, { useContext, useState } from 'react';
25
+ import React, { useContext, useEffect, useState } from 'react';
27
26
  import styled from 'styled-components';
28
27
  import StatusMessage from '../interface/statusMessage';
29
- import { Queries } from '../webservice';
28
+ import { Section } from '../section';
29
+ import { Queries, RequestStatus } from '../webservice';
30
30
  import ProtestosCategory from './protestosCategory';
31
31
  import { ProtestoItem } from './protestosList';
32
- var ResultProtestos = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n\n flex-direction: column;\n\n row-gap: 20px;\n\n margin-top: 20px;\n"], ["\n display: flex;\n\n flex-direction: column;\n\n row-gap: 20px;\n\n margin-top: 20px;\n"])));
32
+ 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"])));
33
33
  var Protestos = function () {
34
34
  var ctx = useContext(Queries.Protestos);
35
- var Section = ctx.Section;
36
35
  var setData = useGlobalData().setData;
37
36
  var _a = useState(false), dataUpdated = _a[0], setDataUpdated = _a[1];
38
- var filterProtestos = function (regex, data) {
39
- return XPathUtils.selectArray('//body//protesto', data).filter(function (protesto) {
40
- return regex.test(XPathUtils.select('string(./nomeCedente)', protesto));
41
- });
42
- };
43
- 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) {
44
- var byDate = function (protesto, protesto2) {
45
- var _a, _b;
46
- return ((_a = formatDatePtBrToDate(XPathUtils.select('string(./dataProtesto)', protesto2))) === null || _a === void 0 ? void 0 : _a.getTime()) -
47
- ((_b = formatDatePtBrToDate(XPathUtils.select('string(./dataProtesto)', protesto))) === null || _b === void 0 ? void 0 : _b.getTime());
48
- };
37
+ useEffect(function () {
38
+ if (ctx.type !== RequestStatus.Success || dataUpdated || !ctx.document) {
39
+ return;
40
+ }
41
+ var data = ctx.document;
42
+ var byDate = function (protesto, protesto2) {
43
+ var _a, _b;
44
+ return (((_a = formatDatePtBrToDate(XPathUtils.select('string(./dataProtesto)', protesto2))) === null || _a === void 0 ? void 0 : _a.getTime()) || 0) -
45
+ (((_b = formatDatePtBrToDate(XPathUtils.select('string(./dataProtesto)', protesto))) === null || _b === void 0 ? void 0 : _b.getTime()) || 0);
46
+ };
47
+ var registrosText = XPathUtils.select('string(//registros)', data);
48
+ var registros = extractIntegerFromText(registrosText);
49
+ var filterProtestos = function (regex, data) {
50
+ return XPathUtils.selectArray('//body//protesto', data).filter(function (protesto) {
51
+ return regex.test(XPathUtils.select('string(./nomeCedente)', protesto));
52
+ });
53
+ };
54
+ var protestosDeCredito = filterProtestos(REGEX_PROTESTOS_DE_CREDITO, data).sort(byDate);
55
+ var protestosDeImposto = filterProtestos(REGEX_PROTESTOS_DE_IMPOSTO, data).sort(byDate);
56
+ var protestosGerais = XPathUtils.selectArray('//body//protesto', data)
57
+ .filter(function (protesto) {
58
+ var nomeCedente = XPathUtils.select('string(./nomeCedente)', protesto);
59
+ return (!REGEX_PROTESTOS_DE_IMPOSTO.test(nomeCedente) &&
60
+ !REGEX_PROTESTOS_DE_CREDITO.test(nomeCedente));
61
+ })
62
+ .sort(byDate);
63
+ var protestosState = {
64
+ protestosDeCredito: protestosDeCredito,
65
+ protestosDeImposto: protestosDeImposto,
66
+ protestosGerais: protestosGerais,
67
+ totalProtestos: registros
68
+ };
69
+ setData(function (prevState) { return (__assign(__assign({}, prevState), { protestos: registros, protestosData: protestosState })); });
70
+ setDataUpdated(true);
71
+ }, [ctx, setData, dataUpdated]);
72
+ return (React.createElement(Section, { ctx: __assign(__assign({}, ctx), { progress: ctx.progress }), title: "Apontamentos na Central de Protestos (CENPROT)", subtitle: "Consulta de protestos de cr\u00E9dito, imposto e gerais.", icon: ProtestosIcon, onSuccess: function (data) {
49
73
  var registrosText = XPathUtils.select('string(//registros)', data);
50
74
  var registros = extractIntegerFromText(registrosText);
51
- setData(function (prevState) { return (__assign(__assign({}, prevState), { protestos: registros })); });
52
- var protestosDeCredito = filterProtestos(REGEX_PROTESTOS_DE_CREDITO, data).sort(byDate);
53
- var protestosDeImposto = filterProtestos(REGEX_PROTESTOS_DE_IMPOSTO, data).sort(byDate);
54
- var protestosGerais = XPathUtils.selectArray('//body//protesto', data)
55
- .filter(function (protesto) {
75
+ var protestosDeCredito = XPathUtils.selectArray('//body//protesto', data).filter(function (protesto) {
76
+ return REGEX_PROTESTOS_DE_CREDITO.test(XPathUtils.select('string(./nomeCedente)', protesto));
77
+ });
78
+ var protestosDeImposto = XPathUtils.selectArray('//body//protesto', data).filter(function (protesto) {
79
+ return REGEX_PROTESTOS_DE_IMPOSTO.test(XPathUtils.select('string(./nomeCedente)', protesto));
80
+ });
81
+ var protestosGerais = XPathUtils.selectArray('//body//protesto', data).filter(function (protesto) {
56
82
  var nomeCedente = XPathUtils.select('string(./nomeCedente)', protesto);
57
83
  return (!REGEX_PROTESTOS_DE_IMPOSTO.test(nomeCedente) &&
58
84
  !REGEX_PROTESTOS_DE_CREDITO.test(nomeCedente));
59
- })
60
- .sort(byDate);
61
- if (!dataUpdated) {
62
- var protestosState_1 = {
63
- protestosDeCredito: protestosDeCredito,
64
- protestosDeImposto: protestosDeImposto,
65
- protestosGerais: protestosGerais,
66
- totalProtestos: registros
67
- };
68
- setData(function (prevState) { return (__assign(__assign({}, prevState), { protestosData: protestosState_1 })); });
69
- setDataUpdated(true);
70
- }
85
+ });
71
86
  var elements = [
72
87
  {
73
- total: protestosDeCredito === null || protestosDeCredito === void 0 ? void 0 : protestosDeCredito.length,
74
- element: (React.createElement(ProtestosCategory, { title: "Protestos de Cr\u00E9dito", subtitle: "Protestos de cr\u00E9dito em geral.", registros: protestosDeCredito === null || protestosDeCredito === void 0 ? void 0 : protestosDeCredito.length, icon: ProtestosCreditoIcon }, protestosDeCredito.map(function (protesto, i) { return (React.createElement(ProtestoItem, { protesto: protesto, key: i })); })))
88
+ total: protestosDeCredito.length,
89
+ element: (React.createElement(ProtestosCategory, { title: "Protestos de Cr\u00E9dito", subtitle: "Protestos de cr\u00E9dito em geral.", registros: protestosDeCredito.length, icon: ProtestosCreditoIcon }, protestosDeCredito.map(function (protesto, i) { return (React.createElement(ProtestoItem, { protesto: protesto, key: i })); })))
75
90
  },
76
91
  {
77
- total: protestosDeImposto === null || protestosDeImposto === void 0 ? void 0 : protestosDeImposto.length,
78
- element: (React.createElement(ProtestosCategory, { title: "Protestos de Imposto", subtitle: "Protestos de impostos federais, estaduais e municipais.", registros: protestosDeImposto === null || protestosDeImposto === void 0 ? void 0 : protestosDeImposto.length, icon: ProtestosImpostosIcon }, protestosDeImposto.map(function (protestoElement, index) { return (React.createElement(ProtestoItem, { protesto: protestoElement, key: index })); })))
92
+ total: protestosDeImposto.length,
93
+ element: (React.createElement(ProtestosCategory, { title: "Protestos de Imposto", subtitle: "Protestos de impostos federais, estaduais e municipais.", registros: protestosDeImposto.length, icon: ProtestosImpostosIcon }, protestosDeImposto.map(function (protestoElement, index) { return (React.createElement(ProtestoItem, { protesto: protestoElement, key: index })); })))
79
94
  },
80
95
  {
81
- total: protestosGerais === null || protestosGerais === void 0 ? void 0 : protestosGerais.length,
82
- element: (React.createElement(ProtestosCategory, { title: "Protestos Gerais", subtitle: "Protestos de outros tipos.", registros: protestosGerais === null || protestosGerais === void 0 ? void 0 : protestosGerais.length, icon: ProtestosGeraisIcon }, protestosGerais.map(function (protestoElement, index) { return (React.createElement(ProtestoItem, { protesto: protestoElement, key: index })); })))
96
+ total: protestosGerais.length,
97
+ element: (React.createElement(ProtestosCategory, { title: "Protestos Gerais", subtitle: "Protestos de outros tipos.", registros: protestosGerais.length, icon: ProtestosGeraisIcon }, protestosGerais.map(function (protestoElement, index) { return (React.createElement(ProtestoItem, { protesto: protestoElement, key: index })); })))
83
98
  }
84
99
  ].sort(function (a, b) { return b.total - a.total; });
85
100
  var children = registros ? (React.createElement(ResultProtestos, null, elements.map(function (_a) {
@@ -16,17 +16,17 @@ import { addNoValueContent } from '../../utils/string';
16
16
  import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
17
17
  import AddItemField from '../common/addItem';
18
18
  import { ConsultasComplementaresContext } from '../consultasComplementares';
19
- import Header from '../interface/header';
20
19
  import { Result, ResultContent } from '../interface/result';
21
20
  import StatusMessage from '../interface/statusMessage';
22
- import { useQuery } from '../webservice';
21
+ import { Section } from '../section';
22
+ import { RequestStatus, useQuery } from '../webservice';
23
23
  function useRefinBoaVista(documento) {
24
24
  var _a;
25
25
  var consultasComplementaresContext = useContext(ConsultasComplementaresContext);
26
26
  var setData = useGlobalData().setData;
27
27
  var _b = useState(false), dataUpdated = _b[0], setDataUpdated = _b[1];
28
28
  var _c = consultasComplementaresContext !== null && consultasComplementaresContext !== void 0 ? consultasComplementaresContext : {}, consultasComplementares = _c.consultasComplementares, setConsultasComplementares = _c.setConsultasComplementares;
29
- var _d = useQuery("SELECT FROM 'PROTESTOS'.'REFIN'", { documento: documento }, !!((_a = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinBoaVista) === null || _a === void 0 ? void 0 : _a.consultaRealizada)), response = _d.response, isLoading = _d.isLoading, error = _d.error;
29
+ var _d = useQuery("SELECT FROM 'PROTESTOS'.'REFIN'", { documento: documento }, !!((_a = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinBoaVista) === null || _a === void 0 ? void 0 : _a.consultaRealizada)), response = _d.response, isLoading = _d.isLoading, error = _d.error, loadingProgress = _d.loadingProgress;
30
30
  var pendencias = useMemo(function () {
31
31
  var _a;
32
32
  if ((_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.spc) {
@@ -51,30 +51,40 @@ function useRefinBoaVista(documento) {
51
51
  setDataUpdated(true);
52
52
  }
53
53
  }, [response, dataUpdated, setData, setConsultasComplementares]);
54
- return { isLoading: isLoading, error: error, pendencias: pendencias, consultaRealizada: !!response };
54
+ return {
55
+ isLoading: isLoading,
56
+ error: error,
57
+ pendencias: pendencias,
58
+ consultaRealizada: !!response,
59
+ loadingProgress: loadingProgress
60
+ };
55
61
  }
56
62
  function RefinBoaVista(_a) {
57
63
  var documento = _a.documento;
58
64
  var refinBoaVistaRef = useRef(null);
59
- var _b = useRefinBoaVista(documento), isLoading = _b.isLoading, error = _b.error, pendencias = _b.pendencias, consultaRealizada = _b.consultaRealizada;
65
+ var _b = useRefinBoaVista(documento), isLoading = _b.isLoading, error = _b.error, pendencias = _b.pendencias, consultaRealizada = _b.consultaRealizada, loadingProgress = _b.loadingProgress;
60
66
  useEffect(function () {
61
67
  var _a;
62
68
  (_a = refinBoaVistaRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
63
69
  }, [consultaRealizada]);
64
- var statusType = pendencias.length > 0 ? 'success' : 'default';
65
- var variant = isLoading
66
- ? 'loading'
67
- : error
68
- ? 'error'
69
- : 'default';
70
70
  var description = pendencias.length
71
71
  ? "Foram encontrados ".concat(pendencias.length, " ocorr\u00EAncias")
72
72
  : 'Nenhuma ocorrência encontrada';
73
73
  if (!consultaRealizada)
74
74
  return null;
75
- return (React.createElement("div", null,
76
- React.createElement(Header, { innerRef: refinBoaVistaRef, title: "Restri\u00E7\u00F5es Pefin/Refin Boa Vista", subtitle: "Apontamentos e Restri\u00E7\u00F5es Financeiras e Comerciais", variant: variant, description: React.createElement(StatusMessage, { type: statusType }, error ? error.message : description), icon: PefinRefinBoaVistaIcon }),
77
- pendencias.length > 0 && (React.createElement(Result, null, pendencias.map(function (pendencia, i) { return (React.createElement(ResultContent, { key: i, desktop: "repeat(5, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
75
+ return (React.createElement(Section, { ctx: {
76
+ type: isLoading
77
+ ? RequestStatus.Loading
78
+ : error
79
+ ? RequestStatus.Error
80
+ : RequestStatus.Success,
81
+ error: error || null,
82
+ response: undefined,
83
+ document: pendencias,
84
+ refetch: function () { },
85
+ Section: Section,
86
+ progress: loadingProgress
87
+ }, title: "Restri\u00E7\u00F5es Pefin/Refin Boa Vista", subtitle: "Apontamentos e Restri\u00E7\u00F5es Financeiras e Comerciais", icon: PefinRefinBoaVistaIcon, description: !error && (React.createElement(StatusMessage, { type: pendencias.length ? 'success' : 'default' }, description)), onSuccess: function () { return (React.createElement(Result, null, pendencias.map(function (pendencia, i) { return (React.createElement(ResultContent, { key: i, desktop: "repeat(5, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
78
88
  React.createElement(AddItemField, { name: "Associado", value: pendencia.NomeAssociado }),
79
89
  React.createElement(AddItemField, { name: "Valor", value: pendencia.Valor && !isNaN(parseFloat(pendencia.Valor))
80
90
  ? "".concat(formatMoney(parseFloat(pendencia.Valor)))
@@ -86,6 +96,12 @@ function RefinBoaVista(_a) {
86
96
  React.createElement(AddItemField, { name: "Comprador, Fiador ou Avalista", value: pendencia.CompradorFiadorAvalista }),
87
97
  React.createElement(AddItemField, { name: "Telefone Associado", value: pendencia.TelefoneAssociado }),
88
98
  React.createElement(AddItemField, { name: "Cidade Associado", value: pendencia.CidadeAssociado }),
89
- React.createElement(AddItemField, { name: "UF Associado", value: pendencia.UfAssociado }))); })))));
99
+ React.createElement(AddItemField, { name: "UF Associado", value: pendencia.UfAssociado }))); }))); }, isError: function (err) { return ({
100
+ children: React.createElement(React.Fragment, null),
101
+ description: (React.createElement(StatusMessage, { type: "error" },
102
+ "Erro ao realizar a consulta: ",
103
+ err.message)),
104
+ variant: 'error'
105
+ }); } }));
90
106
  }
91
107
  export default RefinBoaVista;
@@ -9,17 +9,6 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
12
  import PefinRefinSerasaIcon from '../../assets/icones/pefinRefinSerasa';
24
13
  import { useGlobalData } from '../../contexts/globalDataContext';
25
14
  import { formatMoney } from '../../utils/number';
@@ -27,10 +16,10 @@ import { addNoValueContent } from '../../utils/string';
27
16
  import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
28
17
  import AddItemField from '../common/addItem';
29
18
  import { ConsultasComplementaresContext } from '../consultasComplementares';
30
- import Header from '../interface/header';
31
19
  import { Result, ResultContent } from '../interface/result';
32
20
  import StatusMessage from '../interface/statusMessage';
33
- import { useQuery } from '../webservice';
21
+ import { Section } from '../section';
22
+ import { RequestStatus, useQuery } from '../webservice';
34
23
  var RefinSerasa = function (_a) {
35
24
  var _b, _c, _d, _e;
36
25
  var documento = _a.documento;
@@ -39,7 +28,7 @@ var RefinSerasa = function (_a) {
39
28
  var _f = useState(false), dataUpdated = _f[0], setDataUpdated = _f[1];
40
29
  var consultasComplementaresContext = useContext(ConsultasComplementaresContext);
41
30
  var _g = consultasComplementaresContext !== null && consultasComplementaresContext !== void 0 ? consultasComplementaresContext : {}, consultasComplementares = _g.consultasComplementares, setConsultasComplementares = _g.setConsultasComplementares;
42
- var _h = useQuery("SELECT FROM 'PROTESTOS'.'SERASA'", { documento: documento }, !!((_b = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinSerasa) === null || _b === void 0 ? void 0 : _b.consultaRealizada)), response = _h.response, isLoading = _h.isLoading, error = _h.error;
31
+ var _h = useQuery("SELECT FROM 'PROTESTOS'.'SERASA'", { documento: documento }, !!((_b = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinSerasa) === null || _b === void 0 ? void 0 : _b.consultaRealizada)), response = _h.response, isLoading = _h.isLoading, error = _h.error, loadingProgress = _h.loadingProgress;
43
32
  var clearValue = function (value) {
44
33
  var semPontos = value === null || value === void 0 ? void 0 : value.replace(/\./g, '');
45
34
  return semPontos === null || semPontos === void 0 ? void 0 : semPontos.replace(',', '.');
@@ -77,32 +66,24 @@ var RefinSerasa = function (_a) {
77
66
  }
78
67
  }, [response, dataUpdated, setData]);
79
68
  var valorTotalPendenciasFinanceiras = (((_e = (_d = response === null || response === void 0 ? void 0 : response.document) === null || _d === void 0 ? void 0 : _d.informacoes) === null || _e === void 0 ? void 0 : _e[0]) || {}).valorTotalPendenciasFinanceiras;
80
- return consultaRefinRealizada ? (React.createElement(React.Fragment, null,
81
- React.createElement(PendenciasList, { title: "Pefin/Refin e Contratos Vencidos Serasa", subtitle: "Confira as Pend\u00EAncias Financeiras deste documento", pendencias: pendencias, valorTotal: valorTotalPendenciasFinanceiras, innerRef: refinSerasaRef, isLoading: isLoading, error: error }))) : null;
82
- };
83
- var PendenciasList = function (_a) {
84
- var isLoading = _a.isLoading, error = _a.error, pendencias = _a.pendencias, valorTotal = _a.valorTotal, headerProps = __rest(_a, ["isLoading", "error", "pendencias", "valorTotal"]);
85
- var valorTotalSeguro = valorTotal !== null && valorTotal !== void 0 ? valorTotal : 0;
86
- var totalFormatado = formatMoney(valorTotal === null || valorTotal === void 0 ? void 0 : valorTotal.toString().replace(',', '.'));
87
69
  var description = pendencias.length === 0
88
70
  ? 'Nenhuma ocorrência encontrada'
89
71
  : pendencias.length === 1
90
- ? 'Foi encontrada 1 ocorrência' +
91
- (valorTotalSeguro > 0 ? " no valor de ".concat(totalFormatado) : '')
92
- : "Foram encontradas ".concat(pendencias.length, " ocorr\u00EAncias") +
93
- (valorTotalSeguro > 0 ? " no valor de ".concat(totalFormatado) : '');
94
- var statusType = error
95
- ? 'error'
96
- : pendencias.length === 0
97
- ? 'success'
98
- : 'error';
99
- return (React.createElement("div", null,
100
- React.createElement(Header, __assign({ variant: isLoading
101
- ? 'loading'
102
- : error || pendencias.length
103
- ? 'error'
104
- : 'default', description: React.createElement(StatusMessage, { type: statusType }, (error === null || error === void 0 ? void 0 : error.message) || description), icon: PefinRefinSerasaIcon }, headerProps)),
105
- React.createElement(Result, null, pendencias.map(function (pendencia, i) { return (React.createElement(ResultContent, { key: i, desktop: "repeat(5, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
72
+ ? "Foi encontrada 1 ocorr\u00EAncia".concat(valorTotalPendenciasFinanceiras ? " no valor de ".concat(formatMoney(valorTotalPendenciasFinanceiras)) : '')
73
+ : "Foram encontradas ".concat(pendencias.length, " ocorr\u00EAncias").concat(valorTotalPendenciasFinanceiras ? " no valor de ".concat(formatMoney(valorTotalPendenciasFinanceiras)) : '');
74
+ return consultaRefinRealizada ? (React.createElement(Section, { ctx: {
75
+ type: isLoading
76
+ ? RequestStatus.Loading
77
+ : error
78
+ ? RequestStatus.Error
79
+ : RequestStatus.Success,
80
+ error: error || null,
81
+ response: undefined,
82
+ document: response === null || response === void 0 ? void 0 : response.document,
83
+ refetch: function () { },
84
+ Section: Section,
85
+ progress: loadingProgress
86
+ }, title: "Pefin/Refin e Contratos Vencidos Serasa", subtitle: "Confira as Pend\u00EAncias Financeiras deste documento", icon: PefinRefinSerasaIcon, description: !error && (React.createElement(StatusMessage, { type: pendencias.length === 0 ? 'success' : 'default' }, description)), onSuccess: function () { return (React.createElement(Result, null, pendencias.map(function (pendencia, i) { return (React.createElement(ResultContent, { key: i, desktop: "repeat(5, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
106
87
  React.createElement(AddItemField, { name: "Tipo de Ocorr\u00EAncia", value: pendencia.ocorrencia }),
107
88
  React.createElement(AddItemField, { name: "Credor", value: pendencia.credor }),
108
89
  React.createElement(AddItemField, { name: "Data de Entrada", value: pendencia.entrada }),
@@ -117,6 +98,12 @@ var PendenciasList = function (_a) {
117
98
  React.createElement(AddItemField, { name: "Org\u00E3o Emissor", value: pendencia.orgaoemissor }),
118
99
  React.createElement(AddItemField, { name: "Total de Pend\u00EAncias", value: pendencia.totalpendencias }),
119
100
  React.createElement(AddItemField, { name: "Valor Total", value: pendencia.totalvalor }),
120
- React.createElement(AddItemField, { name: "Categoria", value: pendencia.categoria }))); }))));
101
+ React.createElement(AddItemField, { name: "Categoria", value: pendencia.categoria }))); }))); }, isError: function (err) { return ({
102
+ children: React.createElement(React.Fragment, null),
103
+ description: (React.createElement(StatusMessage, { type: "error" },
104
+ "Erro ao realizar a consulta: ",
105
+ err.message)),
106
+ variant: 'error'
107
+ }); } })) : null;
121
108
  };
122
109
  export default RefinSerasa;
@@ -14,17 +14,17 @@ import { useGlobalData } from '../../contexts/globalDataContext';
14
14
  import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
15
15
  import AddItemField from '../common/addItem';
16
16
  import { ConsultasComplementaresContext } from '../consultasComplementares';
17
- import Header from '../interface/header';
18
17
  import { Result, ResultContent } from '../interface/result';
19
18
  import StatusMessage from '../interface/statusMessage';
20
- import { useQuery } from '../webservice';
19
+ import { Section } from '../section';
20
+ import { RequestStatus, useQuery } from '../webservice';
21
21
  var ConsultaScore = function (_a) {
22
22
  var _b, _c, _d, _e, _f;
23
23
  var documento = _a.documento;
24
24
  var consultasComplementaresContext = useContext(ConsultasComplementaresContext);
25
25
  var setData = useGlobalData().setData;
26
26
  var _g = useState(false), dataUpdated = _g[0], setDataUpdated = _g[1];
27
- var _h = useQuery("SELECT FROM 'SPCNet'.'ScoreBoaVista'", { documento: documento }, (_c = (_b = consultasComplementaresContext === null || consultasComplementaresContext === void 0 ? void 0 : consultasComplementaresContext.consultasComplementares) === null || _b === void 0 ? void 0 : _b.scoreBoaVista) === null || _c === void 0 ? void 0 : _c.consultaRealizada), response = _h.response, isLoading = _h.isLoading, error = _h.error;
27
+ var _h = useQuery("SELECT FROM 'SPCNet'.'ScoreBoaVista'", { documento: documento }, (_c = (_b = consultasComplementaresContext === null || consultasComplementaresContext === void 0 ? void 0 : consultasComplementaresContext.consultasComplementares) === null || _b === void 0 ? void 0 : _b.scoreBoaVista) === null || _c === void 0 ? void 0 : _c.consultaRealizada), response = _h.response, isLoading = _h.isLoading, error = _h.error, loadingProgress = _h.loadingProgress;
28
28
  var scoreData = (_d = response === null || response === void 0 ? void 0 : response.document) === null || _d === void 0 ? void 0 : _d.score[0];
29
29
  var scoreRef = useRef(null);
30
30
  var consultaRefinRealizada = useMemo(function () {
@@ -33,11 +33,9 @@ var ConsultaScore = function (_a) {
33
33
  }, [
34
34
  (_f = (_e = consultasComplementaresContext === null || consultasComplementaresContext === void 0 ? void 0 : consultasComplementaresContext.consultasComplementares) === null || _e === void 0 ? void 0 : _e.scoreBoaVista) === null || _f === void 0 ? void 0 : _f.consultaRealizada
35
35
  ]);
36
- var description = error
37
- ? error.message
38
- : scoreData
39
- ? "Score: ".concat(scoreData.score)
40
- : 'Nenhuma informação de score disponível para este documento.';
36
+ var description = scoreData
37
+ ? "Score: ".concat(scoreData.score)
38
+ : 'Nenhuma informação de score disponível para este documento.';
41
39
  useEffect(function () {
42
40
  var _a;
43
41
  (_a = scoreRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
@@ -50,16 +48,32 @@ var ConsultaScore = function (_a) {
50
48
  setDataUpdated(true);
51
49
  }
52
50
  }, [consultaRefinRealizada, response, dataUpdated, setData]);
53
- return consultaRefinRealizada ? (React.createElement("div", null,
54
- React.createElement(Header, { innerRef: scoreRef, title: "Score Boa Vista", subtitle: "Consulta de Score", variant: isLoading ? 'loading' : error ? 'error' : 'default', description: React.createElement(StatusMessage, { type: error ? 'error' : scoreData ? 'success' : 'default' }, (error === null || error === void 0 ? void 0 : error.message) || description), icon: ScoreBoaVistaIcon }),
55
- React.createElement(Result, null, scoreData && (React.createElement(ResultContent, { desktop: "repeat(4, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
51
+ return consultaRefinRealizada ? (React.createElement(Section, { ctx: {
52
+ type: isLoading
53
+ ? RequestStatus.Loading
54
+ : error
55
+ ? RequestStatus.Error
56
+ : RequestStatus.Success,
57
+ error: error || null,
58
+ response: undefined,
59
+ document: response === null || response === void 0 ? void 0 : response.document,
60
+ refetch: function () { },
61
+ Section: Section,
62
+ progress: loadingProgress
63
+ }, title: "Score Boa Vista", subtitle: "Consulta de Score", icon: ScoreBoaVistaIcon, description: !error && (React.createElement(StatusMessage, { type: scoreData ? 'success' : 'default' }, description)), onSuccess: function () { return (React.createElement(Result, null, scoreData && (React.createElement(ResultContent, { desktop: "repeat(4, 1fr)", tablet: "repeat(3, 1fr)", mobile: "1fr 1fr" },
56
64
  React.createElement(AddItemField, { name: "Score", value: String(scoreData.score) }),
57
65
  React.createElement(AddItemField, { name: "Probabilidade de Inadimpl\u00EAncia", value: scoreData.provavel }),
58
66
  React.createElement(AddItemField, { name: "Classifica\u00E7\u00E3o", value: scoreData.classificacao }),
59
67
  React.createElement(AddItemField, { name: "An\u00E1lise", value: scoreData.texto }),
60
68
  React.createElement(AddItemField, { name: "Status", value: scoreData.status }),
61
69
  documento.length > 11 && (React.createElement(React.Fragment, null,
62
- React.createElement(AddItemField, { name: "Classifica\u00E7\u00E3o N\u00FAmerica", value: scoreData.classificacao_numerica }),
63
- React.createElement(AddItemField, { name: "Classifica\u00E7\u00E3o Alfab\u00E9tica", value: scoreData.classificacao_alfabetica })))))))) : null;
70
+ React.createElement(AddItemField, { name: "Classifica\u00E7\u00E3o Num\u00E9rica", value: scoreData.classificacao_numerica }),
71
+ React.createElement(AddItemField, { name: "Classifica\u00E7\u00E3o Alfab\u00E9tica", value: scoreData.classificacao_alfabetica }))))))); }, isError: function (err) { return ({
72
+ children: React.createElement(React.Fragment, null),
73
+ description: (React.createElement(StatusMessage, { type: "error" },
74
+ "Erro ao realizar a consulta: ",
75
+ err.message)),
76
+ variant: 'error'
77
+ }); } })) : null;
64
78
  };
65
79
  export default ConsultaScore;