Skip to content

Commit

Permalink
replace alert with toast in Report
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikeW committed Aug 4, 2022
1 parent 1c0fd61 commit bc7857e
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions frontend/src/pages/Report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,14 @@ export const Report = () => {
}
})
.catch((error) => {
alert(error);
setToastList([
...toastList,
{
type: "warning",
timeout: 5000,
message: error.message,
},
]);
const favs = [...favorites];
setFavorites(favs);
return false;
Expand Down Expand Up @@ -400,13 +407,44 @@ export const Report = () => {
}
})
.catch((error) => {
alert(error);
setToastList([
...toastList,
{
type: "warning",
timeout: 5000,
message: error.message,
},
]);
return false;
});
if (logout) context.setUser(null);
return saved;
};

// Make sure that the custom issue name is saved in the database.
const handleCustomNamesSave = async () => {
const saved = await saveFavorites([...favorites, ...hidden]);
if (!saved) {
setToastList([
...toastList,
{
type: "warning",
timeout: 5000,
message: "Favourite rows could not be saved. Please try again later.",
},
]);
return;
}
setToastList([
...toastList,
{
type: "success",
timeout: 3000,
message: "Custom names were saved!",
},
]);
};

// Check for ...
const handleSave = async () => {
setShowUnsavedWarning(false);
Expand Down Expand Up @@ -462,7 +500,14 @@ export const Report = () => {
});
}
if (recentIssue) {
alert("This issue/activity pair is already added");
setToastList([
...toastList,
{
type: "warning",
timeout: 5000,
message: "This issue/activity pair is already added.",
},
]);
return;
}
const newRecentIssues = [...filteredRecents, pair];
Expand Down

0 comments on commit bc7857e

Please sign in to comment.