@credithub/harlan-components 1.116.0 → 1.116.2

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.
@@ -83,7 +83,7 @@ export var useInstrumento = function (_a) {
83
83
  res = _a.sent();
84
84
  setEmailTitle('Instrumento solicitado por e-mail');
85
85
  setEmailMessage((res === null || res === void 0 ? void 0 : res.message) ||
86
- 'Solicitação registrada. Vamos processar o instrumento e também agregar as informações do credor quando possível. Em alguns minutos, refaça a consulta de hoje para atualizar os dados.');
86
+ 'Pedido registrado.\n\nAgora é aguardar: vamos tentar obter o instrumento e enviar por e-mail. Isso pode levar alguns minutos.\n\nApós identificar o instrumento, também vamos identificar o credor (quem protestou).');
87
87
  setIsSuccess(true);
88
88
  setIsEmailModalOpen(true);
89
89
  setIsModalSPOpen(false);
@@ -119,7 +119,7 @@ export var useInstrumento = function (_a) {
119
119
  res = _a.sent();
120
120
  setEmailTitle('Solicitação enviada');
121
121
  setEmailMessage((res === null || res === void 0 ? void 0 : res.message) ||
122
- 'Solicitação registrada. Vamos processar o instrumento e também agregar as informações do credor quando possível. Em alguns minutos, refaça a consulta de hoje para atualizar os dados.');
122
+ 'Pedido registrado.\n\nAgora é aguardar: vamos tentar obter o instrumento e enviar por e-mail. Isso pode levar alguns minutos.\n\nQuando possível, também vamos identificar o credor (quem protestou).');
123
123
  setIsSuccess(true);
124
124
  setIsEmailModalOpen(true);
125
125
  return [3 /*break*/, 5];
@@ -7,4 +7,4 @@ export declare const ProtestoItem: React.MemoExoticComponent<({ protesto, showIn
7
7
  export declare const Instrumento: ({ nm_chave, cpfCnpj }: {
8
8
  nm_chave?: string;
9
9
  cpfCnpj?: string;
10
- }) => React.JSX.Element | null;
10
+ }) => React.JSX.Element;
@@ -1,14 +1,3 @@
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
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -45,17 +34,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
34
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
35
  }
47
36
  };
48
- var __rest = (this && this.__rest) || function (s, e) {
49
- var t = {};
50
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
- t[p] = s[p];
52
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
- t[p[i]] = s[p[i]];
56
- }
57
- return t;
58
- };
59
37
  import { useGlobalData } from '../../contexts/globalDataContext';
60
38
  import { formatMoney } from '../../utils/number';
61
39
  import { isProtestoSPByNmChave } from '../../utils/protestoUf';
@@ -65,7 +43,7 @@ import AddItemField from '../common/addItem';
65
43
  import Button from '../common/button';
66
44
  import ModalInstrumentoProtestoSP from '../common/modalInstrumentoProtestoSP';
67
45
  import { ResultContent } from '../interface/result';
68
- import { Queries, WebService } from '../webservice';
46
+ import { WebService } from '../webservice';
69
47
  import InstrumentoDiscoveryConfirmModal from './instrumento/InstrumentoDiscoveryConfirmModal';
70
48
  import InstrumentoEmailStatusModal from './instrumento/InstrumentoEmailStatusModal';
71
49
  import { useInstrumento } from './instrumento/useInstrumento';
@@ -111,6 +89,8 @@ var isInstrumentKeyValid = function (key) {
111
89
  return false;
112
90
  return true;
113
91
  };
92
+ // Endpoint de IA desativado no momento; evita loader eterno
93
+ var isQuemProtestouLookupEnabled = false;
114
94
  // Elegant three-dot loader component
115
95
  var ThreeDotsLoader = function () {
116
96
  // CSS for the loader container
@@ -170,6 +150,8 @@ export var ProtestoItem = memo(function (_a) {
170
150
  });
171
151
  }); };
172
152
  var queueOrExecuteFetch = function (nm_chave) {
153
+ if (!isQuemProtestouLookupEnabled)
154
+ return;
173
155
  var execute = function () { return fetchQuemApresentou(nm_chave); };
174
156
  if (activeRequests < MAX_CONCURRENT_REQUESTS) {
175
157
  activeRequests++;
@@ -187,6 +169,15 @@ export var ProtestoItem = memo(function (_a) {
187
169
  var nomeCedente = protesto.nomeCedente;
188
170
  if (nomeCedente && nomeCedente.trim() !== '')
189
171
  return;
172
+ if (!isQuemProtestouLookupEnabled) {
173
+ setLoading(true);
174
+ setQueued(false);
175
+ requestQueue.length = 0;
176
+ var timeout_1 = setTimeout(function () {
177
+ setLoading(false);
178
+ }, 800);
179
+ return function () { return clearTimeout(timeout_1); };
180
+ }
190
181
  if (isInstrumentKeyValid(nm_chave)) {
191
182
  queueOrExecuteFetch(nm_chave);
192
183
  }
@@ -212,6 +203,8 @@ export var ProtestoItem = memo(function (_a) {
212
203
  return (React.createElement(React.Fragment, null,
213
204
  quemApresentou,
214
205
  React.createElement(AIIndicator, null)));
206
+ if (!isQuemProtestouLookupEnabled)
207
+ return '---';
215
208
  if ((loading || queued) && !quemApresentou)
216
209
  return React.createElement(ThreeDotsLoader, null);
217
210
  return quemApresentou || '';
@@ -229,9 +222,6 @@ export var ProtestoItem = memo(function (_a) {
229
222
  export var Instrumento = function (_a) {
230
223
  var nm_chave = _a.nm_chave, cpfCnpj = _a.cpfCnpj;
231
224
  var client = useContext(WebService);
232
- var ctxProtestos = useContext(Queries.Protestos);
233
- var _b = useGlobalData(), setData = _b.setData, globalData = _b.data;
234
- var protestosData = (globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) || {};
235
225
  var normalizedKey = useMemo(function () { return normalizeInstrumentKey(nm_chave); }, [nm_chave]);
236
226
  // Hook para gerenciar fluxo de instrumento (fase mockada)
237
227
  var instrumentoHook = useInstrumento({
@@ -239,10 +229,9 @@ export var Instrumento = function (_a) {
239
229
  cpfCnpj: cpfCnpj || '',
240
230
  client: client
241
231
  });
242
- if (!nm_chave)
243
- return null;
244
232
  var hasCpfCnpj = Boolean(cpfCnpj && cpfCnpj.trim() !== '');
245
233
  var isValidKey = useMemo(function () { return isInstrumentKeyValid(nm_chave); }, [nm_chave]);
234
+ var hasKey = Boolean(normalizedKey);
246
235
  var classifyInstrumentError = function (err) {
247
236
  var rawMessage = err instanceof Error ? err.message : String(err !== null && err !== void 0 ? err : '').toString();
248
237
  if (/chave.+inv[aá]lid/i.test(rawMessage) ||
@@ -252,30 +241,51 @@ export var Instrumento = function (_a) {
252
241
  return 'missing-doc';
253
242
  };
254
243
  var deriveErrorKind = useCallback(function () {
244
+ if (!hasKey)
245
+ return 'missing-key';
255
246
  if (!hasCpfCnpj)
256
247
  return 'missing-doc';
257
248
  if (!isValidKey)
258
249
  return 'invalid-key';
259
250
  return null;
260
- }, [hasCpfCnpj, isValidKey]);
261
- var _c = useState(deriveErrorKind), errorKind = _c[0], setErrorKind = _c[1];
262
- var _d = useState(false), isLoading = _d[0], setIsLoading = _d[1];
263
- var _e = useState(false), isDiscoveryConfirmOpen = _e[0], setIsDiscoveryConfirmOpen = _e[1];
251
+ }, [hasKey, hasCpfCnpj, isValidKey]);
252
+ var _b = useState(deriveErrorKind), errorKind = _b[0], setErrorKind = _b[1];
253
+ var _c = useState(false), isLoading = _c[0], setIsLoading = _c[1];
254
+ var _d = useState(false), isDiscoveryConfirmOpen = _d[0], setIsDiscoveryConfirmOpen = _d[1];
255
+ var _e = useState(false), isMissingKeyLoading = _e[0], setIsMissingKeyLoading = _e[1];
264
256
  useEffect(function () {
265
257
  setErrorKind(deriveErrorKind());
266
258
  }, [deriveErrorKind]);
259
+ useEffect(function () {
260
+ if (errorKind !== 'missing-key') {
261
+ setIsMissingKeyLoading(false);
262
+ return;
263
+ }
264
+ setIsMissingKeyLoading(true);
265
+ var timeout = setTimeout(function () {
266
+ setIsMissingKeyLoading(false);
267
+ }, 800);
268
+ return function () { return clearTimeout(timeout); };
269
+ }, [errorKind]);
267
270
  // Mantém o botão clicável para "Solicitar instrumento" mesmo durante prefetch
268
271
  var isDisabled = isLoading ||
272
+ isMissingKeyLoading ||
269
273
  errorKind === 'invalid-key' ||
270
- errorKind === 'missing-doc';
274
+ errorKind === 'missing-doc' ||
275
+ errorKind === 'missing-key';
271
276
  var getTooltipMessage = function () {
272
277
  if (errorKind === 'missing-doc')
273
278
  return 'Documento não disponível para consulta';
274
279
  if (errorKind === 'invalid-key')
275
280
  return 'Chave de instrumento inválida';
281
+ if (errorKind === 'missing-key') {
282
+ return isMissingKeyLoading ? '' : 'Instrumento não localizado';
283
+ }
276
284
  return '';
277
285
  };
278
286
  var getButtonLabel = function () {
287
+ if (errorKind === 'missing-key')
288
+ return isMissingKeyLoading ? 'Solicitar instrumento' : 'Instrumento não localizado';
279
289
  if (errorKind === 'invalid-key' || errorKind === 'missing-doc')
280
290
  return 'Instrumento Indisponível';
281
291
  if (!isProtestoSPByNmChave(normalizedKey))
@@ -284,23 +294,11 @@ export var Instrumento = function (_a) {
284
294
  };
285
295
  var tooltipMessage = getTooltipMessage();
286
296
  var isSP = isProtestoSPByNmChave(normalizedKey);
287
- var resetInstrumentStateForKey = useCallback(function () {
288
- if (!nm_chave)
289
- return;
290
- setData(function (prev) {
291
- var base = prev || {};
292
- var prevProtestosData = base.protestosData || {};
293
- var _a = prevProtestosData.failedInstruments || {}, _b = nm_chave, _f1 = _a[_b], restFailed = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
294
- var _c = prevProtestosData.failedInstrumentReasons || {}, _d = nm_chave, _r1 = _c[_d], restReasons = __rest(_c, [typeof _d === "symbol" ? _d : _d + ""]);
295
- var _e = prevProtestosData.checkedInstruments || {}, _f = nm_chave, _c1 = _e[_f], restChecked = __rest(_e, [typeof _f === "symbol" ? _f : _f + ""]);
296
- var _g = prevProtestosData.instrumentCache || {}, _h = nm_chave, _i1 = _g[_h], restCache = __rest(_g, [typeof _h === "symbol" ? _h : _h + ""]);
297
- return __assign(__assign({}, base), { protestosData: __assign(__assign({}, prevProtestosData), { failedInstruments: restFailed, failedInstrumentReasons: restReasons, checkedInstruments: restChecked, instrumentCache: restCache, refreshToken: (prevProtestosData.refreshToken || 0) + 1 }) });
298
- });
299
- setErrorKind(null);
300
- }, [nm_chave, setData]);
301
297
  return (React.createElement(React.Fragment, null,
302
298
  React.createElement("span", { title: tooltipMessage, style: { display: 'inline-block' } },
303
- React.createElement(Button, { isLoading: isLoading || instrumentoHook.isProcessandoDescoberta, onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
299
+ React.createElement(Button, { isLoading: isLoading ||
300
+ instrumentoHook.isProcessandoDescoberta ||
301
+ isMissingKeyLoading, onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
304
302
  return __generator(this, function (_a) {
305
303
  if (isDisabled)
306
304
  return [2 /*return*/];
@@ -315,15 +313,7 @@ export var Instrumento = function (_a) {
315
313
  });
316
314
  }); }, disabled: isDisabled }, getButtonLabel())),
317
315
  React.createElement(ModalInstrumentoProtestoSP, { isOpen: instrumentoHook.isModalSPOpen, onClose: instrumentoHook.closeModalSP, onEnviarEmail: instrumentoHook.handleEnviarEmail, isEnviandoEmail: instrumentoHook.isEnviandoEmail }),
318
- React.createElement(InstrumentoEmailStatusModal, { isOpen: instrumentoHook.isEmailModalOpen, onClose: instrumentoHook.closeEmailModal, message: instrumentoHook.emailMessage, title: instrumentoHook.emailTitle, secondaryActionLabel: instrumentoHook.isSuccess ? 'Atualizar consulta (hoje)' : undefined, secondaryActionDisabled: false, onSecondaryAction: instrumentoHook.isSuccess
319
- ? function () {
320
- var _a;
321
- // Permite reconsultar no mesmo dia para tentar “desocultar” instrumento/nome
322
- resetInstrumentStateForKey();
323
- (_a = ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.refetch) === null || _a === void 0 ? void 0 : _a.call(ctxProtestos);
324
- instrumentoHook.closeEmailModal();
325
- }
326
- : undefined }),
316
+ React.createElement(InstrumentoEmailStatusModal, { isOpen: instrumentoHook.isEmailModalOpen, onClose: instrumentoHook.closeEmailModal, message: instrumentoHook.emailMessage, title: instrumentoHook.emailTitle }),
327
317
  React.createElement(InstrumentoDiscoveryConfirmModal, { isOpen: isDiscoveryConfirmOpen, onClose: function () { return setIsDiscoveryConfirmOpen(false); }, isLoading: instrumentoHook.isProcessandoDescoberta, onConfirm: function () { return __awaiter(void 0, void 0, void 0, function () {
328
318
  return __generator(this, function (_a) {
329
319
  switch (_a.label) {