@credithub/harlan-components 1.104.1 → 1.106.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.
@@ -7,7 +7,11 @@ var useChartData = function (consultaSerasa, consultaBoaVista) {
7
7
  var _b = useState(null), data = _b[0], setData = _b[1];
8
8
  var _c = useState(null), errorState = _c[0], setErrorState = _c[1];
9
9
  var _d = useState(0), loadingProgress = _d[0], _setLoadingProgress = _d[1];
10
+ var _e = useState(false), isProcessing = _e[0], setIsProcessing = _e[1];
11
+ var _f = useState(false), dataReady = _f[0], setDataReady = _f[1];
10
12
  var lastProgress = useRef(0);
13
+ var lastProcessedDocument = useRef(null);
14
+ var processingTimeout = useRef(null);
11
15
  var ctxHistory = useContext(Queries.GraficosAnaliticos);
12
16
  var ctxProtestos = useContext(Queries.Protestos);
13
17
  var ctxCCF = useContext(Queries.CCF);
@@ -36,15 +40,22 @@ var useChartData = function (consultaSerasa, consultaBoaVista) {
36
40
  (_d = ctxProcessos.progress) !== null && _d !== void 0 ? _d : 0
37
41
  ];
38
42
  var avg = parts.reduce(function (sum, p) { return sum + p; }, 0) / parts.length;
39
- if (avg === 100 || Math.abs(avg - lastProgress.current) >= 10) {
40
- lastProgress.current = avg;
41
- _setLoadingProgress(avg);
43
+ // Se está processando dados, mostra 95% para indicar processamento
44
+ var adjustedProgress = avg;
45
+ if (isProcessing && avg === 100) {
46
+ adjustedProgress = 95;
47
+ }
48
+ if (adjustedProgress === 100 ||
49
+ Math.abs(adjustedProgress - lastProgress.current) >= 10) {
50
+ lastProgress.current = adjustedProgress;
51
+ _setLoadingProgress(adjustedProgress);
42
52
  }
43
53
  }, [
44
54
  ctxHistory.progress,
45
55
  ctxProtestos.progress,
46
56
  ctxCCF.progress,
47
- ctxProcessos.progress
57
+ ctxProcessos.progress,
58
+ isProcessing
48
59
  ]);
49
60
  var lastComplementary = useRef({
50
61
  serasa: null,
@@ -62,35 +73,102 @@ var useChartData = function (consultaSerasa, consultaBoaVista) {
62
73
  }
63
74
  // eslint-disable-next-line react-hooks/exhaustive-deps
64
75
  }, [consultaSerasa, consultaBoaVista]);
76
+ // Verifica se todos os contextos necessários terminaram de carregar
77
+ var allContextsReady = useMemo(function () {
78
+ return (ctxHistory.type !== RequestStatus.Loading &&
79
+ ctxProtestos.type !== RequestStatus.Loading &&
80
+ ctxCCF.type !== RequestStatus.Loading &&
81
+ ctxProcessos.type !== RequestStatus.Loading &&
82
+ ctxHistory.type === RequestStatus.Success &&
83
+ ctxProtestos.type === RequestStatus.Success &&
84
+ ctxCCF.type === RequestStatus.Success &&
85
+ ctxProcessos.type === RequestStatus.Success);
86
+ }, [ctxHistory.type, ctxProtestos.type, ctxCCF.type, ctxProcessos.type]);
65
87
  useEffect(function () {
66
88
  var _a;
67
- if (ctxHistory.type === RequestStatus.Loading) {
89
+ // Limpa timeout anterior se existir
90
+ if (processingTimeout.current) {
91
+ clearTimeout(processingTimeout.current);
92
+ processingTimeout.current = null;
93
+ }
94
+ // Reset quando qualquer contexto volta para Loading
95
+ if (ctxHistory.type === RequestStatus.Loading ||
96
+ ctxProtestos.type === RequestStatus.Loading ||
97
+ ctxCCF.type === RequestStatus.Loading ||
98
+ ctxProcessos.type === RequestStatus.Loading) {
99
+ setDataReady(false);
68
100
  setErrorState(null);
101
+ setIsProcessing(false);
102
+ return;
69
103
  }
70
- else if (ctxHistory.type === RequestStatus.Error) {
104
+ if (ctxHistory.type === RequestStatus.Error) {
71
105
  setErrorState(((_a = ctxHistory.error) === null || _a === void 0 ? void 0 : _a.message) || 'Erro ao consultar histórico');
106
+ setIsProcessing(false);
107
+ setDataReady(false);
108
+ lastProcessedDocument.current = null;
109
+ return;
72
110
  }
73
- else if (ctxHistory.type === RequestStatus.Success &&
74
- ctxHistory.document) {
75
- try {
76
- var parsed = JSON.parse(ctxHistory.document);
77
- parsed.protestosCategory = dadosProtestos;
78
- var processed = processData(structuredClone(parsed), quantidadeProcessos);
79
- setData(processed);
80
- }
81
- catch (_b) {
82
- setErrorState('Erro ao processar os dados');
111
+ // processa quando TODOS os contextos estiverem prontos
112
+ if (allContextsReady && ctxHistory.document) {
113
+ var documentSnapshot_1 = ctxHistory.document;
114
+ // Evita processar o mesmo documento múltiplas vezes
115
+ if (lastProcessedDocument.current === documentSnapshot_1) {
116
+ return;
83
117
  }
118
+ // Marca como processando
119
+ setIsProcessing(true);
120
+ setDataReady(false);
121
+ lastProcessedDocument.current = documentSnapshot_1;
122
+ // Usa setTimeout para permitir que a UI atualize o estado de loading
123
+ processingTimeout.current = setTimeout(function () {
124
+ try {
125
+ if (!documentSnapshot_1) {
126
+ throw new Error('Document is undefined');
127
+ }
128
+ var parsed = JSON.parse(documentSnapshot_1);
129
+ parsed.protestosCategory = dadosProtestos;
130
+ var processed = processData(structuredClone(parsed), quantidadeProcessos);
131
+ setData(processed);
132
+ setIsProcessing(false);
133
+ setDataReady(true);
134
+ // Garante que o progresso chegue a 100% quando dados estão prontos
135
+ _setLoadingProgress(100);
136
+ }
137
+ catch (error) {
138
+ console.error('[useChartData] Erro ao processar dados:', error);
139
+ setErrorState('Erro ao processar os dados');
140
+ setIsProcessing(false);
141
+ setDataReady(false);
142
+ }
143
+ processingTimeout.current = null;
144
+ }, 0);
84
145
  }
85
146
  }, [
86
147
  ctxHistory.type,
148
+ ctxProtestos.type,
149
+ ctxCCF.type,
150
+ ctxProcessos.type,
87
151
  ctxHistory.document,
88
152
  dadosProtestos,
89
- quantidadeProcessos
153
+ quantidadeProcessos,
154
+ allContextsReady
90
155
  ]);
156
+ // Cleanup do timeout quando componente desmonta
157
+ useEffect(function () {
158
+ return function () {
159
+ if (processingTimeout.current) {
160
+ clearTimeout(processingTimeout.current);
161
+ processingTimeout.current = null;
162
+ }
163
+ };
164
+ }, []);
165
+ // Verifica se está carregando - aguarda TODOS os contextos necessários terminarem
166
+ // E aguarda o processamento E renderização dos dados estar completo
167
+ // Só sai de loading quando dataReady === true (todos os contextos prontos + dados processados)
168
+ var isLoading = !dataReady || isProcessing || !allContextsReady;
91
169
  return {
92
170
  data: data,
93
- isLoading: ctxHistory.type === RequestStatus.Loading,
171
+ isLoading: isLoading,
94
172
  error: errorState,
95
173
  refetch: ctxHistory.refetch,
96
174
  loadingProgress: loadingProgress
@@ -18,7 +18,7 @@ var Trigger = styled.span(templateObject_2 || (templateObject_2 = __makeTemplate
18
18
  ? "\n position: absolute;\n right: 0;\n top: 50%;\n transform: translate(100%, -50%);\n "
19
19
  : '';
20
20
  });
21
- var Bubble = styled.span(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n visibility: ", ";\n pointer-events: ", ";\n opacity: ", ";\n transform: ", ";\n\n width: 380px;\n max-width: 90vw;\n background-color: ", ";\n color: ", ";\n text-align: left;\n border-radius: 10px;\n padding: 10px 16px 16px 16px;\n font-size: 15px;\n font-weight: 500;\n line-height: 1.35;\n position: absolute;\n z-index: 10;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);\n transition:\n opacity 0.3s ease-in-out,\n transform 0.3s ease-in-out;\n\n ", "\n\n @media screen and (max-width: 768px) {\n font-size: 14px;\n padding: 10px 14px 14px 14px;\n }\n"], ["\n visibility: ", ";\n pointer-events: ", ";\n opacity: ", ";\n transform: ", ";\n\n width: 380px;\n max-width: 90vw;\n background-color: ", ";\n color: ", ";\n text-align: left;\n border-radius: 10px;\n padding: 10px 16px 16px 16px;\n font-size: 15px;\n font-weight: 500;\n line-height: 1.35;\n position: absolute;\n z-index: 10;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);\n transition:\n opacity 0.3s ease-in-out,\n transform 0.3s ease-in-out;\n\n ", "\n\n @media screen and (max-width: 768px) {\n font-size: 14px;\n padding: 10px 14px 14px 14px;\n }\n"])), function (_a) {
21
+ var Bubble = styled.span(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n visibility: ", ";\n pointer-events: ", ";\n opacity: ", ";\n transform: ", ";\n\n width: 380px;\n max-width: 90vw;\n background-color: ", ";\n color: ", ";\n text-align: left;\n border-radius: 10px;\n padding: 10px 16px 16px 16px;\n font-size: 15px;\n font-weight: 500;\n line-height: 1.35;\n position: absolute;\n z-index: 9999;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);\n transition:\n opacity 0.3s ease-in-out,\n transform 0.3s ease-in-out;\n\n ", "\n\n @media screen and (max-width: 768px) {\n font-size: 14px;\n padding: 10px 14px 14px 14px;\n }\n"], ["\n visibility: ", ";\n pointer-events: ", ";\n opacity: ", ";\n transform: ", ";\n\n width: 380px;\n max-width: 90vw;\n background-color: ", ";\n color: ", ";\n text-align: left;\n border-radius: 10px;\n padding: 10px 16px 16px 16px;\n font-size: 15px;\n font-weight: 500;\n line-height: 1.35;\n position: absolute;\n z-index: 9999;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);\n transition:\n opacity 0.3s ease-in-out,\n transform 0.3s ease-in-out;\n\n ", "\n\n @media screen and (max-width: 768px) {\n font-size: 14px;\n padding: 10px 14px 14px 14px;\n }\n"])), function (_a) {
22
22
  var $visible = _a.$visible;
23
23
  return ($visible ? 'visible' : 'hidden');
24
24
  }, function (_a) {
@@ -25,6 +25,7 @@ var __rest = (this && this.__rest) || function (s, e) {
25
25
  return t;
26
26
  };
27
27
  import ConsultaSimplesIcon from '../../assets/icones/consultaSimples';
28
+ import Tooltip from '../../components/common/tooltip';
28
29
  import { useGlobalData } from '../../contexts/globalDataContext';
29
30
  import { usePostHog } from '../../contexts/PostHogContext';
30
31
  import usePrintWhenStable from '../../hooks/usePrintWhenStable';
@@ -33,7 +34,7 @@ import { formatMoney } from '../../utils/number';
33
34
  import { formatDocument } from '../../utils/string';
34
35
  import { hasOneOfTags } from '../../utils/tags';
35
36
  import { format } from 'date-fns';
36
- import { WarningCircle } from 'phosphor-react';
37
+ import { Info, WarningCircle } from 'phosphor-react';
37
38
  import React, { useContext, useEffect } from 'react';
38
39
  import styled, { keyframes } from 'styled-components';
39
40
  import Section from '../interface/section';
@@ -43,14 +44,18 @@ import { Queries, RequestStatus } from '../webservice';
43
44
  var spin = keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n"], ["\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n"])));
44
45
  // Componente Spinner sutil
45
46
  var Spinner = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n border: 1px solid rgba(0, 0, 0, 0.1);\n border-left-color: #222;\n border-radius: 50%;\n width: 9px;\n height: 9px;\n animation: ", " 1s linear infinite;\n margin-right: 8px;\n display: inline-block;\n vertical-align: middle;\n"], ["\n border: 1px solid rgba(0, 0, 0, 0.1);\n border-left-color: #222;\n border-radius: 50%;\n width: 9px;\n height: 9px;\n animation: ", " 1s linear infinite;\n margin-right: 8px;\n display: inline-block;\n vertical-align: middle;\n"])), spin);
47
+ // StatusMessage clicável para scroll
48
+ var ClickableStatusMessage = styled(StatusMessage)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n cursor: pointer;\n transition: opacity 0.2s ease;\n position: relative;\n\n &:hover {\n opacity: 0.85;\n }\n\n @media print {\n cursor: default;\n }\n"], ["\n cursor: pointer;\n transition: opacity 0.2s ease;\n position: relative;\n\n &:hover {\n opacity: 0.85;\n }\n\n @media print {\n cursor: default;\n }\n"])));
49
+ // Wrapper para o texto clicável dentro do StatusMessage
50
+ 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"])));
46
51
  var ConsultaSimplesSection = function (_a) {
47
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
48
- var documento = _a.documento, children = _a.children, onClose = _a.onClose, onClickPrint = _a.onClickPrint, isFinancial = _a.isFinancial, ctime = _a.ctime, printMode = _a.printMode, _w = _a.tags, tags = _w === void 0 ? [] : _w, rest = __rest(_a, ["documento", "children", "onClose", "onClickPrint", "isFinancial", "ctime", "printMode", "tags"]);
52
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
53
+ 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"]);
49
54
  var ctx = useContext(Queries.Finder);
50
55
  var data = useGlobalData().data;
51
56
  var posthog = usePostHog().posthog;
52
57
  // Hook para observar mutações no DOM e chamar callback quando estável
53
- var _x = usePrintWhenStable({
58
+ var _0 = usePrintWhenStable({
54
59
  debounceTime: 500,
55
60
  maxWaitTime: 30000,
56
61
  onStart: function () {
@@ -61,7 +66,7 @@ var ConsultaSimplesSection = function (_a) {
61
66
  // Chama o callback externo (Harlan decide como imprimir)
62
67
  onClickPrint === null || onClickPrint === void 0 ? void 0 : onClickPrint();
63
68
  }
64
- }), printWhenStable = _x.printWhenStable, isWaiting = _x.isWaiting;
69
+ }), printWhenStable = _0.printWhenStable, isWaiting = _0.isWaiting;
65
70
  // Handler que usa o observer ao invés de imprimir diretamente
66
71
  var handlePrint = function () {
67
72
  printWhenStable();
@@ -132,8 +137,8 @@ var ConsultaSimplesSection = function (_a) {
132
137
  data.liminar.message === 'Encontrado')
133
138
  ? 'Indício de Liminar'
134
139
  : '', (_q = data.liminar) === null || _q === void 0 ? void 0 : _q.error),
135
- makeItem('Potenciais Protestos Futuros', (_r = data.editalData) === null || _r === void 0 ? void 0 : _r.isLoaded, ((_s = data.editalData) === null || _s === void 0 ? void 0 : _s.totalEditais)
136
- ? "".concat(data.editalData.totalEditais === 1 ? '1 Potencial Protesto Futuro' : "".concat(data.editalData.totalEditais, " Potenciais Protestos Futuros"))
140
+ 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)
141
+ ? "".concat(data.editalData.recentesCount === 1 ? '1 Potencial Protesto Entrante' : "".concat(data.editalData.recentesCount, " Potenciais Protestos Entrantes"))
137
142
  : '', (_t = data.editalData) === null || _t === void 0 ? void 0 : _t.error)
138
143
  ].filter(function (e) {
139
144
  if (e.label === 'Liminar')
@@ -150,7 +155,7 @@ var ConsultaSimplesSection = function (_a) {
150
155
  data.processosJuridicos ||
151
156
  receitaStatus ||
152
157
  ((_u = data.liminar) === null || _u === void 0 ? void 0 : _u.message) === 'Encontrado' ||
153
- ((_v = data.editalData) === null || _v === void 0 ? void 0 : _v.totalEditais);
158
+ ((_v = data.editalData) === null || _v === void 0 ? void 0 : _v.recentesCount);
154
159
  var statusType = isError ? 'warning' : hasPendencias ? 'error' : 'success';
155
160
  useEffect(function () {
156
161
  if (posthog && pendencias.every(function (pendencia) { return pendencia.loaded; }))
@@ -162,6 +167,98 @@ var ConsultaSimplesSection = function (_a) {
162
167
  }); })
163
168
  });
164
169
  }, [posthog, pendencias]);
170
+ // Scroll to Editais section
171
+ var scrollToEditais = function () {
172
+ // Strategy 1: Try by ID (most reliable)
173
+ var editalSectionById = document.getElementById('editais-section');
174
+ if (editalSectionById) {
175
+ editalSectionById.scrollIntoView({
176
+ behavior: 'smooth',
177
+ block: 'start'
178
+ });
179
+ return;
180
+ }
181
+ // Strategy 2: Find by title text (updated title)
182
+ var headings = Array.from(document.querySelectorAll('h1, h2, h3, h4, h5, h6'));
183
+ var editalHeading = headings.find(function (heading) {
184
+ var _a, _b;
185
+ return ((_a = heading.textContent) === null || _a === void 0 ? void 0 : _a.includes('Protestos Entrantes')) ||
186
+ ((_b = heading.textContent) === null || _b === void 0 ? void 0 : _b.includes('Intimações por Edital Eletrônico'));
187
+ });
188
+ if (editalHeading) {
189
+ // Scroll to parent section/container
190
+ var section = editalHeading.closest('section') ||
191
+ editalHeading.closest('[role="region"]') ||
192
+ editalHeading.closest('div[class*="Section"]') ||
193
+ editalHeading.parentElement;
194
+ if (section) {
195
+ section.scrollIntoView({
196
+ behavior: 'smooth',
197
+ block: 'start'
198
+ });
199
+ return;
200
+ }
201
+ }
202
+ // Strategy 3: Search all sections and match by content
203
+ var allSections = Array.from(document.querySelectorAll('section, [role="region"], div[class*="Section"]'));
204
+ var editalSection = allSections.find(function (section) {
205
+ var _a, _b;
206
+ return ((_a = section.textContent) === null || _a === void 0 ? void 0 : _a.includes('Protestos Entrantes')) ||
207
+ ((_b = section.textContent) === null || _b === void 0 ? void 0 : _b.includes('Intimações por Edital Eletrônico'));
208
+ });
209
+ if (editalSection) {
210
+ editalSection.scrollIntoView({
211
+ behavior: 'smooth',
212
+ block: 'start'
213
+ });
214
+ }
215
+ else {
216
+ console.warn('Seção Editais não encontrada para scroll');
217
+ }
218
+ };
219
+ // Render tooltip content for expired editais
220
+ var renderVencidosTooltip = function () {
221
+ var _a;
222
+ var vencidosResumo = ((_a = data.editalData) === null || _a === void 0 ? void 0 : _a.vencidosResumo) || [];
223
+ if (vencidosResumo.length === 0)
224
+ return null;
225
+ var itemsToShow = vencidosResumo.slice(0, 5);
226
+ var remaining = vencidosResumo.length - 5;
227
+ return (React.createElement("div", null,
228
+ React.createElement("div", { style: { fontWeight: 600, marginBottom: '10px', fontSize: '14px' } },
229
+ "Editais vencidos (",
230
+ vencidosResumo.length,
231
+ "):"),
232
+ itemsToShow.map(function (item, index) { return (React.createElement("div", { key: index, style: {
233
+ marginBottom: '10px',
234
+ paddingBottom: '8px',
235
+ borderBottom: index < itemsToShow.length - 1 ? '1px solid #e0e0e0' : 'none'
236
+ } },
237
+ React.createElement("div", { style: { fontSize: '13px', marginBottom: '3px' } },
238
+ React.createElement("strong", null,
239
+ "#",
240
+ item.id),
241
+ " \u2014 ",
242
+ item.cartorio),
243
+ React.createElement("div", { style: { fontSize: '12px', color: '#666' } },
244
+ item.dataCadastro,
245
+ " \u2022 ",
246
+ item.diasUteis,
247
+ " dias \u00FAteis"),
248
+ item.devedor && (React.createElement("div", { style: { fontSize: '12px', color: '#666' } },
249
+ item.devedor,
250
+ item.documentoMascarado && " \u2022 ".concat(item.documentoMascarado))))); }),
251
+ remaining > 0 && (React.createElement("div", { style: {
252
+ fontSize: '12px',
253
+ fontStyle: 'italic',
254
+ color: '#999',
255
+ marginTop: '8px'
256
+ } },
257
+ "+ ",
258
+ remaining,
259
+ " edita",
260
+ remaining === 1 ? 'l' : 'is'))));
261
+ };
165
262
  return (React.createElement(Section, __assign({ title: "Consulta Simples", subtitle: "Consulta de informa\u00E7\u00F5es do documento.", onClickPrint: handlePrint, isPrintLoading: isWaiting, printLoadingMessage: "O sistema est\u00E1 verificando se todas as consultas foram conclu\u00EDdas. Por favor, aguarde...", description: React.createElement(React.Fragment, null,
166
263
  ctimeDate ? (React.createElement(StatusMessage, { type: "warning" },
167
264
  React.createElement(WarningCircle, { weight: "fill", size: 18, color: theme.colors.cinzaEscuro, style: { marginRight: 6, verticalAlign: 'text-bottom' } }),
@@ -182,11 +279,20 @@ var ConsultaSimplesSection = function (_a) {
182
279
  if ((_a = item.error) === null || _a === void 0 ? void 0 : _a.summary) {
183
280
  return (React.createElement(StatusMessage, { key: item.label, type: "warning" }, item.error.summary));
184
281
  }
185
- return item.text ? (React.createElement(StatusMessage, { key: item.label, type: "error" }, item.text)) : null;
186
- })), onClose: onClose, icon: ConsultaSimplesIcon, variant: isLoading ? 'loading' : 'default', ctx: ctx, loadingProps: {
282
+ 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;
283
+ }),
284
+ ((_w = data.editalData) === null || _w === void 0 ? void 0 : _w.isLoaded) &&
285
+ ((_x = data.editalData) === null || _x === void 0 ? void 0 : _x.vencidosCount) &&
286
+ data.editalData.vencidosCount > 0 &&
287
+ hasOneOfTags(tags, ['diamante', 'diamante-new']) && (React.createElement(StatusMessage, { type: "error" },
288
+ React.createElement(ClickableText, { onClick: scrollToEditais, title: "Clique para ver detalhes" },
289
+ "Cart\u00F3rio com dificuldade para intimar",
290
+ ((_y = data.editalData) === null || _y === void 0 ? void 0 : _y.dataEditalMaisAntigo) &&
291
+ " desde o: ".concat(data.editalData.dataEditalMaisAntigo)),
292
+ React.createElement(Tooltip, { icon: React.createElement(Info, { size: 16, weight: "fill", style: { marginLeft: 6, verticalAlign: 'middle' } }), content: renderVencidosTooltip(), placement: "left", float: true })))), onClose: onClose, icon: ConsultaSimplesIcon, variant: isLoading ? 'loading' : 'default', ctx: ctx, loadingProps: {
187
293
  percentage: (ctx === null || ctx === void 0 ? void 0 : ctx.progress) || 0,
188
294
  hidden: !isLoading
189
295
  }, printMode: printMode }, rest), children));
190
296
  };
191
297
  export default ConsultaSimplesSection;
192
- var templateObject_1, templateObject_2;
298
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
@@ -1,3 +1,7 @@
1
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
2
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
3
+ return cooked;
4
+ };
1
5
  var __assign = (this && this.__assign) || function () {
2
6
  __assign = Object.assign || function(t) {
3
7
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -9,19 +13,33 @@ var __assign = (this && this.__assign) || function () {
9
13
  };
10
14
  return __assign.apply(this, arguments);
11
15
  };
16
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
17
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
18
+ if (ar || !(i in from)) {
19
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
20
+ ar[i] = from[i];
21
+ }
22
+ }
23
+ return to.concat(ar || Array.prototype.slice.call(from));
24
+ };
12
25
  import EditalIcon from '../../assets/icones/edital';
13
26
  import { useGlobalData } from '../../contexts/globalDataContext';
27
+ import { calculateBusinessDays, parseEditalDate } from '../../utils/businessDays';
28
+ import { formatDocument } from '../../utils/string';
14
29
  import { hasOneOfTags } from '../../utils/tags';
15
30
  import React, { useContext, useEffect, useMemo, useState } from 'react';
31
+ import styled from 'styled-components';
16
32
  import StatusMessage from '../interface/statusMessage';
17
33
  import Section from '../section';
18
34
  import { Queries, RequestStatus } from '../webservice';
19
35
  import EditalList from './editalList';
36
+ var BtnWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n @media print {\n display: none;\n }\n"], ["\n @media print {\n display: none;\n }\n"])));
20
37
  var Edital = function (_a) {
21
38
  var _b = _a.isFinancial, isFinancial = _b === void 0 ? false : _b, _c = _a.tags, tags = _c === void 0 ? [] : _c;
22
39
  var ctx = useContext(Queries.Edital);
23
40
  var _d = useGlobalData(), globalData = _d.data, setData = _d.setData;
24
41
  var _e = useState(false), dataUpdated = _e[0], setDataUpdated = _e[1];
42
+ var _f = useState(false), showExpired = _f[0], setShowExpired = _f[1];
25
43
  // Verificar se o usuário tem acesso ao plano diamante
26
44
  var hasAccess = useMemo(function () {
27
45
  return hasOneOfTags(tags, ['diamante', 'diamante-new']);
@@ -48,10 +66,67 @@ var Edital = function (_a) {
48
66
  var response = ctx.document;
49
67
  var editais = (response === null || response === void 0 ? void 0 : response.editalEletronico) || [];
50
68
  var total = editais.length;
69
+ // Classify editais by business days
70
+ var today = new Date();
71
+ today.setHours(0, 0, 0, 0);
72
+ var editaisRecentes = [];
73
+ var editaisVencidos = [];
74
+ var vencidosResumo = [];
75
+ var dataEditalMaisAntigo = null;
76
+ var formatDate = function (dateStr) {
77
+ var date = parseEditalDate(dateStr);
78
+ if (!date)
79
+ return dateStr;
80
+ var day = String(date.getDate()).padStart(2, '0');
81
+ var month = String(date.getMonth() + 1).padStart(2, '0');
82
+ var year = date.getFullYear();
83
+ return "".concat(day, "/").concat(month, "/").concat(year);
84
+ };
85
+ editais.forEach(function (edital) {
86
+ var dataCadastro = parseEditalDate(edital.dt_hr_cadastro);
87
+ if (!dataCadastro) {
88
+ // Skip items with invalid dates
89
+ return;
90
+ }
91
+ var diasUteis = calculateBusinessDays(dataCadastro, today);
92
+ var isRecent = diasUteis <= 3;
93
+ if (isRecent) {
94
+ editaisRecentes.push(edital);
95
+ }
96
+ else {
97
+ editaisVencidos.push(edital);
98
+ // Track oldest expired edital date
99
+ if (!dataEditalMaisAntigo || dataCadastro < dataEditalMaisAntigo) {
100
+ dataEditalMaisAntigo = dataCadastro;
101
+ }
102
+ // Add to summary (limit to first items, will be sliced in UI)
103
+ if (vencidosResumo.length < 10) {
104
+ // Store more than 5 to allow proper counting
105
+ vencidosResumo.push({
106
+ id: edital.cd_arquivo_editalEletronico,
107
+ cartorio: edital.nome_cartorio,
108
+ dataCadastro: formatDate(edital.dt_hr_cadastro),
109
+ diasUteis: diasUteis,
110
+ devedor: edital.nomeDevedor || undefined,
111
+ documentoMascarado: edital.doc_devedor
112
+ ? formatDocument(edital.doc_devedor)
113
+ : undefined
114
+ });
115
+ }
116
+ }
117
+ });
51
118
  setData(function (prevState) { return (__assign(__assign({}, prevState), { editalData: {
52
119
  isLoaded: true,
53
120
  totalEditais: total,
54
- editais: editais
121
+ editais: editais,
122
+ recentesCount: editaisRecentes.length,
123
+ vencidosCount: editaisVencidos.length,
124
+ editaisRecentes: editaisRecentes,
125
+ editaisVencidos: editaisVencidos,
126
+ vencidosResumo: vencidosResumo,
127
+ dataEditalMaisAntigo: dataEditalMaisAntigo
128
+ ? formatDate(dataEditalMaisAntigo.toISOString())
129
+ : undefined
55
130
  } })); });
56
131
  setDataUpdated(true);
57
132
  }, [ctx.document, dataUpdated, setData]);
@@ -62,23 +137,56 @@ var Edital = function (_a) {
62
137
  }
63
138
  }, [ctx.type, setData]);
64
139
  var handleSuccess = function (response) {
140
+ var _a, _b, _c, _d;
65
141
  var editais = (response === null || response === void 0 ? void 0 : response.editalEletronico) || [];
66
142
  var total = editais.length;
143
+ // Read counts from globalData
144
+ var recentesCount = ((_a = globalData.editalData) === null || _a === void 0 ? void 0 : _a.recentesCount) || 0;
145
+ var vencidosCount = ((_b = globalData.editalData) === null || _b === void 0 ? void 0 : _b.vencidosCount) || 0;
146
+ var editaisRecentes = ((_c = globalData.editalData) === null || _c === void 0 ? void 0 : _c.editaisRecentes) || [];
147
+ var editaisVencidos = ((_d = globalData.editalData) === null || _d === void 0 ? void 0 : _d.editaisVencidos) || [];
148
+ // Determine which editais to display
149
+ var editaisToDisplay = showExpired
150
+ ? __spreadArray(__spreadArray([], editaisRecentes, true), editaisVencidos, true) : editaisRecentes;
67
151
  var variant = total > 0 ? 'error' : 'default';
152
+ // Build description with count and warning
153
+ var buildDescription = function () {
154
+ var _a;
155
+ if (total === 0) {
156
+ return (React.createElement(StatusMessage, { type: "default" }, "N\u00E3o h\u00E1 intima\u00E7\u00F5es por edital eletr\u00F4nico"));
157
+ }
158
+ var messages = [];
159
+ // Count message
160
+ if (vencidosCount > 0) {
161
+ var countText = total === 1
162
+ ? "Encontrada 1 intima\u00E7\u00E3o (".concat(recentesCount, " recente; ").concat(vencidosCount, " vencida oculta)")
163
+ : "Encontradas ".concat(total, " intima\u00E7\u00F5es (").concat(recentesCount, " recentes; ").concat(vencidosCount, " vencidas ocultas)");
164
+ messages.push(React.createElement(StatusMessage, { key: "count", type: total > 0 ? 'error' : 'default' }, countText));
165
+ // Warning banner
166
+ var dataDesde = (_a = globalData.editalData) === null || _a === void 0 ? void 0 : _a.dataEditalMaisAntigo;
167
+ messages.push(React.createElement(StatusMessage, { key: "warning", type: "error" },
168
+ "Cart\u00F3rio com dificuldade para intimar",
169
+ dataDesde && " desde o: ".concat(dataDesde)));
170
+ }
171
+ else {
172
+ var countText = recentesCount === 1
173
+ ? 'Encontrada 1 intimação'
174
+ : "Encontradas ".concat(recentesCount, " intima\u00E7\u00F5es");
175
+ messages.push(React.createElement(StatusMessage, { key: "count", type: recentesCount > 0 ? 'error' : 'default' }, countText));
176
+ }
177
+ return React.createElement(React.Fragment, null, messages);
178
+ };
68
179
  return {
69
- children: total > 0 ? React.createElement(EditalList, { editais: editais }) : null,
180
+ children: editaisToDisplay.length > 0 ? (React.createElement(EditalList, { editais: editaisToDisplay })) : null,
70
181
  variant: variant,
71
- description: (React.createElement(StatusMessage, { type: total > 0 ? 'error' : 'default' }, total > 0
72
- ? total === 1
73
- ? 'Encontrada 1 intimação por edital eletrônico'
74
- : "Encontradas ".concat(total, " intima\u00E7\u00F5es por edital eletr\u00F4nico")
75
- : 'Não há intimações por edital eletrônico'))
182
+ description: buildDescription()
76
183
  };
77
184
  };
78
185
  // Se não tiver acesso, não renderiza nada
79
186
  if (!hasAccess) {
80
187
  return null;
81
188
  }
82
- return (React.createElement(Section, { ctx: ctx, title: "Intima\u00E7\u00F5es por Edital Eletr\u00F4nico", subtitle: "Consulta de intima\u00E7\u00F5es por edital eletr\u00F4nico para aceite, pagamento ou apresenta\u00E7\u00E3o de raz\u00F5es.", icon: EditalIcon, onSuccess: handleSuccess }));
189
+ return (React.createElement(Section, { id: "editais-section", ctx: ctx, title: "Protestos Entrantes", subtitle: "Consulta de potencial protesto futuro.", icon: EditalIcon, onSuccess: handleSuccess }));
83
190
  };
84
191
  export default React.memo(Edital);
192
+ var templateObject_1;
@@ -2,7 +2,9 @@ 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 { calculateRemainingBusinessDays, parseEditalDate } from '../../utils/businessDays';
5
6
  import { formatDocument } from '../../utils/string';
7
+ import { Clock } from 'phosphor-react';
6
8
  import React from 'react';
7
9
  import styled from 'styled-components';
8
10
  import AddItemField from '../common/addItem';
@@ -12,10 +14,20 @@ var EditalContainer = styled.div(templateObject_2 || (templateObject_2 = __makeT
12
14
  var EditalCard = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background: #f8f9fa;\n border-radius: 8px;\n padding: 0;\n border-left: 4px solid #dc3545;\n overflow: hidden;\n"], ["\n background: #f8f9fa;\n border-radius: 8px;\n padding: 0;\n border-left: 4px solid #dc3545;\n overflow: hidden;\n"])));
13
15
  var EditalHeader = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n border-bottom: 1px solid #dee2e6;\n"], ["\n border-bottom: 1px solid #dee2e6;\n"])));
14
16
  var EditalTitle = styled.h4(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n margin: 0;\n padding: 18px 20px 12px 20px;\n color: #212529;\n font-size: 16px;\n font-weight: 600;\n"], ["\n margin: 0;\n padding: 18px 20px 12px 20px;\n color: #212529;\n font-size: 16px;\n font-weight: 600;\n"])));
15
- var EditalText = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n padding: 18px 20px;\n background: white;\n font-size: 14px;\n line-height: 1.6;\n color: #495057;\n border-top: 1px solid #dee2e6;\n border-bottom: 1px solid #dee2e6;\n\n strong {\n display: block;\n margin-bottom: 10px;\n color: #212529;\n }\n"], ["\n padding: 18px 20px;\n background: white;\n font-size: 14px;\n line-height: 1.6;\n color: #495057;\n border-top: 1px solid #dee2e6;\n border-bottom: 1px solid #dee2e6;\n\n strong {\n display: block;\n margin-bottom: 10px;\n color: #212529;\n }\n"])));
16
- var TitulosSection = styled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding: 18px 0;\n"], ["\n padding: 18px 0;\n"])));
17
- var TitulosSectionTitle = styled.h5(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n margin: 0 0 20px 0;\n padding: 0 20px;\n color: #495057;\n font-size: 14px;\n font-weight: 600;\n text-transform: uppercase;\n"], ["\n margin: 0 0 20px 0;\n padding: 0 20px;\n color: #495057;\n font-size: 14px;\n font-weight: 600;\n text-transform: uppercase;\n"])));
18
- var TituloCard = styled.div(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n background: white;\n border-radius: 6px;\n margin: 0 20px 12px 20px;\n border: 1px solid #dee2e6;\n\n &:last-child {\n margin-bottom: 0;\n }\n"], ["\n background: white;\n border-radius: 6px;\n margin: 0 20px 12px 20px;\n border: 1px solid #dee2e6;\n\n &:last-child {\n margin-bottom: 0;\n }\n"])));
17
+ var CountdownBadge = styled.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 4px 12px;\n margin-left: 12px;\n border-radius: 12px;\n font-size: 13px;\n font-weight: 500;\n background-color: ", ";\n color: ", ";\n border: 1px solid ", ";\n\n @media print {\n display: none;\n }\n"], ["\n display: inline-flex;\n align-items: center;\n gap: 6px;\n padding: 4px 12px;\n margin-left: 12px;\n border-radius: 12px;\n font-size: 13px;\n font-weight: 500;\n background-color: ", ";\n color: ", ";\n border: 1px solid ", ";\n\n @media print {\n display: none;\n }\n"])), function (_a) {
18
+ var $expired = _a.$expired;
19
+ return ($expired ? '#fee' : '#fff3cd');
20
+ }, function (_a) {
21
+ var $expired = _a.$expired;
22
+ return ($expired ? '#c82333' : '#856404');
23
+ }, function (_a) {
24
+ var $expired = _a.$expired;
25
+ return ($expired ? '#f5c6cb' : '#ffeaa7');
26
+ });
27
+ var EditalText = styled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding: 18px 20px;\n background: white;\n font-size: 14px;\n line-height: 1.6;\n color: #495057;\n border-top: 1px solid #dee2e6;\n border-bottom: 1px solid #dee2e6;\n\n strong {\n display: block;\n margin-bottom: 10px;\n color: #212529;\n }\n"], ["\n padding: 18px 20px;\n background: white;\n font-size: 14px;\n line-height: 1.6;\n color: #495057;\n border-top: 1px solid #dee2e6;\n border-bottom: 1px solid #dee2e6;\n\n strong {\n display: block;\n margin-bottom: 10px;\n color: #212529;\n }\n"])));
28
+ var TitulosSection = styled.div(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n padding: 18px 0;\n"], ["\n padding: 18px 0;\n"])));
29
+ var TitulosSectionTitle = styled.h5(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n margin: 0 0 20px 0;\n padding: 0 20px;\n color: #495057;\n font-size: 14px;\n font-weight: 600;\n text-transform: uppercase;\n"], ["\n margin: 0 0 20px 0;\n padding: 0 20px;\n color: #495057;\n font-size: 14px;\n font-weight: 600;\n text-transform: uppercase;\n"])));
30
+ var TituloCard = styled.div(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n background: white;\n border-radius: 6px;\n margin: 0 20px 12px 20px;\n border: 1px solid #dee2e6;\n\n &:last-child {\n margin-bottom: 0;\n }\n"], ["\n background: white;\n border-radius: 6px;\n margin: 0 20px 12px 20px;\n border: 1px solid #dee2e6;\n\n &:last-child {\n margin-bottom: 0;\n }\n"])));
19
31
  var formatDate = function (dateStr) {
20
32
  if (!dateStr)
21
33
  return '-';
@@ -47,14 +59,20 @@ var EditalList = function (_a) {
47
59
  var _a;
48
60
  // Agrupa os títulos únicos (remove duplicatas baseadas em protocolo e data)
49
61
  var titulosUnicos = ((_a = edital.editalf) === null || _a === void 0 ? void 0 : _a[0]) || [];
62
+ // Calculate remaining business days for countdown
63
+ var dataCadastro = parseEditalDate(edital.dt_hr_cadastro);
64
+ var remainingDays = dataCadastro
65
+ ? calculateRemainingBusinessDays(dataCadastro)
66
+ : null;
50
67
  return (React.createElement(EditalCard, { key: index },
51
68
  React.createElement(EditalHeader, null,
52
69
  React.createElement(EditalTitle, null,
53
- "Edital #",
54
- edital.cd_arquivo_editalEletronico,
55
- " -",
56
- ' ',
57
- edital.nome_cartorio),
70
+ edital.nome_cartorio,
71
+ remainingDays !== null && (React.createElement(CountdownBadge, { "$expired": remainingDays <= 0 },
72
+ React.createElement(Clock, { size: 14, weight: "bold" }),
73
+ remainingDays > 0
74
+ ? "".concat(remainingDays, " ").concat(remainingDays === 1 ? 'dia útil' : 'dias úteis', " para protesto")
75
+ : 'Prazo vencido'))),
58
76
  React.createElement(ResultContent, { print: "repeat(3, 1fr)", desktop: "repeat(3, 1fr)", tablet: "repeat(2, 1fr)", mobile: "1fr" },
59
77
  React.createElement(AddItemField, { name: "Cart\u00F3rio", value: edital.nome_cartorio }),
60
78
  React.createElement(AddItemField, { name: "Endere\u00E7o", value: "".concat(edital.endereco, ", ").concat(edital.endereco_numero, " - ").concat(edital.bairroc, ", ").concat(edital.cidadec, "/").concat(edital.uf) }),
@@ -85,4 +103,4 @@ var EditalList = function (_a) {
85
103
  })));
86
104
  };
87
105
  export default EditalList;
88
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9;
106
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10;
@@ -45,7 +45,7 @@ var ProtestosSP = function () {
45
45
  children: data === null || data === void 0 ? void 0 : data.map(function (e) {
46
46
  var _a, _b, _c, _d, _e;
47
47
  return (React.createElement(ResultContent, { print: "repeat(7, 1fr)", desktop: "repeat(8, 1fr)", tablet: "repeat(4, 1fr)", mobile: "repeat(2, 1fr)" },
48
- React.createElement(AddItemField, { name: "Cartorio", value: e === null || e === void 0 ? void 0 : e[2] }),
48
+ React.createElement(AddItemField, { name: "Cart\u00F3rio", value: e === null || e === void 0 ? void 0 : e[2] }),
49
49
  React.createElement(AddItemField, { name: "Quantidade", value: (_a = e === null || e === void 0 ? void 0 : e[10]) !== null && _a !== void 0 ? _a : e === null || e === void 0 ? void 0 : e[9] }),
50
50
  React.createElement(AddItemField, { name: "Valor Total", value: formatMoney((_e = (_d = (_c = (_b = e === null || e === void 0 ? void 0 : e[7]) === null || _b === void 0 ? void 0 : _b.match(/[\d,.]+/g)) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.replace('.', '')) === null || _e === void 0 ? void 0 : _e.replace(',', '.')) })));
51
51
  }),