@credithub/harlan-components 1.106.3 → 1.107.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.
@@ -48,13 +48,13 @@ var ClickableStatusMessage = styled(StatusMessage)(templateObject_3 || (template
48
48
  // Wrapper para o texto clicável dentro do StatusMessage
49
49
  var ClickableText = styled.span(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n cursor: pointer;\n &:hover {\n opacity: 0.85;\n }\n"], ["\n cursor: pointer;\n &:hover {\n opacity: 0.85;\n }\n"])));
50
50
  var ConsultaSimplesSection = function (_a) {
51
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
52
- var documento = _a.documento, children = _a.children, onClose = _a.onClose, onClickPrint = _a.onClickPrint, isFinancial = _a.isFinancial, ctime = _a.ctime, printMode = _a.printMode, _z = _a.tags, tags = _z === void 0 ? [] : _z, rest = __rest(_a, ["documento", "children", "onClose", "onClickPrint", "isFinancial", "ctime", "printMode", "tags"]);
51
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
52
+ var documento = _a.documento, children = _a.children, onClose = _a.onClose, onClickPrint = _a.onClickPrint, isFinancial = _a.isFinancial, ctime = _a.ctime, printMode = _a.printMode, _y = _a.tags, tags = _y === void 0 ? [] : _y, rest = __rest(_a, ["documento", "children", "onClose", "onClickPrint", "isFinancial", "ctime", "printMode", "tags"]);
53
53
  var ctx = useContext(Queries.Finder);
54
54
  var data = useGlobalData().data;
55
55
  var posthog = usePostHog().posthog;
56
56
  // Hook para observar mutações no DOM e chamar callback quando estável
57
- var _0 = usePrintWhenStable({
57
+ var _z = usePrintWhenStable({
58
58
  debounceTime: 500,
59
59
  maxWaitTime: 30000,
60
60
  onStart: function () {
@@ -65,7 +65,7 @@ var ConsultaSimplesSection = function (_a) {
65
65
  // Chama o callback externo (Harlan decide como imprimir)
66
66
  onClickPrint === null || onClickPrint === void 0 ? void 0 : onClickPrint();
67
67
  }
68
- }), printWhenStable = _0.printWhenStable, isWaiting = _0.isWaiting;
68
+ }), printWhenStable = _z.printWhenStable, isWaiting = _z.isWaiting;
69
69
  // Handler que usa o observer ao invés de imprimir diretamente
70
70
  var handlePrint = function () {
71
71
  printWhenStable();
@@ -138,7 +138,9 @@ var ConsultaSimplesSection = function (_a) {
138
138
  : '', (_q = data.liminar) === null || _q === void 0 ? void 0 : _q.error),
139
139
  makeItem('Potenciais Protestos Entrantes', (_r = data.editalData) === null || _r === void 0 ? void 0 : _r.isLoaded, ((_s = data.editalData) === null || _s === void 0 ? void 0 : _s.recentesCount)
140
140
  ? "".concat(data.editalData.recentesCount === 1 ? '1 Potencial Protesto Entrante' : "".concat(data.editalData.recentesCount, " Potenciais Protestos Entrantes"))
141
- : '', (_t = data.editalData) === null || _t === void 0 ? void 0 : _t.error)
141
+ : ''
142
+ // Não exibe erro de edital - deve falhar silenciosamente
143
+ )
142
144
  ].filter(function (e) {
143
145
  if (e.label === 'Liminar')
144
146
  return isFinancial;
@@ -153,8 +155,9 @@ var ConsultaSimplesSection = function (_a) {
153
155
  data.dividasPublicas ||
154
156
  data.processosJuridicos ||
155
157
  receitaStatus ||
156
- ((_u = data.liminar) === null || _u === void 0 ? void 0 : _u.message) === 'Encontrado' ||
157
- ((_v = data.editalData) === null || _v === void 0 ? void 0 : _v.recentesCount);
158
+ ((_t = data.liminar) === null || _t === void 0 ? void 0 : _t.message) === 'Encontrado' ||
159
+ (((_u = data.editalData) === null || _u === void 0 ? void 0 : _u.recentesCount) &&
160
+ hasOneOfTags(tags, ['diamante', 'diamante-new']));
158
161
  var statusType = isError ? 'warning' : hasPendencias ? 'error' : 'success';
159
162
  useEffect(function () {
160
163
  if (posthog && pendencias.every(function (pendencia) { return pendencia.loaded; }))
@@ -280,13 +283,13 @@ var ConsultaSimplesSection = function (_a) {
280
283
  }
281
284
  return item.text ? (item.label === 'Potenciais Protestos Entrantes' ? (React.createElement(ClickableStatusMessage, { key: item.label, type: "error", onClick: scrollToEditais, title: "Clique para ver detalhes" }, item.text)) : (React.createElement(StatusMessage, { key: item.label, type: "error" }, item.text))) : null;
282
285
  }),
283
- ((_w = data.editalData) === null || _w === void 0 ? void 0 : _w.isLoaded) &&
284
- !!((_x = data.editalData) === null || _x === void 0 ? void 0 : _x.vencidosCount) &&
286
+ ((_v = data.editalData) === null || _v === void 0 ? void 0 : _v.isLoaded) &&
287
+ !!((_w = data.editalData) === null || _w === void 0 ? void 0 : _w.vencidosCount) &&
285
288
  data.editalData.vencidosCount > 0 &&
286
289
  hasOneOfTags(tags, ['diamante', 'diamante-new']) && (React.createElement(StatusMessage, { type: "error" },
287
290
  React.createElement(ClickableText, { onClick: scrollToEditais, title: "Clique para ver detalhes" },
288
291
  "Cart\u00F3rio com dificuldade para intimar",
289
- ((_y = data.editalData) === null || _y === void 0 ? void 0 : _y.dataEditalMaisAntigo) &&
292
+ ((_x = data.editalData) === null || _x === void 0 ? void 0 : _x.dataEditalMaisAntigo) &&
290
293
  " desde o: ".concat(data.editalData.dataEditalMaisAntigo))))), onClose: onClose, icon: ConsultaSimplesIcon, variant: isLoading ? 'loading' : 'default', ctx: ctx, loadingProps: {
291
294
  percentage: (ctx === null || ctx === void 0 ? void 0 : ctx.progress) || 0,
292
295
  hidden: !isLoading
@@ -44,26 +44,30 @@ var Edital = function (_a) {
44
44
  var hasAccess = useMemo(function () {
45
45
  return hasOneOfTags(tags, ['diamante', 'diamante-new']);
46
46
  }, [tags]);
47
- var EDITAL_ERROR_SUMMARY = 'Falha ao consultar intimações de protestos entrantes.';
47
+ // const EDITAL_ERROR_SUMMARY =
48
+ // 'Falha ao consultar intimações de protestos entrantes.';
48
49
  // Atualiza globalData quando há erro
49
50
  useEffect(function () {
50
- if (!ctx)
51
+ if (!hasAccess || !ctx)
51
52
  return;
52
- if (ctx.type === RequestStatus.Error) {
53
- setData(function (prevState) { return (__assign(__assign({}, prevState), { editalData: {
54
- isLoaded: true,
55
- error: { summary: EDITAL_ERROR_SUMMARY }
56
- } })); });
57
- return;
58
- }
59
- if (ctx.type === RequestStatus.Empty) {
53
+ // if (ctx.type === RequestStatus.Error) {
54
+ // setData((prevState: GlobalState) => ({
55
+ // ...prevState,
56
+ // editalData: {
57
+ // isLoaded: true,
58
+ // error: { summary: EDITAL_ERROR_SUMMARY }
59
+ // }
60
+ // }));
61
+ // return;
62
+ // }
63
+ if (ctx.type === RequestStatus.Empty || ctx.type === RequestStatus.Error) {
60
64
  setData(function (prevState) { return (__assign(__assign({}, prevState), { editalData: { isLoaded: true } })); });
61
65
  return;
62
66
  }
63
- }, [ctx, setData]);
67
+ }, [ctx, setData, hasAccess]);
64
68
  // Atualiza globalData com os dados do edital
65
69
  useEffect(function () {
66
- if (dataUpdated || !ctx.document)
70
+ if (!hasAccess || dataUpdated || !ctx.document)
67
71
  return;
68
72
  var response = ctx.document;
69
73
  var editais = (response === null || response === void 0 ? void 0 : response.editalEletronico) || [];
@@ -131,15 +135,15 @@ var Edital = function (_a) {
131
135
  : undefined
132
136
  } })); });
133
137
  setDataUpdated(true);
134
- }, [ctx.document, dataUpdated, setData]);
138
+ }, [ctx.document, dataUpdated, setData, hasAccess]);
135
139
  // Marca como carregando quando inicia requisição
136
140
  useEffect(function () {
137
- if (!ctx)
141
+ if (!hasAccess || !ctx)
138
142
  return;
139
143
  if (ctx.type === RequestStatus.Loading) {
140
144
  setData(function (prevState) { return (__assign(__assign({}, prevState), { editalData: __assign(__assign({}, (prevState.editalData || {})), { isLoaded: false }) })); });
141
145
  }
142
- }, [ctx, setData]);
146
+ }, [ctx, setData, hasAccess]);
143
147
  var handleSuccess = function (response) {
144
148
  var _a, _b, _c, _d;
145
149
  var editais = (response === null || response === void 0 ? void 0 : response.editalEletronico) || [];
@@ -26,6 +26,7 @@ import { PrintModeProvider } from './contexts/printModeContext';
26
26
  import useToggle from './hooks/useToggle';
27
27
  import GlobalStyle from './styles/globalStyle';
28
28
  import theme from './styles/theme';
29
+ import { hasOneOfTags } from './utils/tags';
29
30
  Chart.register.apply(Chart, registerables);
30
31
  var Wrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-family: 'Open Sans Condensed';\n display: flex;\n flex-direction: column;\n gap: 20px;\n margin-bottom: 20px;\n\n * {\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n }\n\n @media print {\n @page {\n size: auto;\n margin: 5mm;\n }\n }\n"], ["\n font-family: 'Open Sans Condensed';\n display: flex;\n flex-direction: column;\n gap: 20px;\n margin-bottom: 20px;\n\n * {\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n }\n\n @media print {\n @page {\n size: auto;\n margin: 5mm;\n }\n }\n"])));
31
32
  var FinderDependency = function (_a) {
@@ -60,12 +61,22 @@ var HasCreditsVerification = function (_a) {
60
61
  React.createElement("a", { href: "https://painel.credithub.com.br/?apiKey=".concat(apiKey), target: "_blank", rel: "noopener noreferrer" }, "painel.credithub.com.br"),
61
62
  ".")));
62
63
  };
64
+ // Conditional wrapper for Edital query based on diamante tags
65
+ var EditalQueryWrapper = function (_a) {
66
+ var hasDiamanteAccess = _a.hasDiamanteAccess, documento = _a.documento, children = _a.children;
67
+ if (hasDiamanteAccess) {
68
+ return (React.createElement(Queries.Edital.Request, { data: { documento: documento } }, children));
69
+ }
70
+ return React.createElement(React.Fragment, null, children);
71
+ };
63
72
  var ConsultaSimples = function (_a) {
64
73
  var _b, _c, _d;
65
74
  var _documento = _a.documento, onClickConsultarProcessoJuridico = _a.onClickConsultarProcessoJuridico, onClickQSA = _a.onClickQSA, onClickPrint = _a.onClickPrint, apiKey = _a.apiKey, queryParams = _a.queryParams, onClose = _a.onClose, hasCredits = _a.hasCredits, _e = _a.initRefinBoaVista, initRefinBoaVista = _e === void 0 ? false : _e, _f = _a.initRefinSerasa, initRefinSerasa = _f === void 0 ? false : _f, _g = _a.initVeiculos, initVeiculos = _g === void 0 ? false : _g, _h = _a.printMode, printMode = _h === void 0 ? false : _h, _j = _a.isFinancial, isFinancial = _j === void 0 ? false : _j, _k = _a.tags, tags = _k === void 0 ? [] : _k, posthog = _a.posthog;
66
75
  var documento = _documento.replace(/\D+/g, '');
67
76
  // extrai CTIME (case-insensitive) dos urlData para repassar como prop
68
77
  var ctimeProp = (_c = (_b = queryParams === null || queryParams === void 0 ? void 0 : queryParams.urlData) === null || _b === void 0 ? void 0 : _b.CTIME) !== null && _c !== void 0 ? _c : (_d = queryParams === null || queryParams === void 0 ? void 0 : queryParams.urlData) === null || _d === void 0 ? void 0 : _d.ctime;
78
+ // Check if user has diamante access
79
+ var hasDiamanteAccess = hasOneOfTags(tags, ['diamante', 'diamante-new']);
69
80
  return (React.createElement(ThemeProvider, { theme: theme },
70
81
  React.createElement(ErrorModalProvider, null,
71
82
  React.createElement(PostHogProvider, { posthog: posthog },
@@ -79,7 +90,7 @@ var ConsultaSimples = function (_a) {
79
90
  React.createElement(Queries.ProcessosJuridicos.Request, { data: { documento: documento } },
80
91
  React.createElement(Queries.Liminar.Request, { data: { documento: documento } },
81
92
  React.createElement(Queries.LiminarCenprot.Request, { data: { documento: documento } },
82
- React.createElement(Queries.Edital.Request, { data: { documento: documento } },
93
+ React.createElement(EditalQueryWrapper, { hasDiamanteAccess: hasDiamanteAccess, documento: documento },
83
94
  React.createElement(Wrapper, null,
84
95
  React.createElement(GlobalDataProvider, null,
85
96
  React.createElement(ConsultaSimplesSection, { documento: documento, onClose: onClose, onClickPrint: onClickPrint, isFinancial: isFinancial, ctime: ctimeProp, printMode: printMode, tags: tags },