Simplified toast function call

This commit is contained in:
Daniel Cojocea committed 2024-07-18 10:43:46 -04:00
1 parent 783d745181
commit 5150179193
8 files changed
+9 -61

No files matched your search

@@ -79,9 +79,7 @@ const PasswordPanel = () => {
const action = await dispatch(update({ authToken, localData }));
if (action.payload.success) {
createToast({
variant: "info",
body: "Your password was changed successfully.",
hasIcon: false,
});
setLocalData({
password: "",
@@ -91,9 +89,7 @@ const PasswordPanel = () => {
} else {
// TODO: Check for other errors?
createToast({
variant: "info",
body: "Your password input was incorrect.",
hasIcon: false,
});
setErrors({ password: "*" + action.payload.msg + "." });
}
@@ -162,9 +162,7 @@ const ProfilePanel = () => {
localData.file === undefined
) {
createToast({
variant: "info",
body: "Unable to update profile — no changes detected.",
hasIcon: false,
});
setErrors({ unchanged: "unable to update profile" });
return;
@@ -173,15 +171,11 @@ const ProfilePanel = () => {
const action = await dispatch(update({ authToken, localData }));
if (action.payload.success) {
createToast({
variant: "info",
body: "Your profile data was changed successfully.",
hasIcon: false,
});
} else {
createToast({
variant: "error",
body: "There was an error updating your profile data.",
hasIcon: false,
});
}
};
@@ -205,16 +199,12 @@ const ProfilePanel = () => {
if (action.payload) {
// dispatch errors
createToast({
variant: "info",
body: action.payload.msg,
hasIcon: false,
});
} else {
// unknown errors
createToast({
variant: "info",
body: "Unknown error.",
hasIcon: false,
});
}
}