@credithub/harlan-components 1.112.0 → 1.112.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.
- package/dist/adapters/instrumentoProtesto/ieptbInstrumento.js +2 -2
- package/dist/components/common/modalInstrumentoProtestoSP.d.ts +0 -3
- package/dist/components/common/modalInstrumentoProtestoSP.js +5 -6
- package/dist/components/protestos/instrumento/useInstrumento.d.ts +2 -4
- package/dist/components/protestos/instrumento/useInstrumento.js +18 -84
- package/dist/components/protestos/protestosList.js +2 -2
- package/lib/cjs/index.js +80 -286
- package/lib/esm/index.js +80 -286
- package/package.json +1 -1
- package/dist/components/protestos/instrumento/mocks/instrumentoMocks.d.ts +0 -33
- package/dist/components/protestos/instrumento/mocks/instrumentoMocks.js +0 -142
|
@@ -39,7 +39,7 @@ export function sendInstrumentoManualEmail(client, payload) {
|
|
|
39
39
|
var res;
|
|
40
40
|
return __generator(this, function (_a) {
|
|
41
41
|
switch (_a.label) {
|
|
42
|
-
case 0: return [4 /*yield*/, client.request("
|
|
42
|
+
case 0: return [4 /*yield*/, client.request("INSERT INTO 'IEPTB'.'InstrumentoManualSendmail'", {
|
|
43
43
|
documento: payload.documento,
|
|
44
44
|
nm_chave: payload.nm_chave,
|
|
45
45
|
livro: payload.livro,
|
|
@@ -58,7 +58,7 @@ export function sendInstrumentoDiscoveryEmail(client, payload) {
|
|
|
58
58
|
var res;
|
|
59
59
|
return __generator(this, function (_a) {
|
|
60
60
|
switch (_a.label) {
|
|
61
|
-
case 0: return [4 /*yield*/, client.request("
|
|
61
|
+
case 0: return [4 /*yield*/, client.request("INSERT INTO 'IEPTB'.'InstrumentoDiscoverySendmail'", {
|
|
62
62
|
documento: payload.documento,
|
|
63
63
|
nm_chave: payload.nm_chave
|
|
64
64
|
})];
|
|
@@ -2,10 +2,7 @@ import { FC } from 'react';
|
|
|
2
2
|
interface ModalInstrumentoProtestoSPProps {
|
|
3
3
|
isOpen: boolean;
|
|
4
4
|
onClose: () => void;
|
|
5
|
-
onDescobrir?: (livro: string, folha: string) => void;
|
|
6
5
|
onEnviarEmail?: (livro: string, folha: string) => void;
|
|
7
|
-
canDescobrir?: boolean;
|
|
8
|
-
isDescobrindo?: boolean;
|
|
9
6
|
isEnviandoEmail?: boolean;
|
|
10
7
|
}
|
|
11
8
|
declare const ModalInstrumentoProtestoSP: FC<ModalInstrumentoProtestoSPProps>;
|
|
@@ -73,9 +73,9 @@ var GhostButton = styled(Button)(templateObject_11 || (templateObject_11 = __mak
|
|
|
73
73
|
return theme.colors.azulCredithub;
|
|
74
74
|
});
|
|
75
75
|
var ModalInstrumentoProtestoSP = function (_a) {
|
|
76
|
-
var isOpen = _a.isOpen, onClose = _a.onClose,
|
|
77
|
-
var
|
|
78
|
-
var
|
|
76
|
+
var isOpen = _a.isOpen, onClose = _a.onClose, onEnviarEmail = _a.onEnviarEmail, _b = _a.isEnviandoEmail, isEnviandoEmail = _b === void 0 ? false : _b;
|
|
77
|
+
var _c = useState(''), livro = _c[0], setLivro = _c[1];
|
|
78
|
+
var _d = useState(''), folha = _d[0], setFolha = _d[1];
|
|
79
79
|
useEffect(function () {
|
|
80
80
|
if (!isOpen) {
|
|
81
81
|
setLivro('');
|
|
@@ -85,11 +85,10 @@ var ModalInstrumentoProtestoSP = function (_a) {
|
|
|
85
85
|
var hasLivro = livro.trim().length > 0;
|
|
86
86
|
var hasFolha = folha.trim().length > 0;
|
|
87
87
|
var isFormValid = hasLivro && hasFolha;
|
|
88
|
-
var isProcessing =
|
|
88
|
+
var isProcessing = isEnviandoEmail;
|
|
89
89
|
var isFormDisabled = !isFormValid || isProcessing;
|
|
90
90
|
var footerContent = (React.createElement(Footer, null,
|
|
91
|
-
|
|
92
|
-
React.createElement(Button, { onClick: function () { return onEnviarEmail === null || onEnviarEmail === void 0 ? void 0 : onEnviarEmail(livro, folha); }, disabled: isFormDisabled, isLoading: isEnviandoEmail }, "ENVIAR POR E-MAIL"),
|
|
91
|
+
React.createElement(Button, { onClick: function () { return onEnviarEmail === null || onEnviarEmail === void 0 ? void 0 : onEnviarEmail(livro, folha); }, disabled: isFormDisabled, isLoading: isEnviandoEmail }, "SOLICITAR POR E-MAIL"),
|
|
93
92
|
React.createElement(GhostButton, { onClick: onClose, disabled: isProcessing }, "Cancelar")));
|
|
94
93
|
return (React.createElement(Modal, { isOpen: isOpen, onClose: onClose, title: "INSTRUMENTO DE PROTESTO - SP", footer: footerContent },
|
|
95
94
|
React.createElement(Wrapper, null,
|
|
@@ -2,20 +2,18 @@ import type { Client } from '@credithub/webservice';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
interface UseInstrumentoParams {
|
|
4
4
|
nmChave: string;
|
|
5
|
-
cpfCnpj
|
|
6
|
-
client
|
|
5
|
+
cpfCnpj: string;
|
|
6
|
+
client: Client.WebService;
|
|
7
7
|
}
|
|
8
8
|
interface UseInstrumentoReturn {
|
|
9
9
|
isModalSPOpen: boolean;
|
|
10
10
|
isEmailModalOpen: boolean;
|
|
11
11
|
emailMessage: ReactNode;
|
|
12
12
|
emailTitle: string;
|
|
13
|
-
isDescobrindo: boolean;
|
|
14
13
|
isEnviandoEmail: boolean;
|
|
15
14
|
isProcessandoDescoberta: boolean;
|
|
16
15
|
openModalSP: () => void;
|
|
17
16
|
closeModalSP: () => void;
|
|
18
|
-
handleDescobrir: (livro: string, folha: string) => Promise<void>;
|
|
19
17
|
handleEnviarEmail: (livro: string, folha: string) => Promise<void>;
|
|
20
18
|
handleDescobertaAutomatica: () => Promise<void>;
|
|
21
19
|
closeEmailModal: () => void;
|
|
@@ -36,7 +36,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
import { sendInstrumentoDiscoveryEmail, sendInstrumentoManualEmail } from '../../../adapters/instrumentoProtesto/ieptbInstrumento';
|
|
38
38
|
import { useCallback, useState } from 'react';
|
|
39
|
-
import { mockDescobertaAutomaticaEmail, mockDescobrirInstrumento, mockEnviarEmailSP } from './mocks/instrumentoMocks';
|
|
40
39
|
/**
|
|
41
40
|
* Hook para gerenciar o fluxo de instrumento de protesto (fase mockada)
|
|
42
41
|
*
|
|
@@ -50,9 +49,8 @@ export var useInstrumento = function (_a) {
|
|
|
50
49
|
var _c = useState(false), isEmailModalOpen = _c[0], setIsEmailModalOpen = _c[1];
|
|
51
50
|
var _d = useState(''), emailMessage = _d[0], setEmailMessage = _d[1];
|
|
52
51
|
var _e = useState('Instrumento de Protesto'), emailTitle = _e[0], setEmailTitle = _e[1];
|
|
53
|
-
var _f = useState(false),
|
|
54
|
-
var _g = useState(false),
|
|
55
|
-
var _h = useState(false), isProcessandoDescoberta = _h[0], setIsProcessandoDescoberta = _h[1];
|
|
52
|
+
var _f = useState(false), isEnviandoEmail = _f[0], setIsEnviandoEmail = _f[1];
|
|
53
|
+
var _g = useState(false), isProcessandoDescoberta = _g[0], setIsProcessandoDescoberta = _g[1];
|
|
56
54
|
var openModalSP = useCallback(function () {
|
|
57
55
|
setIsModalSPOpen(true);
|
|
58
56
|
}, []);
|
|
@@ -64,54 +62,15 @@ export var useInstrumento = function (_a) {
|
|
|
64
62
|
setEmailMessage('');
|
|
65
63
|
setEmailTitle('Instrumento de Protesto');
|
|
66
64
|
}, []);
|
|
67
|
-
var handleDescobrir = useCallback(function (livro, folha) { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
|
-
var result, error_1;
|
|
69
|
-
return __generator(this, function (_a) {
|
|
70
|
-
switch (_a.label) {
|
|
71
|
-
case 0:
|
|
72
|
-
setIsDescobrindo(true);
|
|
73
|
-
_a.label = 1;
|
|
74
|
-
case 1:
|
|
75
|
-
_a.trys.push([1, 3, 4, 5]);
|
|
76
|
-
return [4 /*yield*/, mockDescobrirInstrumento(livro, folha)];
|
|
77
|
-
case 2:
|
|
78
|
-
result = _a.sent();
|
|
79
|
-
if (result.success) {
|
|
80
|
-
setEmailTitle('Instrumento Descoberto');
|
|
81
|
-
setEmailMessage(result.message);
|
|
82
|
-
setIsEmailModalOpen(true);
|
|
83
|
-
// Fecha o modal SP após sucesso
|
|
84
|
-
setIsModalSPOpen(false);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
setEmailTitle('Erro ao Descobrir Instrumento');
|
|
88
|
-
setEmailMessage(result.message);
|
|
89
|
-
setIsEmailModalOpen(true);
|
|
90
|
-
}
|
|
91
|
-
return [3 /*break*/, 5];
|
|
92
|
-
case 3:
|
|
93
|
-
error_1 = _a.sent();
|
|
94
|
-
setEmailTitle('Erro ao Descobrir Instrumento');
|
|
95
|
-
setEmailMessage('Ocorreu um erro inesperado ao tentar descobrir o instrumento. Tente novamente mais tarde.');
|
|
96
|
-
setIsEmailModalOpen(true);
|
|
97
|
-
return [3 /*break*/, 5];
|
|
98
|
-
case 4:
|
|
99
|
-
setIsDescobrindo(false);
|
|
100
|
-
return [7 /*endfinally*/];
|
|
101
|
-
case 5: return [2 /*return*/];
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}); }, []);
|
|
105
65
|
var handleEnviarEmail = useCallback(function (livro, folha) { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
-
var res,
|
|
66
|
+
var res, error_1;
|
|
107
67
|
return __generator(this, function (_a) {
|
|
108
68
|
switch (_a.label) {
|
|
109
69
|
case 0:
|
|
110
70
|
setIsEnviandoEmail(true);
|
|
111
71
|
_a.label = 1;
|
|
112
72
|
case 1:
|
|
113
|
-
_a.trys.push([1,
|
|
114
|
-
if (!(client && cpfCnpj)) return [3 /*break*/, 3];
|
|
73
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
115
74
|
return [4 /*yield*/, sendInstrumentoManualEmail(client, {
|
|
116
75
|
documento: cpfCnpj,
|
|
117
76
|
nm_chave: nmChave,
|
|
@@ -125,45 +84,29 @@ export var useInstrumento = function (_a) {
|
|
|
125
84
|
'Ok! Vamos processar e enviar o instrumento para seu e-mail assim que estiver disponível.');
|
|
126
85
|
setIsEmailModalOpen(true);
|
|
127
86
|
setIsModalSPOpen(false);
|
|
128
|
-
return [
|
|
129
|
-
case 3:
|
|
130
|
-
|
|
131
|
-
result = _a.sent();
|
|
132
|
-
setEmailTitle('Instrumento solicitado por e-mail');
|
|
133
|
-
setEmailMessage(result.message);
|
|
134
|
-
setIsEmailModalOpen(true);
|
|
135
|
-
// Fecha o modal SP após envio
|
|
136
|
-
setIsModalSPOpen(false);
|
|
137
|
-
return [3 /*break*/, 7];
|
|
138
|
-
case 5:
|
|
139
|
-
error_2 = _a.sent();
|
|
87
|
+
return [3 /*break*/, 5];
|
|
88
|
+
case 3:
|
|
89
|
+
error_1 = _a.sent();
|
|
140
90
|
setEmailTitle('Erro ao Enviar E-mail');
|
|
141
91
|
setEmailMessage('Não foi possível solicitar o instrumento por e-mail agora. Tente novamente em instantes.');
|
|
142
92
|
setIsEmailModalOpen(true);
|
|
143
|
-
return [3 /*break*/,
|
|
144
|
-
case
|
|
93
|
+
return [3 /*break*/, 5];
|
|
94
|
+
case 4:
|
|
145
95
|
setIsEnviandoEmail(false);
|
|
146
96
|
return [7 /*endfinally*/];
|
|
147
|
-
case
|
|
97
|
+
case 5: return [2 /*return*/];
|
|
148
98
|
}
|
|
149
99
|
});
|
|
150
100
|
}); }, [client, cpfCnpj, nmChave]);
|
|
151
101
|
var handleDescobertaAutomatica = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
152
|
-
var res,
|
|
102
|
+
var res, error_2;
|
|
153
103
|
return __generator(this, function (_a) {
|
|
154
104
|
switch (_a.label) {
|
|
155
105
|
case 0:
|
|
156
|
-
if (!cpfCnpj) {
|
|
157
|
-
setEmailTitle('Erro');
|
|
158
|
-
setEmailMessage('Documento não disponível para descoberta automática.');
|
|
159
|
-
setIsEmailModalOpen(true);
|
|
160
|
-
return [2 /*return*/];
|
|
161
|
-
}
|
|
162
106
|
setIsProcessandoDescoberta(true);
|
|
163
107
|
_a.label = 1;
|
|
164
108
|
case 1:
|
|
165
|
-
_a.trys.push([1,
|
|
166
|
-
if (!client) return [3 /*break*/, 3];
|
|
109
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
167
110
|
return [4 /*yield*/, sendInstrumentoDiscoveryEmail(client, {
|
|
168
111
|
documento: cpfCnpj,
|
|
169
112
|
nm_chave: nmChave
|
|
@@ -174,24 +117,17 @@ export var useInstrumento = function (_a) {
|
|
|
174
117
|
setEmailMessage((res === null || res === void 0 ? void 0 : res.message) ||
|
|
175
118
|
'Pronto! Iniciamos o processamento e você receberá o instrumento por e-mail assim que estiver disponível.');
|
|
176
119
|
setIsEmailModalOpen(true);
|
|
177
|
-
return [
|
|
178
|
-
case 3:
|
|
179
|
-
|
|
180
|
-
result = _a.sent();
|
|
181
|
-
setEmailTitle('Solicitação enviada');
|
|
182
|
-
setEmailMessage(result.message);
|
|
183
|
-
setIsEmailModalOpen(true);
|
|
184
|
-
return [3 /*break*/, 7];
|
|
185
|
-
case 5:
|
|
186
|
-
error_3 = _a.sent();
|
|
120
|
+
return [3 /*break*/, 5];
|
|
121
|
+
case 3:
|
|
122
|
+
error_2 = _a.sent();
|
|
187
123
|
setEmailTitle('Erro na solicitação');
|
|
188
124
|
setEmailMessage('Não foi possível iniciar a solicitação por e-mail agora. Tente novamente em instantes.');
|
|
189
125
|
setIsEmailModalOpen(true);
|
|
190
|
-
return [3 /*break*/,
|
|
191
|
-
case
|
|
126
|
+
return [3 /*break*/, 5];
|
|
127
|
+
case 4:
|
|
192
128
|
setIsProcessandoDescoberta(false);
|
|
193
129
|
return [7 /*endfinally*/];
|
|
194
|
-
case
|
|
130
|
+
case 5: return [2 /*return*/];
|
|
195
131
|
}
|
|
196
132
|
});
|
|
197
133
|
}); }, [client, nmChave, cpfCnpj]);
|
|
@@ -200,12 +136,10 @@ export var useInstrumento = function (_a) {
|
|
|
200
136
|
isEmailModalOpen: isEmailModalOpen,
|
|
201
137
|
emailMessage: emailMessage,
|
|
202
138
|
emailTitle: emailTitle,
|
|
203
|
-
isDescobrindo: isDescobrindo,
|
|
204
139
|
isEnviandoEmail: isEnviandoEmail,
|
|
205
140
|
isProcessandoDescoberta: isProcessandoDescoberta,
|
|
206
141
|
openModalSP: openModalSP,
|
|
207
142
|
closeModalSP: closeModalSP,
|
|
208
|
-
handleDescobrir: handleDescobrir,
|
|
209
143
|
handleEnviarEmail: handleEnviarEmail,
|
|
210
144
|
handleDescobertaAutomatica: handleDescobertaAutomatica,
|
|
211
145
|
closeEmailModal: closeEmailModal
|
|
@@ -66,8 +66,8 @@ import Button from '../common/button';
|
|
|
66
66
|
import ModalInstrumentoProtestoSP from '../common/modalInstrumentoProtestoSP';
|
|
67
67
|
import { ResultContent } from '../interface/result';
|
|
68
68
|
import { WebService } from '../webservice';
|
|
69
|
-
import InstrumentoEmailStatusModal from './instrumento/InstrumentoEmailStatusModal';
|
|
70
69
|
import InstrumentoDiscoveryConfirmModal from './instrumento/InstrumentoDiscoveryConfirmModal';
|
|
70
|
+
import InstrumentoEmailStatusModal from './instrumento/InstrumentoEmailStatusModal';
|
|
71
71
|
import { useInstrumento } from './instrumento/useInstrumento';
|
|
72
72
|
// Throttling mechanism for API requests
|
|
73
73
|
var activeRequests = 0;
|
|
@@ -519,7 +519,7 @@ export var Instrumento = function (_a) {
|
|
|
519
519
|
}
|
|
520
520
|
});
|
|
521
521
|
}); }, disabled: isDisabled }, getButtonLabel())),
|
|
522
|
-
React.createElement(ModalInstrumentoProtestoSP, { isOpen: instrumentoHook.isModalSPOpen, onClose: instrumentoHook.closeModalSP,
|
|
522
|
+
React.createElement(ModalInstrumentoProtestoSP, { isOpen: instrumentoHook.isModalSPOpen, onClose: instrumentoHook.closeModalSP, onEnviarEmail: instrumentoHook.handleEnviarEmail, isEnviandoEmail: instrumentoHook.isEnviandoEmail }),
|
|
523
523
|
React.createElement(InstrumentoEmailStatusModal, { isOpen: instrumentoHook.isEmailModalOpen, onClose: instrumentoHook.closeEmailModal, message: instrumentoHook.emailMessage, title: instrumentoHook.emailTitle }),
|
|
524
524
|
React.createElement(InstrumentoDiscoveryConfirmModal, { isOpen: isDiscoveryConfirmOpen, onClose: function () { return setIsDiscoveryConfirmOpen(false); }, isLoading: instrumentoHook.isProcessandoDescoberta, onConfirm: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
525
525
|
return __generator(this, function (_a) {
|