This commit is contained in:
Luiz H. R. Silva 2024-06-04 21:22:33 -03:00
parent ac361d54a0
commit f4e8a8d5bf
6 changed files with 110 additions and 83 deletions

View file

@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.componentesAlerta = void 0;
const dist_1 = require("~comuns/dist");
const dist_2 = require("~estaticos/dist");
const dist_1 = require("p-estaticos/dist");
const p_respostas_1 = require("p-respostas");
const react_1 = __importDefault(require("react"));
const autoClose = 5000;
const componentesAlerta = ({ mui_material: { Avatar, Typography }, react_toastify: { ToastContainer, Slide, toast }, }) => {
const AlertaContainer = () => (react_1.default.createElement(ToastContainer, { position: "bottom-left", autoClose: autoClose, hideProgressBar: false, newestOnTop: false, closeOnClick: true, rtl: false, pauseOnFocusLoss: true, draggable: true, pauseOnHover: true, theme: "light", transition: Slide }));
const aguarde = () => toast.loading(() => react_1.default.createElement(Typography, { sx: { marginLeft: 4 } }, "\"Aguarde...\""), {
icon: () => (react_1.default.createElement(Avatar, { src: (0, dist_2.estaticos)("link-servidor").imagens["quero-quero.gif"], alt: "Carregando..." })),
icon: () => (react_1.default.createElement(Avatar, { src: (0, dist_1.estaticos)("link-servidor").imagens["quero-quero.gif"], alt: "Carregando..." })),
});
const exibir = (res, id) => {
console.table(res);
@ -66,11 +66,11 @@ const componentesAlerta = ({ mui_material: { Avatar, Typography }, react_toastif
toast.dismiss(this.id);
}
erro(mensagem) {
this.exibir(dist_1.respostaComuns.erro(mensagem));
this.exibir(p_respostas_1.respostaComuns.erro(mensagem));
return this;
}
erroCatch(erro) {
const erroResposta = dist_1.respostaComuns.erro(erro.response?.data?.mensagem
const erroResposta = p_respostas_1.respostaComuns.erro(erro.response?.data?.mensagem
? erro.response?.data?.mensagem
: erro.message
? erro.message
@ -81,7 +81,7 @@ const componentesAlerta = ({ mui_material: { Avatar, Typography }, react_toastif
return this;
}
sucesso(mensagem) {
this.exibir(dist_1.respostaComuns.valor(mensagem));
this.exibir(p_respostas_1.respostaComuns.valor(mensagem));
return this;
}
}