@credithub/harlan-components 1.112.0 → 1.113.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.
- package/dist/adapters/instrumentoProtesto/ieptbInstrumento.js +2 -2
- package/dist/components/common/modalInstrumentoProtestoSP.d.ts +0 -3
- package/dist/components/common/modalInstrumentoProtestoSP.js +8 -9
- package/dist/components/protestos/instrumento/InstrumentoDiscoveryConfirmModal.js +4 -4
- package/dist/components/protestos/instrumento/InstrumentoEmailStatusModal.d.ts +3 -0
- package/dist/components/protestos/instrumento/InstrumentoEmailStatusModal.js +11 -3
- package/dist/components/protestos/instrumento/useInstrumento.d.ts +2 -4
- package/dist/components/protestos/instrumento/useInstrumento.js +20 -86
- package/dist/components/protestos/protestosList.js +35 -13
- package/lib/cjs/index.js +360 -537
- package/lib/esm/index.js +360 -537
- 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>;
|
|
@@ -2,10 +2,10 @@ 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 React, {
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
6
|
import styled, { css, keyframes } from 'styled-components';
|
|
7
|
-
import Modal from './modal';
|
|
8
7
|
import Button from './button';
|
|
8
|
+
import Modal from './modal';
|
|
9
9
|
var CheckIcon = function () { return (React.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" },
|
|
10
10
|
React.createElement("polyline", { points: "20 6 9 17 4 12" }))); };
|
|
11
11
|
var slideUp = keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n from { opacity: 0; transform: translateY(8px); }\n to { opacity: 1; transform: translateY(0); }\n"], ["\n from { opacity: 0; transform: translateY(8px); }\n to { opacity: 1; transform: translateY(0); }\n"])));
|
|
@@ -59,7 +59,7 @@ var StyledInput = styled.input(templateObject_9 || (templateObject_9 = __makeTem
|
|
|
59
59
|
return theme.colors.azulClaro;
|
|
60
60
|
}, function (_a) {
|
|
61
61
|
var $isValid = _a.$isValid, theme = _a.theme;
|
|
62
|
-
return $isValid && css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n
|
|
62
|
+
return $isValid && css(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n background-color: ", ";\n border-color: ", ";\n color: ", ";\n\n &:focus {\n border-color: ", ";\n box-shadow: 0 0 0 2px ", "30;\n }\n "], ["\n background-color: ", ";\n border-color: ", ";\n color: ", ";\n\n &:focus {\n border-color: ", ";\n box-shadow: 0 0 0 2px ", "30;\n }\n "])), theme.colors.white, theme.colors.positivoApoio, theme.colors.cinzaEscuro, theme.colors.positivoApoio, theme.colors.positivoClaro);
|
|
63
63
|
});
|
|
64
64
|
var Footer = styled.div(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n gap: 12px;\n width: 100%;\n border-top: 1px solid ", ";\n"], ["\n display: flex;\n flex-direction: column;\n gap: 12px;\n width: 100%;\n border-top: 1px solid ", ";\n"])), function (_a) {
|
|
65
65
|
var theme = _a.theme;
|
|
@@ -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 INSTRUMENTO"),
|
|
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,9 +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 React from 'react';
|
|
6
|
-
import Modal from '../../../components/common/modal';
|
|
7
5
|
import Button from '../../../components/common/button';
|
|
6
|
+
import Modal from '../../../components/common/modal';
|
|
7
|
+
import React from 'react';
|
|
8
8
|
import styled from 'styled-components';
|
|
9
9
|
var Actions = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n gap: 10px;\n flex-wrap: wrap;\n"], ["\n display: flex;\n justify-content: center;\n gap: 10px;\n flex-wrap: wrap;\n"])));
|
|
10
10
|
var PrimaryButton = styled(Button)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n && {\n width: auto !important;\n min-width: 190px;\n white-space: nowrap;\n }\n"], ["\n && {\n width: auto !important;\n min-width: 190px;\n white-space: nowrap;\n }\n"])));
|
|
@@ -20,8 +20,8 @@ var CancelButton = styled.button(templateObject_3 || (templateObject_3 = __makeT
|
|
|
20
20
|
});
|
|
21
21
|
var InstrumentoDiscoveryConfirmModal = function (_a) {
|
|
22
22
|
var isOpen = _a.isOpen, onClose = _a.onClose, onConfirm = _a.onConfirm, _b = _a.isLoading, isLoading = _b === void 0 ? false : _b;
|
|
23
|
-
return (React.createElement(Modal, { isOpen: isOpen, onClose: onClose, title: "Solicitar instrumento
|
|
24
|
-
React.createElement(PrimaryButton, { onClick: onConfirm, isLoading: isLoading }, "
|
|
23
|
+
return (React.createElement(Modal, { isOpen: isOpen, onClose: onClose, title: "Solicitar instrumento", footer: React.createElement(Actions, null,
|
|
24
|
+
React.createElement(PrimaryButton, { onClick: onConfirm, isLoading: isLoading }, "Solicitar instrumento"),
|
|
25
25
|
React.createElement(CancelButton, { onClick: onClose, disabled: isLoading }, "Cancelar")) },
|
|
26
26
|
React.createElement("div", { style: { textAlign: 'center' } }, "N\u00E3o encontramos o PDF do instrumento agora. Se voc\u00EA confirmar, vamos iniciar o processamento e enviar o instrumento por e-mail assim que estiver dispon\u00EDvel.")));
|
|
27
27
|
};
|
|
@@ -4,6 +4,9 @@ interface InstrumentoEmailStatusModalProps {
|
|
|
4
4
|
onClose: () => void;
|
|
5
5
|
message: ReactNode;
|
|
6
6
|
title?: string;
|
|
7
|
+
secondaryActionLabel?: string;
|
|
8
|
+
onSecondaryAction?: () => void | Promise<void>;
|
|
9
|
+
secondaryActionDisabled?: boolean;
|
|
7
10
|
}
|
|
8
11
|
declare const InstrumentoEmailStatusModal: FC<InstrumentoEmailStatusModalProps>;
|
|
9
12
|
export default InstrumentoEmailStatusModal;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
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
|
+
};
|
|
2
5
|
import Modal from '../../../components/common/modal';
|
|
3
6
|
import React from 'react';
|
|
7
|
+
import Button from '../../../components/common/button';
|
|
8
|
+
import styled from 'styled-components';
|
|
9
|
+
var Actions = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n gap: 10px;\n flex-wrap: wrap;\n margin-top: 16px;\n"], ["\n display: flex;\n justify-content: center;\n gap: 10px;\n flex-wrap: wrap;\n margin-top: 16px;\n"])));
|
|
4
10
|
var InstrumentoEmailStatusModal = function (_a) {
|
|
5
|
-
var isOpen = _a.isOpen, onClose = _a.onClose, message = _a.message, _b = _a.title, title = _b === void 0 ? 'Instrumento de Protesto' : _b;
|
|
11
|
+
var isOpen = _a.isOpen, onClose = _a.onClose, message = _a.message, _b = _a.title, title = _b === void 0 ? 'Instrumento de Protesto' : _b, secondaryActionLabel = _a.secondaryActionLabel, onSecondaryAction = _a.onSecondaryAction, _c = _a.secondaryActionDisabled, secondaryActionDisabled = _c === void 0 ? false : _c;
|
|
6
12
|
return (React.createElement(Modal, { isOpen: isOpen, onClose: onClose, title: title },
|
|
7
13
|
React.createElement("div", { style: {
|
|
8
14
|
textAlign: 'center',
|
|
@@ -10,7 +16,9 @@ var InstrumentoEmailStatusModal = function (_a) {
|
|
|
10
16
|
fontSize: 18,
|
|
11
17
|
fontWeight: 400
|
|
12
18
|
} }, message),
|
|
13
|
-
React.createElement(
|
|
19
|
+
React.createElement(Actions, null,
|
|
20
|
+
secondaryActionLabel && onSecondaryAction && (React.createElement(Button, { onClick: onSecondaryAction, disabled: secondaryActionDisabled }, secondaryActionLabel)),
|
|
14
21
|
React.createElement(Button, { onClick: onClose }, "Fechar"))));
|
|
15
22
|
};
|
|
16
23
|
export default InstrumentoEmailStatusModal;
|
|
24
|
+
var templateObject_1;
|
|
@@ -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,
|
|
@@ -122,48 +81,32 @@ export var useInstrumento = function (_a) {
|
|
|
122
81
|
res = _a.sent();
|
|
123
82
|
setEmailTitle('Instrumento solicitado por e-mail');
|
|
124
83
|
setEmailMessage((res === null || res === void 0 ? void 0 : res.message) ||
|
|
125
|
-
'
|
|
84
|
+
'Solicitação registrada. Em alguns minutos, refaça a consulta de hoje para atualizar os dados e obter o instrumento.');
|
|
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
|
|
@@ -172,26 +115,19 @@ export var useInstrumento = function (_a) {
|
|
|
172
115
|
res = _a.sent();
|
|
173
116
|
setEmailTitle('Solicitação enviada');
|
|
174
117
|
setEmailMessage((res === null || res === void 0 ? void 0 : res.message) ||
|
|
175
|
-
'
|
|
118
|
+
'Solicitação registrada. Em alguns minutos, refaça a consulta de hoje para atualizar os dados e obter o instrumento.');
|
|
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
|
|
@@ -65,9 +65,9 @@ import AddItemField from '../common/addItem';
|
|
|
65
65
|
import Button from '../common/button';
|
|
66
66
|
import ModalInstrumentoProtestoSP from '../common/modalInstrumentoProtestoSP';
|
|
67
67
|
import { ResultContent } from '../interface/result';
|
|
68
|
-
import { WebService } from '../webservice';
|
|
69
|
-
import InstrumentoEmailStatusModal from './instrumento/InstrumentoEmailStatusModal';
|
|
68
|
+
import { Queries, WebService } from '../webservice';
|
|
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;
|
|
@@ -147,15 +147,16 @@ var AIIndicator = function () { return (React.createElement("span", { title: "In
|
|
|
147
147
|
cursor: 'help'
|
|
148
148
|
} }, "*")); };
|
|
149
149
|
export var ProtestoItem = memo(function (_a) {
|
|
150
|
-
var _b;
|
|
150
|
+
var _b, _c;
|
|
151
151
|
var protesto = _a.protesto;
|
|
152
152
|
var client = useContext(WebService);
|
|
153
|
-
var
|
|
153
|
+
var _d = useGlobalData(), setData = _d.setData, globalData = _d.data;
|
|
154
154
|
var iaOverrides = ((_b = globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) === null || _b === void 0 ? void 0 : _b.iaOverrides) || {};
|
|
155
|
-
var
|
|
156
|
-
var _e = useState(
|
|
157
|
-
var _f = useState(false),
|
|
158
|
-
var _g = useState(false),
|
|
155
|
+
var refreshToken = ((_c = globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) === null || _c === void 0 ? void 0 : _c.refreshToken) || 0;
|
|
156
|
+
var _e = useState(null), quemApresentou = _e[0], setQuemApresentou = _e[1];
|
|
157
|
+
var _f = useState(false), loading = _f[0], setLoading = _f[1];
|
|
158
|
+
var _g = useState(false), queued = _g[0], setQueued = _g[1];
|
|
159
|
+
var _h = useState(false), isAIData = _h[0], setIsAIData = _h[1];
|
|
159
160
|
var documento = protesto.cpfCnpj;
|
|
160
161
|
var nm_chave = protesto.nm_chave;
|
|
161
162
|
var formatBooleanField = function (value) {
|
|
@@ -244,7 +245,7 @@ export var ProtestoItem = memo(function (_a) {
|
|
|
244
245
|
if (idx !== -1)
|
|
245
246
|
requestQueue.splice(idx, 1);
|
|
246
247
|
};
|
|
247
|
-
}, []);
|
|
248
|
+
}, [nm_chave, refreshToken]);
|
|
248
249
|
var getQuemProtestouDisplay = function () {
|
|
249
250
|
var original = protesto.nomeCedente;
|
|
250
251
|
var override = iaOverrides[nm_chave];
|
|
@@ -276,6 +277,7 @@ export var ProtestoItem = memo(function (_a) {
|
|
|
276
277
|
export var Instrumento = function (_a) {
|
|
277
278
|
var nm_chave = _a.nm_chave, cpfCnpj = _a.cpfCnpj;
|
|
278
279
|
var client = useContext(WebService);
|
|
280
|
+
var ctxProtestos = useContext(Queries.Protestos);
|
|
279
281
|
var _b = useGlobalData(), setData = _b.setData, globalData = _b.data;
|
|
280
282
|
var protestosData = (globalData === null || globalData === void 0 ? void 0 : globalData.protestosData) || {};
|
|
281
283
|
var failedInstruments = protestosData.failedInstruments || {};
|
|
@@ -424,14 +426,14 @@ export var Instrumento = function (_a) {
|
|
|
424
426
|
if (errorKind === 'invalid-key')
|
|
425
427
|
return 'Chave de instrumento inválida';
|
|
426
428
|
if (errorKind === 'not-found')
|
|
427
|
-
return 'PDF indisponível. Você pode solicitar
|
|
429
|
+
return 'PDF indisponível. Você pode solicitar o instrumento.';
|
|
428
430
|
if (isPrefetching)
|
|
429
431
|
return 'Verificando disponibilidade do instrumento...';
|
|
430
432
|
return '';
|
|
431
433
|
};
|
|
432
434
|
var getButtonLabel = function () {
|
|
433
435
|
if (errorKind === 'not-found' && !isProtestoSPByNmChave(normalizedKey))
|
|
434
|
-
return 'Solicitar
|
|
436
|
+
return 'Solicitar instrumento';
|
|
435
437
|
if (errorKind === 'invalid-key' || errorKind === 'missing-doc')
|
|
436
438
|
return 'Instrumento Indisponível';
|
|
437
439
|
return 'Instrumento';
|
|
@@ -444,6 +446,20 @@ export var Instrumento = function (_a) {
|
|
|
444
446
|
pdfWindow.document.write("<iframe width='100%' height='100%' src='data:application/pdf;base64,".concat(base64, "'></iframe>"));
|
|
445
447
|
};
|
|
446
448
|
var isSP = isProtestoSPByNmChave(normalizedKey);
|
|
449
|
+
var resetInstrumentStateForKey = useCallback(function () {
|
|
450
|
+
if (!nm_chave)
|
|
451
|
+
return;
|
|
452
|
+
setData(function (prev) {
|
|
453
|
+
var base = prev || {};
|
|
454
|
+
var prevProtestosData = base.protestosData || {};
|
|
455
|
+
var _a = prevProtestosData.failedInstruments || {}, _b = nm_chave, _f1 = _a[_b], restFailed = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
456
|
+
var _c = prevProtestosData.failedInstrumentReasons || {}, _d = nm_chave, _r1 = _c[_d], restReasons = __rest(_c, [typeof _d === "symbol" ? _d : _d + ""]);
|
|
457
|
+
var _e = prevProtestosData.checkedInstruments || {}, _f = nm_chave, _c1 = _e[_f], restChecked = __rest(_e, [typeof _f === "symbol" ? _f : _f + ""]);
|
|
458
|
+
var _g = prevProtestosData.instrumentCache || {}, _h = nm_chave, _i1 = _g[_h], restCache = __rest(_g, [typeof _h === "symbol" ? _h : _h + ""]);
|
|
459
|
+
return __assign(__assign({}, base), { protestosData: __assign(__assign({}, prevProtestosData), { failedInstruments: restFailed, failedInstrumentReasons: restReasons, checkedInstruments: restChecked, instrumentCache: restCache, refreshToken: (prevProtestosData.refreshToken || 0) + 1 }) });
|
|
460
|
+
});
|
|
461
|
+
setErrorKind(null);
|
|
462
|
+
}, [nm_chave, setData]);
|
|
447
463
|
return (React.createElement(React.Fragment, null,
|
|
448
464
|
React.createElement("span", { title: tooltipMessage, style: { display: 'inline-block' } },
|
|
449
465
|
React.createElement(Button, { isLoading: isLoading || instrumentoHook.isProcessandoDescoberta, onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -519,8 +535,14 @@ export var Instrumento = function (_a) {
|
|
|
519
535
|
}
|
|
520
536
|
});
|
|
521
537
|
}); }, disabled: isDisabled }, getButtonLabel())),
|
|
522
|
-
React.createElement(ModalInstrumentoProtestoSP, { isOpen: instrumentoHook.isModalSPOpen, onClose: instrumentoHook.closeModalSP,
|
|
523
|
-
React.createElement(InstrumentoEmailStatusModal, { isOpen: instrumentoHook.isEmailModalOpen, onClose: instrumentoHook.closeEmailModal, message: instrumentoHook.emailMessage, title: instrumentoHook.emailTitle
|
|
538
|
+
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
|
+
} }),
|
|
524
546
|
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
547
|
return __generator(this, function (_a) {
|
|
526
548
|
switch (_a.label) {
|