Skip to content

Commit

Permalink
add scrapping error toast
Browse files Browse the repository at this point in the history
  • Loading branch information
Joabesv committed Dec 16, 2024
1 parent 643e8df commit ed38979
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/scripts/sig/homepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,9 @@ export async function scrapeMenu(
): Promise<Student | null> {
const { data: page, error } = await fetchGrades();
if (error || !page) {
console.log({
msg: 'Ocorreu um erro ao extrair as disciplinas cursadas, por favor tente novamente mais tarde!',
error,
});
const msg = 'Ocorreu um erro ao extrair as disciplinas cursadas, por favor tente novamente mais tarde!'
console.error(error)
scrappingErrorToast(msg).showToast();
return null;
}

Expand Down
1 change: 0 additions & 1 deletion src/utils/season.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export function calculateQuadrimestres({

// Get current season
const currentSeason = findSeason();
console.log(currentSeason, entranceQuad)
// Calculate total quadrimestres
const totalQuadrimestres = (currentSeason.year - year) * 3 + (currentSeason.quad - quad) + 1;

Expand Down
18 changes: 18 additions & 0 deletions src/utils/toasts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,21 @@ export const errorToast = toast({
background: '#E74C3C;',
},
});


export const scrappingErrorToast = (msg: string) => toast({
text: `
<div style="width: 228px; display: flex; align-items: end; margin-right: 12px;">
<img style="margin-right: 16px;" width="32" height="32" src=${errorImg} />
${msg}
</div>`,
duration: -1,
close: true,
gravity: 'bottom',
position: 'right',
className: 'toast-error-container',
escapeMarkup: false,
style: {
background: '#E74C3C;',
},
});

0 comments on commit ed38979

Please sign in to comment.