Added toast alerts to password panel

This commit is contained in:
Daniel Cojocea
2024-07-11 19:00:31 -04:00
parent e9bab07309
commit 8bd8c292b8
2 changed files with 12 additions and 3 deletions
@@ -8,6 +8,7 @@ import { editPasswordValidation } from "../../../Validation/validation";
import Alert from "../../Alert";
import { update } from "../../../Features/Auth/authSlice";
import { useDispatch, useSelector } from "react-redux";
import { createToast } from "../../../Utils/toastUtils";
/**
* PasswordPanel component manages the form for editing password.
@@ -78,15 +79,23 @@ const PasswordPanel = () => {
} else {
const action = await dispatch(update({ authToken, localData }));
if (action.payload.success) {
// TODO: Add toast/notification for password update success
createToast({
variant: "info",
body: "Your password was changed successfully.",
hasIcon: false,
});
setLocalData({
password: "",
newPassword: "",
confirm: "",
});
} else {
// TODO: Add toast/notification for password update rejected
// TODO: Check for other errors?
createToast({
variant: "info",
body: "Your password input was incorrect.",
hasIcon: false,
});
setErrors({ password: "*" + action.payload.msg + "." });
}
}
@@ -86,7 +86,7 @@ const ProfilePanel = () => {
delete: false,
});
//TODO - potentitally remove once image compression functions are implemented
//TODO - potentitally remove, will revisit in the future
intervalRef.current = setInterval(() => {
const buffer = 12;
setProgress((prev) => {