@credithub/harlan-components 1.119.0 → 1.119.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.
@@ -65,14 +65,15 @@ export var useInstrumento = function (_a) {
65
65
  setIsSuccess(false);
66
66
  }, []);
67
67
  var handleEnviarEmail = useCallback(function (livro, folha) { return __awaiter(void 0, void 0, void 0, function () {
68
- var res, error_1;
69
- return __generator(this, function (_a) {
70
- switch (_a.label) {
68
+ var res, error_1, errorMessage, isSolicitacaoEmProcessamento;
69
+ var _a;
70
+ return __generator(this, function (_b) {
71
+ switch (_b.label) {
71
72
  case 0:
72
73
  setIsEnviandoEmail(true);
73
- _a.label = 1;
74
+ _b.label = 1;
74
75
  case 1:
75
- _a.trys.push([1, 3, 4, 5]);
76
+ _b.trys.push([1, 3, 4, 5]);
76
77
  return [4 /*yield*/, sendInstrumentoManualEmail(client, {
77
78
  documento: cpfCnpj,
78
79
  nm_chave: nmChave,
@@ -80,7 +81,7 @@ export var useInstrumento = function (_a) {
80
81
  folha: folha
81
82
  })];
82
83
  case 2:
83
- res = _a.sent();
84
+ res = _b.sent();
84
85
  setEmailTitle('Instrumento solicitado por e-mail');
85
86
  setEmailMessage((res === null || res === void 0 ? void 0 : res.message) ||
86
87
  'Pedido registrado.\n\nAgora é só aguardar: vamos tentar obter o instrumento e enviar por e-mail. Isso pode levar algum tempo.\n\nApós identificar o instrumento, também vamos identificar o credor (quem protestou).');
@@ -89,7 +90,18 @@ export var useInstrumento = function (_a) {
89
90
  setIsModalSPOpen(false);
90
91
  return [3 /*break*/, 5];
91
92
  case 3:
92
- error_1 = _a.sent();
93
+ error_1 = _b.sent();
94
+ errorMessage = String((_a = error_1 === null || error_1 === void 0 ? void 0 : error_1.message) !== null && _a !== void 0 ? _a : error_1);
95
+ isSolicitacaoEmProcessamento = errorMessage
96
+ .toLocaleLowerCase()
97
+ .includes('já existe um processamento para este instrumento');
98
+ if (isSolicitacaoEmProcessamento) {
99
+ setEmailTitle('Solicitação em processamento');
100
+ setEmailMessage('Já existe uma solicitação em processamento para este instrumento.\n\nAguarde alguns instantes e tente novamente. Se preferir, aguarde o e-mail com o instrumento assim que estiver disponível.');
101
+ setIsSuccess(false);
102
+ setIsEmailModalOpen(true);
103
+ return [2 /*return*/];
104
+ }
93
105
  setEmailTitle('Erro ao Enviar E-mail');
94
106
  setEmailMessage('Não foi possível solicitar o instrumento por e-mail agora. Tente novamente em instantes.');
95
107
  setIsSuccess(false);