@credithub/harlan-components 1.80.2 → 1.81.1

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 (38) hide show
  1. package/dist/assets/btn/buttonAtualizarDadosRfb.js +11 -5
  2. package/dist/components/common/button.d.ts +4 -2
  3. package/dist/components/common/button.js +41 -12
  4. package/dist/components/common/modal.d.ts +4 -4
  5. package/dist/components/common/modal.js +69 -20
  6. package/dist/components/consultaRfb.d.ts +26 -2
  7. package/dist/components/consultaRfb.js +51 -13
  8. package/dist/components/dossie/dossie.js +28 -22
  9. package/dist/components/dossie/summary/cardsAndProducts.js +22 -22
  10. package/dist/components/dossie/summary/styles.d.ts +2 -4
  11. package/dist/components/dossie/summary/styles.js +2 -2
  12. package/dist/components/refinBoaVista/refinBoaVista.js +3 -2
  13. package/dist/components/refinSerasa/refinSerasa.js +13 -8
  14. package/dist/components/score/scoreService.js +3 -2
  15. package/dist/components/scoreSerasa/scoreSerasa.js +3 -2
  16. package/dist/components/scr/scr.js +3 -2
  17. package/dist/components/veiculos/veiculos.js +3 -2
  18. package/dist/consultaSimples.js +34 -32
  19. package/dist/contexts/errorModalContext.d.ts +9 -0
  20. package/dist/contexts/errorModalContext.js +35 -0
  21. package/dist/hooks/useConsultaRfb.d.ts +9 -7
  22. package/dist/hooks/useConsultaRfb.js +14 -2
  23. package/dist/hooks/useSafeQuery.d.ts +7 -0
  24. package/dist/hooks/useSafeQuery.js +15 -0
  25. package/dist/styles/globalStyle.js +4 -4
  26. package/lib/cjs/index.js +27450 -31057
  27. package/lib/esm/index.js +27607 -31196
  28. package/package.json +1 -2
  29. package/dist/components/common/carousel.d.ts +0 -4
  30. package/dist/components/common/carousel.js +0 -19
  31. package/dist/components/dossie/carrousel/carrousel.d.ts +0 -8
  32. package/dist/components/dossie/carrousel/carrousel.js +0 -15
  33. package/dist/components/dossie/companyLogo/companyLogo.d.ts +0 -7
  34. package/dist/components/dossie/companyLogo/companyLogo.js +0 -53
  35. package/dist/components/reclameAqui/reclameAquiCarousel.d.ts +0 -17
  36. package/dist/components/reclameAqui/reclameAquiCarousel.js +0 -64
  37. package/dist/components/reclameAqui/styles.d.ts +0 -14
  38. package/dist/components/reclameAqui/styles.js +0 -31
@@ -14,9 +14,9 @@ export var Spinner = styled.div(templateObject_1 || (templateObject_1 = __makeTe
14
14
  export var ContainerSummary = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n padding: 0 20px;\n width: 100%;\n justify-content: space-between;\n @media (max-width: 768px) {\n padding: 0px;\n }\n\n @media (max-width: 992px) {\n flex-direction: column;\n }\n"], ["\n display: flex;\n padding: 0 20px;\n width: 100%;\n justify-content: space-between;\n @media (max-width: 768px) {\n padding: 0px;\n }\n\n @media (max-width: 992px) {\n flex-direction: column;\n }\n"])));
15
15
  export var ContentSummary = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: grid;\n grid-row: 1 / 8;\n grid-template-columns: repeat(4, 1fr);\n gap: 0 16px;\n\n @media (max-width: 1280px) {\n grid-template-columns: repeat(3, 1fr);\n justify-content: center;\n align-items: center;\n }\n\n @media (max-width: 768px) {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n flex-direction: row;\n width: 100%;\n }\n"], ["\n display: grid;\n grid-row: 1 / 8;\n grid-template-columns: repeat(4, 1fr);\n gap: 0 16px;\n\n @media (max-width: 1280px) {\n grid-template-columns: repeat(3, 1fr);\n justify-content: center;\n align-items: center;\n }\n\n @media (max-width: 768px) {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n flex-direction: row;\n width: 100%;\n }\n"])));
16
16
  export var FieldSummary = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n align-items: center;\n margin-bottom: 16px;\n grid-column: ", ";\n"], ["\n align-items: center;\n margin-bottom: 16px;\n grid-column: ", ";\n"])), function (props) { return (props.fullRow ? '1 / 3' : 'auto'); });
17
- export var ButtonsSummary = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n\n @media (max-width: 768px) {\n align-items: center;\n max-width: 100%;\n }\n"], ["\n\n @media (max-width: 768px) {\n align-items: center;\n max-width: 100%;\n }\n"])));
17
+ export var ButtonsSummary = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n @media (max-width: 768px) {\n align-items: center;\n max-width: 100%;\n }\n"], ["\n @media (max-width: 768px) {\n align-items: center;\n max-width: 100%;\n }\n"])));
18
18
  export var ButtonsWrapper = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: flex;\n gap: 10px;\n min-width: fit-content;\n flex-direction: column;\n\n @media print {\n display: none;\n }\n"], ["\n display: flex;\n gap: 10px;\n min-width: fit-content;\n flex-direction: column;\n\n @media print {\n display: none;\n }\n"])));
19
- export var SummaryButton = styled(Button)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n background: ", ";\n color: ", ";\n cursor: ", ";\n opacity: ", ";\n pointer-events: ", ";\n\n &:hover {\n background: ", ";\n }\n"], ["\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n background: ", ";\n color: ", ";\n cursor: ", ";\n opacity: ", ";\n pointer-events: ", ";\n\n &:hover {\n background: ", ";\n }\n"])), function (_a) {
19
+ export var SummaryButton = styled(Button)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n\n background: ", ";\n color: ", ";\n cursor: ", ";\n opacity: ", ";\n pointer-events: ", ";\n\n &:hover {\n background: ", ";\n }\n"], ["\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n\n background: ", ";\n color: ", ";\n cursor: ", ";\n opacity: ", ";\n pointer-events: ", ";\n\n &:hover {\n background: ", ";\n }\n"])), function (_a) {
20
20
  var theme = _a.theme, disabled = _a.disabled;
21
21
  return disabled ? theme.colors.cinzaClaro : theme.colors.azulCredithub;
22
22
  }, function (_a) {
@@ -19,14 +19,15 @@ import { ConsultasComplementaresContext } from '../consultasComplementares';
19
19
  import { Result, ResultContent } from '../interface/result';
20
20
  import StatusMessage from '../interface/statusMessage';
21
21
  import Section from '../section';
22
- import { RequestStatus, useQuery } from '../webservice';
22
+ import { RequestStatus } from '../webservice';
23
+ import { useSafeQuery } from '../../hooks/useSafeQuery';
23
24
  export function useRefinBoaVista(documento) {
24
25
  var _a;
25
26
  var consultasComplementaresContext = useContext(ConsultasComplementaresContext);
26
27
  var setData = useGlobalData().setData;
27
28
  var _b = useState(false), dataUpdated = _b[0], setDataUpdated = _b[1];
28
29
  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, loadingProgress = _d.loadingProgress;
30
+ var _d = useSafeQuery("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
31
  var pendencias = useMemo(function () {
31
32
  var _a;
32
33
  if ((_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.spc) {
@@ -28,14 +28,15 @@ import { ConsultasComplementaresContext } from '../consultasComplementares';
28
28
  import { Result, ResultContent } from '../interface/result';
29
29
  import StatusMessage from '../interface/statusMessage';
30
30
  import Section from '../section';
31
- import { RequestStatus, useQuery } from '../webservice';
31
+ import { RequestStatus } from '../webservice';
32
+ import { useSafeQuery } from '../../hooks/useSafeQuery';
32
33
  export function useRefinSerasa(documento) {
33
34
  var _a;
34
35
  var consultasComplementaresContext = useContext(ConsultasComplementaresContext);
35
36
  var setData = useGlobalData().setData;
36
37
  var _b = useState(false), dataUpdated = _b[0], setDataUpdated = _b[1];
37
38
  var _c = consultasComplementaresContext !== null && consultasComplementaresContext !== void 0 ? consultasComplementaresContext : {}, consultasComplementares = _c.consultasComplementares, setConsultasComplementares = _c.setConsultasComplementares;
38
- var _d = useQuery("SELECT FROM 'PROTESTOS'.'SERASA'", { documento: documento }, !!((_a = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinSerasa) === null || _a === void 0 ? void 0 : _a.consultaRealizada)), response = _d.response, isLoading = _d.isLoading, error = _d.error, loadingProgress = _d.loadingProgress;
39
+ var _d = useSafeQuery("SELECT FROM 'PROTESTOS'.'SERASA'", { documento: documento }, !!((_a = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.refinSerasa) === null || _a === void 0 ? void 0 : _a.consultaRealizada)), response = _d.response, isLoading = _d.isLoading, error = _d.error, loadingProgress = _d.loadingProgress;
39
40
  var clearValue = function (value) {
40
41
  if (!value)
41
42
  return '0';
@@ -105,16 +106,18 @@ var RefinSerasa = function (_a) {
105
106
  var totalPendencias = useMemo(function () {
106
107
  var _a, _b, _c, _d, _e;
107
108
  var resumo = (_b = (_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.dados) === null || _b === void 0 ? void 0 : _b.resumo;
108
- return (((_c = resumo === null || resumo === void 0 ? void 0 : resumo.pefin) === null || _c === void 0 ? void 0 : _c.quantidade) || 0) +
109
+ return ((((_c = resumo === null || resumo === void 0 ? void 0 : resumo.pefin) === null || _c === void 0 ? void 0 : _c.quantidade) || 0) +
109
110
  (((_d = resumo === null || resumo === void 0 ? void 0 : resumo.refin) === null || _d === void 0 ? void 0 : _d.quantidade) || 0) +
110
- (((_e = resumo === null || resumo === void 0 ? void 0 : resumo.pendencias_vencidas) === null || _e === void 0 ? void 0 : _e.quantidade) || 0);
111
+ (((_e = resumo === null || resumo === void 0 ? void 0 : resumo.pendencias_vencidas) === null || _e === void 0 ? void 0 : _e.quantidade) || 0));
111
112
  }, [response === null || response === void 0 ? void 0 : response.document]);
112
113
  var valorTotalPendencias = useMemo(function () {
113
114
  var _a, _b, _c, _d, _e, _f, _g, _h;
114
115
  var resumo = (_b = (_a = response === null || response === void 0 ? void 0 : response.document) === null || _a === void 0 ? void 0 : _a.dados) === null || _b === void 0 ? void 0 : _b.resumo;
115
- return (Number((_d = (_c = resumo === null || resumo === void 0 ? void 0 : resumo.pefin) === null || _c === void 0 ? void 0 : _c.valor_total) === null || _d === void 0 ? void 0 : _d.replace('.', '').replace(',', '.')) || 0) +
116
- (Number((_f = (_e = resumo === null || resumo === void 0 ? void 0 : resumo.refin) === null || _e === void 0 ? void 0 : _e.valor_total) === null || _f === void 0 ? void 0 : _f.replace('.', '').replace(',', '.')) || 0) +
117
- (Number((_h = (_g = resumo === null || resumo === void 0 ? void 0 : resumo.pendencias_vencidas) === null || _g === void 0 ? void 0 : _g.valor_total) === null || _h === void 0 ? void 0 : _h.replace('.', '').replace(',', '.')) || 0);
116
+ return ((Number((_d = (_c = resumo === null || resumo === void 0 ? void 0 : resumo.pefin) === null || _c === void 0 ? void 0 : _c.valor_total) === null || _d === void 0 ? void 0 : _d.replace('.', '').replace(',', '.')) ||
117
+ 0) +
118
+ (Number((_f = (_e = resumo === null || resumo === void 0 ? void 0 : resumo.refin) === null || _e === void 0 ? void 0 : _e.valor_total) === null || _f === void 0 ? void 0 : _f.replace('.', '').replace(',', '.')) ||
119
+ 0) +
120
+ (Number((_h = (_g = resumo === null || resumo === void 0 ? void 0 : resumo.pendencias_vencidas) === null || _g === void 0 ? void 0 : _g.valor_total) === null || _h === void 0 ? void 0 : _h.replace('.', '').replace(',', '.')) || 0));
118
121
  }, [response === null || response === void 0 ? void 0 : response.document]);
119
122
  var description = totalPendencias === 0
120
123
  ? 'Não há ocorrência de Pefin/Refin Serasa'
@@ -146,7 +149,9 @@ var RefinSerasa = function (_a) {
146
149
  React.createElement(AddItemField, { name: "Fiador", value: (pendencia === null || pendencia === void 0 ? void 0 : pendencia.fiador) ? 'Sim' : 'Não' }),
147
150
  React.createElement(AddItemField, { name: "Cidade", value: pendencia === null || pendencia === void 0 ? void 0 : pendencia.cidade }),
148
151
  React.createElement(AddItemField, { name: "UF", value: pendencia === null || pendencia === void 0 ? void 0 : pendencia.uf }),
149
- React.createElement(AddItemField, { name: "Org\u00E3o Emissor", value: ((_a = pendencia === null || pendencia === void 0 ? void 0 : pendencia.base_origem) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'base ii' ? 'Serasa' : 'SPC' }),
152
+ React.createElement(AddItemField, { name: "Org\u00E3o Emissor", value: ((_a = pendencia === null || pendencia === void 0 ? void 0 : pendencia.base_origem) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'base ii'
153
+ ? 'Serasa'
154
+ : 'SPC' }),
150
155
  React.createElement(AddItemField, { name: "Total de Pend\u00EAncias", value: "1" }),
151
156
  React.createElement(AddItemField, { name: "Valor Total", value: formatMoney(pendencia === null || pendencia === void 0 ? void 0 : pendencia.totalvalor) }),
152
157
  React.createElement(AddItemField, { name: "Categoria", value: pendencia === null || pendencia === void 0 ? void 0 : pendencia.categoria })));
@@ -11,20 +11,21 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import ScoreBoaVistaIcon from '../../assets/icones/scoreBoaVista';
13
13
  import { useGlobalData } from '../../contexts/globalDataContext';
14
+ import { useSafeQuery } from '../../hooks/useSafeQuery';
14
15
  import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
15
16
  import AddItemField from '../common/addItem';
16
17
  import { ConsultasComplementaresContext } from '../consultasComplementares';
17
18
  import { Result, ResultContent } from '../interface/result';
18
19
  import StatusMessage from '../interface/statusMessage';
19
20
  import Section from '../section';
20
- import { RequestStatus, useQuery } from '../webservice';
21
+ import { RequestStatus } from '../webservice';
21
22
  var ConsultaScore = function (_a) {
22
23
  var _b, _c, _d, _e, _f;
23
24
  var documento = _a.documento;
24
25
  var consultasComplementaresContext = useContext(ConsultasComplementaresContext);
25
26
  var setData = useGlobalData().setData;
26
27
  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, loadingProgress = _h.loadingProgress;
28
+ var _h = useSafeQuery("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
29
  var scoreData = (_d = response === null || response === void 0 ? void 0 : response.document) === null || _d === void 0 ? void 0 : _d.score[0];
29
30
  var scoreRef = useRef(null);
30
31
  var consultaRealizada = useMemo(function () {
@@ -17,15 +17,16 @@ import { ConsultasComplementaresContext } from '../consultasComplementares';
17
17
  import { Result, ResultContent } from '../interface/result';
18
18
  import StatusMessage from '../interface/statusMessage';
19
19
  import Section from '../section';
20
- import { RequestStatus, useQuery } from '../webservice';
20
+ import { RequestStatus } from '../webservice';
21
21
  import { isDocumentoPF } from '../../utils/string';
22
+ import { useSafeQuery } from '../../hooks/useSafeQuery';
22
23
  var ConsultaScoreSerasa = function (_a) {
23
24
  var _b, _c, _d, _e, _f, _g, _h;
24
25
  var documento = _a.documento;
25
26
  var consultasComplementaresContext = useContext(ConsultasComplementaresContext);
26
27
  var setData = useGlobalData().setData;
27
28
  var _j = useState(false), dataUpdated = _j[0], setDataUpdated = _j[1];
28
- var _k = useQuery("SELECT FROM 'ScoreSerasa'.'Consulta'", { documento: documento }, (_c = (_b = consultasComplementaresContext === null || consultasComplementaresContext === void 0 ? void 0 : consultasComplementaresContext.consultasComplementares) === null || _b === void 0 ? void 0 : _b.scoreSerasa) === null || _c === void 0 ? void 0 : _c.consultaRealizada), response = _k.response, isLoading = _k.isLoading, error = _k.error, loadingProgress = _k.loadingProgress;
29
+ var _k = useSafeQuery("SELECT FROM 'ScoreSerasa'.'Consulta'", { documento: documento }, (_c = (_b = consultasComplementaresContext === null || consultasComplementaresContext === void 0 ? void 0 : consultasComplementaresContext.consultasComplementares) === null || _b === void 0 ? void 0 : _b.scoreSerasa) === null || _c === void 0 ? void 0 : _c.consultaRealizada), response = _k.response, isLoading = _k.isLoading, error = _k.error, loadingProgress = _k.loadingProgress;
29
30
  var scoreData = (_d = response === null || response === void 0 ? void 0 : response.document) === null || _d === void 0 ? void 0 : _d.dados;
30
31
  var scoreRef = useRef(null);
31
32
  var consultaRealizada = useMemo(function () {
@@ -60,7 +60,8 @@ import { ConsultasComplementaresContext } from '../consultasComplementares';
60
60
  import { Result, ResultContent } from '../interface/result';
61
61
  import StatusMessage from '../interface/statusMessage';
62
62
  import Section from '../section';
63
- import { RequestStatus, useFetch, useQuery } from '../webservice';
63
+ import { RequestStatus, useFetch } from '../webservice';
64
+ import { useSafeQuery } from '../../hooks/useSafeQuery';
64
65
  var ResumosWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: ", ";\n flex-direction: column;\n gap: 20px;\n"], ["\n display: ", ";\n flex-direction: column;\n gap: 20px;\n"])), function (_a) {
65
66
  var _b = _a.isOpen, isOpen = _b === void 0 ? true : _b;
66
67
  return (isOpen ? 'flex' : 'none');
@@ -76,7 +77,7 @@ function ConsultaSCR(_a) {
76
77
  var _j = consultasComplementaresContext !== null && consultasComplementaresContext !== void 0 ? consultasComplementaresContext : {}, consultasComplementares = _j.consultasComplementares, setConsultasComplementares = _j.setConsultasComplementares;
77
78
  // O valor de dataBase já vem no formato "YYYY-MM" (ou o padrão "2025-01")
78
79
  var period = ((_b = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.scr) === null || _b === void 0 ? void 0 : _b.dataBase) || '2025-01';
79
- var _k = useQuery("SELECT FROM 'SCR'.'CONSULTA'", {
80
+ var _k = useSafeQuery("SELECT FROM 'SCR'.'CONSULTA'", {
80
81
  documento: documento,
81
82
  period: period
82
83
  }, !!((_c = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.scr) === null || _c === void 0 ? void 0 : _c.consultaRealizada)), response = _k.response, isLoading = _k.isLoading, error = _k.error, loadingProgress = _k.loadingProgress;
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import VeiculosIcon from '../../assets/icones/veiculos';
13
13
  import { useGlobalData } from '../../contexts/globalDataContext';
14
+ import { useSafeQuery } from '../../hooks/useSafeQuery';
14
15
  import XPathUtils from '../../utils/xpath';
15
16
  import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
16
17
  import AddItemField from '../common/addItem';
@@ -18,7 +19,7 @@ import { ConsultasComplementaresContext } from '../consultasComplementares';
18
19
  import { Result, ResultContent } from '../interface/result';
19
20
  import StatusMessage from '../interface/statusMessage';
20
21
  import Section from '../section';
21
- import { RequestStatus, useQuery } from '../webservice';
22
+ import { RequestStatus } from '../webservice';
22
23
  var Veiculos = function (_a) {
23
24
  var _b, _c;
24
25
  var documento = _a.documento;
@@ -26,7 +27,7 @@ var Veiculos = function (_a) {
26
27
  var setData = useGlobalData().setData;
27
28
  var _d = useState(false), dataUpdated = _d[0], setDataUpdated = _d[1];
28
29
  var _e = consultasComplementaresContext !== null && consultasComplementaresContext !== void 0 ? consultasComplementaresContext : {}, consultasComplementares = _e.consultasComplementares, setConsultasComplementares = _e.setConsultasComplementares;
29
- var _f = useQuery("SELECT FROM 'VEICULOS'.'CONSULTA'", { documento: documento }, !!((_b = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.veiculos) === null || _b === void 0 ? void 0 : _b.consultaRealizada)), response = _f.response, isLoading = _f.isLoading, error = _f.error, loadingProgress = _f.loadingProgress;
30
+ var _f = useSafeQuery("SELECT FROM 'VEICULOS'.'CONSULTA'", { documento: documento }, !!((_b = consultasComplementares === null || consultasComplementares === void 0 ? void 0 : consultasComplementares.veiculos) === null || _b === void 0 ? void 0 : _b.consultaRealizada)), response = _f.response, isLoading = _f.isLoading, error = _f.error, loadingProgress = _f.loadingProgress;
30
31
  var registros = useMemo(function () {
31
32
  var _a;
32
33
  var nodes = (_a = ((response === null || response === void 0 ? void 0 : response.document) &&
@@ -15,6 +15,7 @@ import Liminar from './components/liminar/liminar';
15
15
  import ConsultaScore from './components/score/scoreService';
16
16
  import ConsultaScoreSerasa from './components/scoreSerasa/scoreSerasa';
17
17
  import ConsultaSCR from './components/scr/scr';
18
+ import { ErrorModalProvider } from './contexts/errorModalContext';
18
19
  import { GlobalDataProvider } from './contexts/globalDataContext';
19
20
  import GlobalStyle from './styles/globalStyle';
20
21
  import theme from './styles/theme';
@@ -30,38 +31,39 @@ var ConsultaSimples = function (_a) {
30
31
  var _documento = _a.documento, onClickConsultarProcessoJuridico = _a.onClickConsultarProcessoJuridico, onClickQSA = _a.onClickQSA, onClickPrint = _a.onClickPrint, apiKey = _a.apiKey, onClose = _a.onClose, hasCredits = _a.hasCredits, _b = _a.initRefinBoaVista, initRefinBoaVista = _b === void 0 ? false : _b, _c = _a.initRefinSerasa, initRefinSerasa = _c === void 0 ? false : _c, _d = _a.initVeiculos, initVeiculos = _d === void 0 ? false : _d, _e = _a.printMode, printMode = _e === void 0 ? false : _e, _f = _a.isFinancial, isFinancial = _f === void 0 ? false : _f, _g = _a.tags, tags = _g === void 0 ? [] : _g;
31
32
  var documento = _documento.replace(/\D+/g, '');
32
33
  return (React.createElement(ThemeProvider, { theme: theme },
33
- React.createElement(ConsultasComplementaresProvider, { hasCredits: hasCredits, initRefinBoaVista: initRefinBoaVista, initRefinSerasa: initRefinSerasa, initVeiculos: initVeiculos },
34
- React.createElement(WebServiceProvider, { credential: apiKey },
35
- React.createElement(Queries.Dominios.Request, { data: { documento: documento, cnpj: documento } },
36
- React.createElement(Queries.Finder.Request, { data: { documento: documento } },
37
- React.createElement(FinderDependency, { documento: documento },
38
- React.createElement(Queries.ProcessosJuridicos.Request, { data: { documento: documento } },
39
- React.createElement(Queries.Liminar.Request, { data: { documento: documento } },
40
- React.createElement(Queries.LiminarCenprot.Request, { data: { documento: documento } },
41
- React.createElement(Wrapper, null,
42
- React.createElement(GlobalDataProvider, null,
43
- React.createElement(ConsultaSimplesSection, { documento: documento, onClose: onClose, onClickPrint: onClickPrint, isFinancial: isFinancial },
44
- React.createElement(ConsultaRfbProvider, { documento: documento },
45
- React.createElement(Dossie, { documento: documento, printMode: printMode }),
46
- React.createElement(Liminar, { isFinancial: isFinancial, hasCredits: hasCredits, tags: tags }),
47
- React.createElement(Addresses, { apiKey: apiKey }),
48
- React.createElement(Contacts, null),
49
- React.createElement(Partners, { onClickQSA: onClickQSA })),
50
- React.createElement(Dominios, null),
51
- React.createElement(BankAccounts, null),
52
- React.createElement(Queries.GraficosAnaliticos.Request, { data: { documento: documento } },
53
- React.createElement(ChartSystem, { documento: documento }),
54
- React.createElement(ConsultaSCR, { documento: documento }),
55
- React.createElement(RefinBoaVista, { documento: documento }),
56
- React.createElement(RefinSerasa, { documento: documento }),
57
- React.createElement(ConsultaScore, { documento: documento }),
58
- React.createElement(ConsultaScoreSerasa, { documento: documento }),
59
- React.createElement(ConsultaImoveis, { documento: documento }),
60
- React.createElement(Veiculos, { documento: documento })),
61
- React.createElement(Protestos, null),
62
- React.createElement(CCF, null),
63
- React.createElement(DividasPublicas, null),
64
- React.createElement(ProcessosJuridicos, { onClickConsultarProcessoJuridico: onClickConsultarProcessoJuridico })))))))))))),
34
+ React.createElement(ErrorModalProvider, null,
35
+ React.createElement(ConsultasComplementaresProvider, { hasCredits: hasCredits, initRefinBoaVista: initRefinBoaVista, initRefinSerasa: initRefinSerasa, initVeiculos: initVeiculos },
36
+ React.createElement(WebServiceProvider, { credential: apiKey },
37
+ React.createElement(Queries.Dominios.Request, { data: { documento: documento, cnpj: documento } },
38
+ React.createElement(Queries.Finder.Request, { data: { documento: documento } },
39
+ React.createElement(FinderDependency, { documento: documento },
40
+ React.createElement(Queries.ProcessosJuridicos.Request, { data: { documento: documento } },
41
+ React.createElement(Queries.Liminar.Request, { data: { documento: documento } },
42
+ React.createElement(Queries.LiminarCenprot.Request, { data: { documento: documento } },
43
+ React.createElement(Wrapper, null,
44
+ React.createElement(GlobalDataProvider, null,
45
+ React.createElement(ConsultaSimplesSection, { documento: documento, onClose: onClose, onClickPrint: onClickPrint, isFinancial: isFinancial },
46
+ React.createElement(ConsultaRfbProvider, { documento: documento },
47
+ React.createElement(Dossie, { documento: documento, printMode: printMode }),
48
+ React.createElement(Liminar, { isFinancial: isFinancial, hasCredits: hasCredits, tags: tags }),
49
+ React.createElement(Addresses, { apiKey: apiKey }),
50
+ React.createElement(Contacts, null),
51
+ React.createElement(Partners, { onClickQSA: onClickQSA })),
52
+ React.createElement(Dominios, null),
53
+ React.createElement(BankAccounts, null),
54
+ React.createElement(Queries.GraficosAnaliticos.Request, { data: { documento: documento } },
55
+ React.createElement(ChartSystem, { documento: documento }),
56
+ React.createElement(ConsultaSCR, { documento: documento }),
57
+ React.createElement(RefinBoaVista, { documento: documento }),
58
+ React.createElement(RefinSerasa, { documento: documento }),
59
+ React.createElement(ConsultaScore, { documento: documento }),
60
+ React.createElement(ConsultaScoreSerasa, { documento: documento }),
61
+ React.createElement(ConsultaImoveis, { documento: documento }),
62
+ React.createElement(Veiculos, { documento: documento })),
63
+ React.createElement(Protestos, null),
64
+ React.createElement(CCF, null),
65
+ React.createElement(DividasPublicas, null),
66
+ React.createElement(ProcessosJuridicos, { onClickConsultarProcessoJuridico: onClickConsultarProcessoJuridico }))))))))))))),
65
67
  React.createElement(GlobalStyle, null)));
66
68
  };
67
69
  export default ConsultaSimples;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ interface ErrorModalContextValue {
3
+ showError: (title: string, message: string) => void;
4
+ }
5
+ export declare const ErrorModalProvider: React.FC<{
6
+ children: React.ReactNode;
7
+ }>;
8
+ export declare const useErrorModal: () => ErrorModalContextValue;
9
+ export {};
@@ -0,0 +1,35 @@
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
+ // src/contexts/errorModalContext.tsx
13
+ import Modal from '../components/common/modal';
14
+ import React, { createContext, useCallback, useContext, useState } from 'react';
15
+ var ErrorModalContext = createContext({
16
+ showError: function () { }
17
+ });
18
+ export var ErrorModalProvider = function (_a) {
19
+ var children = _a.children;
20
+ var _b = useState({
21
+ open: false,
22
+ title: '',
23
+ msg: ''
24
+ }), modalState = _b[0], setModalState = _b[1];
25
+ var showError = useCallback(function (title, message) {
26
+ setModalState({ open: true, title: title, msg: message });
27
+ }, []);
28
+ return (React.createElement(ErrorModalContext.Provider, { value: { showError: showError } },
29
+ children,
30
+ React.createElement(Modal, { isOpen: modalState.open, onClose: function () { return setModalState(function (s) { return (__assign(__assign({}, s), { open: false })); }); }, title: modalState.title || 'Ops! Algo deu errado', footer: null },
31
+ modalState.msg,
32
+ React.createElement("br", null),
33
+ "Desculpe, tente novamente mais tarde.")));
34
+ };
35
+ export var useErrorModal = function () { return useContext(ErrorModalContext); };
@@ -1,7 +1,9 @@
1
- export declare const useConsultaRfb: () => Partial<{
2
- rfbResponse: Document;
3
- refetch: () => void;
4
- error: Error | null;
5
- isLoading: boolean;
6
- executeFallback: () => void;
7
- }>;
1
+ export declare const useConsultaRfb: () => {
2
+ rfbResponse?: Document | undefined;
3
+ refetch?: (() => void) | undefined;
4
+ error?: Error | null | undefined;
5
+ isLoading?: boolean | undefined;
6
+ executeFallback?: (() => void) | undefined;
7
+ updatedOnce?: boolean | undefined;
8
+ isCnpj?: boolean | undefined;
9
+ };
@@ -1,9 +1,21 @@
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 { ConsultaRfbContext } from '../components/consultaRfb';
2
13
  import { useContext } from 'react';
3
14
  export var useConsultaRfb = function () {
4
15
  var context = useContext(ConsultaRfbContext);
5
16
  if (!context) {
6
- throw new Error('useConsultasComplementares must be used within a ConsultasComplementaresProvider');
17
+ throw new Error('useConsultaRfb must be used within a ConsultaRfbProvider');
7
18
  }
8
- return context;
19
+ // força re-render quando o XML muda
20
+ return __assign({}, context);
9
21
  };
@@ -0,0 +1,7 @@
1
+ export declare function useSafeQuery<T>(query: string, params: Record<string, any>, skip?: boolean): {
2
+ response: import("../components/webservice").ParsedResponse<T> | null;
3
+ error: Error | null;
4
+ isLoading: boolean;
5
+ loadingProgress: number;
6
+ refetch: () => void;
7
+ };
@@ -0,0 +1,15 @@
1
+ // src/hooks/useSafeQuery.ts
2
+ import { useQuery } from '../components/webservice';
3
+ import { useErrorModal } from '../contexts/errorModalContext';
4
+ import { useEffect } from 'react';
5
+ export function useSafeQuery(query, params, skip) {
6
+ var showError = useErrorModal().showError;
7
+ var result = useQuery(query, params, skip);
8
+ useEffect(function () {
9
+ if (result.error) {
10
+ // aqui você pode inspecionar códigos HTTP ou mensagens específicas
11
+ showError('Erro ao consultar serviço', result.error.message);
12
+ }
13
+ }, [result.error, showError]);
14
+ return result;
15
+ }
@@ -2,8 +2,8 @@ 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 { createGlobalStyle, css } from 'styled-components';
6
- var OpenSansFont = css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n @import url('https://fonts.googleapis.com/css?family=Open%20Sans%20Condensed:300,400,500,600,700');\n"], ["\n @import url('https://fonts.googleapis.com/css?family=Open%20Sans%20Condensed:300,400,500,600,700');\n"])));
7
- var GlobalStyle = createGlobalStyle(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n * {\n ", "\n font-family: 'Open Sans Condensed';\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n\n body {\n -webkit-font-smoothing: antialiased;\n }\n\n @media print {\n button,\n [class*=\"Button\"],\n [class^=\"Button\"],\n [class*=\"btn\"],\n [class^=\"btn\"],\n .button,\n .btn {\n display: none !important;\n }\n }\n\n @keyframes highlight {\n from {\n background-color: rgba(255, 215, 0, 0.35);\n }\n to {\n background-color: transparent;\n }\n }\n\n .highlighted-process {\n animation: highlight 3s ease-out forwards !important;\n }\n\n .blue-highlighted-process {\n animation: blueHighlight 2.5s ease-in-out;\n background-color: rgba(0, 122, 255, 0.15);\n transition: background-color 0.3s ease-in-out;\n }\n\n @keyframes blueHighlight {\n from {\n background-color: rgba(0, 122, 255, 0.35);\n }\n to {\n background-color: rgba(0, 122, 255, 0.15);\n }\n }\n"], ["\n * {\n ", "\n font-family: 'Open Sans Condensed';\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n\n body {\n -webkit-font-smoothing: antialiased;\n }\n\n @media print {\n button,\n [class*=\"Button\"],\n [class^=\"Button\"],\n [class*=\"btn\"],\n [class^=\"btn\"],\n .button,\n .btn {\n display: none !important;\n }\n }\n\n @keyframes highlight {\n from {\n background-color: rgba(255, 215, 0, 0.35);\n }\n to {\n background-color: transparent;\n }\n }\n\n .highlighted-process {\n animation: highlight 3s ease-out forwards !important;\n }\n\n .blue-highlighted-process {\n animation: blueHighlight 2.5s ease-in-out;\n background-color: rgba(0, 122, 255, 0.15);\n transition: background-color 0.3s ease-in-out;\n }\n\n @keyframes blueHighlight {\n from {\n background-color: rgba(0, 122, 255, 0.35);\n }\n to {\n background-color: rgba(0, 122, 255, 0.15);\n }\n }\n"])), OpenSansFont);
5
+ // src/styles/globalStyle.tsx
6
+ import { createGlobalStyle } from 'styled-components';
7
+ var GlobalStyle = createGlobalStyle(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n /* Google Fonts \u2013 precisa vir antes de qualquer regra */\n @import url('https://fonts.googleapis.com/css2?family=Open+Sans+Condensed:wght@300;400;500;600;700&display=swap');\n\n /* Reset + fonte padr\u00E3o para toda a aplica\u00E7\u00E3o (inclui modais e portais) */\n *, *::before, *::after {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n font-family: 'Open Sans Condensed', sans-serif;\n }\n\n body {\n -webkit-font-smoothing: antialiased;\n }\n\n /* Oculta bot\u00F5es na impress\u00E3o */\n @media print {\n button,\n [class*=\"Button\"],\n [class^=\"Button\"],\n [class*=\"btn\"],\n [class^=\"btn\"],\n .button,\n .btn {\n display: none !important;\n }\n }\n\n /* Anima\u00E7\u00F5es utilit\u00E1rias */\n @keyframes highlight {\n from {\n background-color: rgba(255, 215, 0, 0.35);\n }\n to {\n background-color: transparent;\n }\n }\n\n .highlighted-process {\n animation: highlight 3s ease-out forwards !important;\n }\n\n @keyframes blueHighlight {\n from {\n background-color: rgba(0, 122, 255, 0.35);\n }\n to {\n background-color: rgba(0, 122, 255, 0.15);\n }\n }\n\n .blue-highlighted-process {\n animation: blueHighlight 2.5s ease-in-out;\n background-color: rgba(0, 122, 255, 0.15);\n transition: background-color 0.3s ease-in-out;\n }\n"], ["\n /* Google Fonts \u2013 precisa vir antes de qualquer regra */\n @import url('https://fonts.googleapis.com/css2?family=Open+Sans+Condensed:wght@300;400;500;600;700&display=swap');\n\n /* Reset + fonte padr\u00E3o para toda a aplica\u00E7\u00E3o (inclui modais e portais) */\n *, *::before, *::after {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n font-family: 'Open Sans Condensed', sans-serif;\n }\n\n body {\n -webkit-font-smoothing: antialiased;\n }\n\n /* Oculta bot\u00F5es na impress\u00E3o */\n @media print {\n button,\n [class*=\"Button\"],\n [class^=\"Button\"],\n [class*=\"btn\"],\n [class^=\"btn\"],\n .button,\n .btn {\n display: none !important;\n }\n }\n\n /* Anima\u00E7\u00F5es utilit\u00E1rias */\n @keyframes highlight {\n from {\n background-color: rgba(255, 215, 0, 0.35);\n }\n to {\n background-color: transparent;\n }\n }\n\n .highlighted-process {\n animation: highlight 3s ease-out forwards !important;\n }\n\n @keyframes blueHighlight {\n from {\n background-color: rgba(0, 122, 255, 0.35);\n }\n to {\n background-color: rgba(0, 122, 255, 0.15);\n }\n }\n\n .blue-highlighted-process {\n animation: blueHighlight 2.5s ease-in-out;\n background-color: rgba(0, 122, 255, 0.15);\n transition: background-color 0.3s ease-in-out;\n }\n"])));
8
8
  export default GlobalStyle;
9
- var templateObject_1, templateObject_2;
9
+ var templateObject_1;