Skip to content

Commit

Permalink
run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Joabesv committed May 24, 2024
1 parent 773ab92 commit 92c99bf
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 39 deletions.
32 changes: 19 additions & 13 deletions src/scripts/contentScriptSigaa.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { scrapeGradesConsulting, scrapeHomepage } from "../utils/sigaa";
import { NextAPI } from "../services/NextAPI";
import { errorToast, redirectToast, processingToast } from "../utils/nextToasts";
import {
errorToast,
redirectToast,
processingToast,
} from "../utils/nextToasts";

const nextApi = NextAPI();

Expand All @@ -12,21 +16,23 @@ if (
document.contains(document.querySelector("#agenda-docente"))
) {
const student = scrapeHomepage();
const toast = redirectToast(student.name);
const toast = redirectToast(student.name);
localStorage.setItem("studentInfo", JSON.stringify(student));
toast.showToast();
toast.showToast();
}

if (isDiscentesPath && document.contains(document.querySelector(".notas"))) {
processingToast.showToast();
const studentHistory = scrapeGradesConsulting();
const { data: res } = nextApi.post("/histories/sigaa", studentHistory, {
timeout: 60 * 1 * 1000, // 1 minute
}).catch(err => {
processingToast.hideToast();
console.log(err);
errorToast.showToast();
});
processingToast.showToast();
const studentHistory = scrapeGradesConsulting();
const { data: res } = nextApi
.post("/histories/sigaa", studentHistory, {
timeout: 60 * 1 * 1000, // 1 minute
})
.catch((err) => {
processingToast.hideToast();
console.log(err);
errorToast.showToast();
});

console.log(res)
console.log(res);
}
53 changes: 27 additions & 26 deletions src/utils/nextToasts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,41 @@ const errorSVG = require("../images/error.svg");
Utils.injectStyle("styles/portal.css");

const errorToast = Toastify({
text: `
text: `
<div style="width: 228px; display: flex; align-items: end; margin-right: 12px;">
<img style="margin-right: 16px;" width="32" height="32" src="${errorSVG}" />
Não foi possível salvar seus dados, recarregue a página e aguarde.
</div>`,
duration: -1,
close: true,
gravity: "top",
position: "right",
className: "toast-error-container",
escapeMarkup: false,
style: {
background: "#E74C3C;",
},
duration: -1,
close: true,
gravity: "top",
position: "right",
className: "toast-error-container",
escapeMarkup: false,
style: {
background: "#E74C3C;",
},
});

const redirectToast = (studentname) => Toastify({
text: `
const redirectToast = (studentname) =>
Toastify({
text: `
<div class='toast-loading-text' style='width: 250px'>
<img src=${logoWhite} width="120" style="margin-bottom: 8px" />
<p style="padding-bottom: 8px;">${studentname} Acesse suas notas!</p>\n\n
<b>Clique no menu Ensino > consultar minhas notas</b>
</div>`,
gravity: "bottom",
position: "right",
duration: 5000,
style: {
background:
"linear-gradient(to right, #2E7EED, rgba(46, 126, 237, 0.5));",
},
escapeMarkup: false,
});
gravity: "bottom",
position: "right",
duration: 5000,
style: {
background:
"linear-gradient(to right, #2E7EED, rgba(46, 126, 237, 0.5));",
},
escapeMarkup: false,
});

const processingToast = Toastify({
const processingToast = Toastify({
text: `
<div class='toast-loading-text' style='width: 250px'>
<img src=${logoWhite} width="120" style="margin-bottom: 8px" />
Expand All @@ -62,7 +63,7 @@ const processingToast = Toastify({
});

module.exports = {
errorToast,
redirectToast,
processingToast,
}
errorToast,
redirectToast,
processingToast,
};

0 comments on commit 92c99bf

Please sign in to comment.