@credithub/harlan-components 1.115.0 → 1.115.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.
@@ -10,6 +10,7 @@ interface UseInstrumentoReturn {
10
10
  isEmailModalOpen: boolean;
11
11
  emailMessage: ReactNode;
12
12
  emailTitle: string;
13
+ isSuccess: boolean;
13
14
  isEnviandoEmail: boolean;
14
15
  isProcessandoDescoberta: boolean;
15
16
  openModalSP: () => void;
@@ -49,8 +49,9 @@ export var useInstrumento = function (_a) {
49
49
  var _c = useState(false), isEmailModalOpen = _c[0], setIsEmailModalOpen = _c[1];
50
50
  var _d = useState(''), emailMessage = _d[0], setEmailMessage = _d[1];
51
51
  var _e = useState('Instrumento de Protesto'), emailTitle = _e[0], setEmailTitle = _e[1];
52
- var _f = useState(false), isEnviandoEmail = _f[0], setIsEnviandoEmail = _f[1];
53
- var _g = useState(false), isProcessandoDescoberta = _g[0], setIsProcessandoDescoberta = _g[1];
52
+ var _f = useState(false), isSuccess = _f[0], setIsSuccess = _f[1];
53
+ var _g = useState(false), isEnviandoEmail = _g[0], setIsEnviandoEmail = _g[1];
54
+ var _h = useState(false), isProcessandoDescoberta = _h[0], setIsProcessandoDescoberta = _h[1];
54
55
  var openModalSP = useCallback(function () {
55
56
  setIsModalSPOpen(true);
56
57
  }, []);
@@ -61,6 +62,7 @@ export var useInstrumento = function (_a) {
61
62
  setIsEmailModalOpen(false);
62
63
  setEmailMessage('');
63
64
  setEmailTitle('Instrumento de Protesto');
65
+ setIsSuccess(false);
64
66
  }, []);
65
67
  var handleEnviarEmail = useCallback(function (livro, folha) { return __awaiter(void 0, void 0, void 0, function () {
66
68
  var res, error_1;
@@ -82,6 +84,7 @@ export var useInstrumento = function (_a) {
82
84
  setEmailTitle('Instrumento solicitado por e-mail');
83
85
  setEmailMessage((res === null || res === void 0 ? void 0 : res.message) ||
84
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.');
87
+ setIsSuccess(true);
85
88
  setIsEmailModalOpen(true);
86
89
  setIsModalSPOpen(false);
87
90
  return [3 /*break*/, 5];
@@ -89,6 +92,7 @@ export var useInstrumento = function (_a) {
89
92
  error_1 = _a.sent();
90
93
  setEmailTitle('Erro ao Enviar E-mail');
91
94
  setEmailMessage('Não foi possível solicitar o instrumento por e-mail agora. Tente novamente em instantes.');
95
+ setIsSuccess(false);
92
96
  setIsEmailModalOpen(true);
93
97
  return [3 /*break*/, 5];
94
98
  case 4:
@@ -116,12 +120,14 @@ export var useInstrumento = function (_a) {
116
120
  setEmailTitle('Solicitação enviada');
117
121
  setEmailMessage((res === null || res === void 0 ? void 0 : res.message) ||
118
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.');
123
+ setIsSuccess(true);
119
124
  setIsEmailModalOpen(true);
120
125
  return [3 /*break*/, 5];
121
126
  case 3:
122
127
  error_2 = _a.sent();
123
128
  setEmailTitle('Erro na solicitação');
124
129
  setEmailMessage('Não foi possível iniciar a solicitação por e-mail agora. Tente novamente em instantes.');
130
+ setIsSuccess(false);
125
131
  setIsEmailModalOpen(true);
126
132
  return [3 /*break*/, 5];
127
133
  case 4:
@@ -136,6 +142,7 @@ export var useInstrumento = function (_a) {
136
142
  isEmailModalOpen: isEmailModalOpen,
137
143
  emailMessage: emailMessage,
138
144
  emailTitle: emailTitle,
145
+ isSuccess: isSuccess,
139
146
  isEnviandoEmail: isEnviandoEmail,
140
147
  isProcessandoDescoberta: isProcessandoDescoberta,
141
148
  openModalSP: openModalSP,
@@ -163,58 +163,10 @@ export var ProtestoItem = memo(function (_a) {
163
163
  return value === 'true' ? 'Sim' : 'Não';
164
164
  };
165
165
  var fetchQuemApresentou = function (nm_chave) { return __awaiter(void 0, void 0, void 0, function () {
166
- var normalizedKey, response, nomeDetectado_1, error_1;
167
166
  return __generator(this, function (_a) {
168
- switch (_a.label) {
169
- case 0:
170
- if (!isInstrumentKeyValid(nm_chave))
171
- return [2 /*return*/];
172
- normalizedKey = normalizeInstrumentKey(nm_chave);
173
- if (!normalizedKey)
174
- return [2 /*return*/];
175
- setLoading(true);
176
- _a.label = 1;
177
- case 1:
178
- _a.trys.push([1, 4, 5, 6]);
179
- return [4 /*yield*/, client.request("SELECT FROM 'PDFPROTESTO'.'AI'", {
180
- nm_chave: normalizedKey,
181
- documento: documento
182
- })];
183
- case 2: return [4 /*yield*/, (_a.sent()).json()];
184
- case 3:
185
- response = _a.sent();
186
- nomeDetectado_1 = null;
187
- if (response === null || response === void 0 ? void 0 : response['Quem Protestou']) {
188
- nomeDetectado_1 = response['Quem Protestou'];
189
- }
190
- else if (response === null || response === void 0 ? void 0 : response['Quem Apresentou']) {
191
- nomeDetectado_1 = response['Quem Apresentou'];
192
- }
193
- if (nomeDetectado_1) {
194
- setQuemApresentou(nomeDetectado_1);
195
- setIsAIData(true);
196
- // Salva IA override globalmente
197
- setData(function (prev) {
198
- var _a;
199
- var _b;
200
- // Garante que só string é atribuída
201
- if (!nomeDetectado_1)
202
- return prev;
203
- return __assign(__assign({}, prev), { protestosData: __assign(__assign({}, prev.protestosData), { iaOverrides: __assign(__assign({}, (((_b = prev.protestosData) === null || _b === void 0 ? void 0 : _b.iaOverrides) || {})), (_a = {}, _a[nm_chave] = nomeDetectado_1, _a)) }) });
204
- });
205
- }
206
- return [3 /*break*/, 6];
207
- case 4:
208
- error_1 = _a.sent();
209
- console.error('Erro ao buscar dados de protesto IA:', error_1);
210
- return [3 /*break*/, 6];
211
- case 5:
212
- setLoading(false);
213
- activeRequests--;
214
- processQueue();
215
- return [7 /*endfinally*/];
216
- case 6: return [2 /*return*/];
217
- }
167
+ // Desabilitado: endpoint PDFPROTESTO.AI está retornando erro 500 (serviço legado indisponível)
168
+ // TODO: Reativar quando novo endpoint de IA estiver disponível
169
+ return [2 /*return*/];
218
170
  });
219
171
  }); };
220
172
  var queueOrExecuteFetch = function (nm_chave) {
@@ -536,13 +488,15 @@ export var Instrumento = function (_a) {
536
488
  });
537
489
  }); }, disabled: isDisabled }, getButtonLabel())),
538
490
  React.createElement(ModalInstrumentoProtestoSP, { isOpen: instrumentoHook.isModalSPOpen, onClose: instrumentoHook.closeModalSP, onEnviarEmail: instrumentoHook.handleEnviarEmail, isEnviandoEmail: instrumentoHook.isEnviandoEmail }),
539
- React.createElement(InstrumentoEmailStatusModal, { isOpen: instrumentoHook.isEmailModalOpen, onClose: instrumentoHook.closeEmailModal, message: instrumentoHook.emailMessage, title: instrumentoHook.emailTitle, secondaryActionLabel: "Atualizar consulta (hoje)", secondaryActionDisabled: isPrefetching || isLoading, onSecondaryAction: function () {
540
- var _a;
541
- // Permite reconsultar no mesmo dia para tentar “desocultar” instrumento/nome
542
- resetInstrumentStateForKey();
543
- (_a = ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.refetch) === null || _a === void 0 ? void 0 : _a.call(ctxProtestos);
544
- instrumentoHook.closeEmailModal();
545
- } }),
491
+ React.createElement(InstrumentoEmailStatusModal, { isOpen: instrumentoHook.isEmailModalOpen, onClose: instrumentoHook.closeEmailModal, message: instrumentoHook.emailMessage, title: instrumentoHook.emailTitle, secondaryActionLabel: instrumentoHook.isSuccess ? 'Atualizar consulta (hoje)' : undefined, secondaryActionDisabled: isPrefetching || isLoading, onSecondaryAction: instrumentoHook.isSuccess
492
+ ? function () {
493
+ var _a;
494
+ // Permite reconsultar no mesmo dia para tentar “desocultar” instrumento/nome
495
+ resetInstrumentStateForKey();
496
+ (_a = ctxProtestos === null || ctxProtestos === void 0 ? void 0 : ctxProtestos.refetch) === null || _a === void 0 ? void 0 : _a.call(ctxProtestos);
497
+ instrumentoHook.closeEmailModal();
498
+ }
499
+ : undefined }),
546
500
  React.createElement(InstrumentoDiscoveryConfirmModal, { isOpen: isDiscoveryConfirmOpen, onClose: function () { return setIsDiscoveryConfirmOpen(false); }, isLoading: instrumentoHook.isProcessandoDescoberta, onConfirm: function () { return __awaiter(void 0, void 0, void 0, function () {
547
501
  return __generator(this, function (_a) {
548
502
  switch (_a.label) {