Added toast alerts to login/register pages
This commit is contained in:
1 parent
7462458eca
commit
e4c179f63d
4 files changed
+41
-19
No files matched your search
@@ -20,6 +20,8 @@ import NewPasswordConfirmed from "./Pages/NewPasswordConfirmed";
|
|||||||
import ProtectedRoute from "./Components/ProtectedRoute";
|
import ProtectedRoute from "./Components/ProtectedRoute";
|
||||||
import Details from "./Pages/Details";
|
import Details from "./Pages/Details";
|
||||||
import Maintenance from "./Pages/Maintenance";
|
import Maintenance from "./Pages/Maintenance";
|
||||||
|
import "react-toastify/dist/ReactToastify.css";
|
||||||
|
import { ToastContainer } from "react-toastify";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
@@ -92,6 +94,7 @@ function App() {
|
|||||||
element={<NewPasswordConfirmed />}
|
element={<NewPasswordConfirmed />}
|
||||||
/>
|
/>
|
||||||
</Routes>
|
</Routes>
|
||||||
|
<ToastContainer />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import ProfilePanel from "../../Components/TabPanels/Account/ProfilePanel";
|
|||||||
import PasswordPanel from "../../Components/TabPanels/Account/PasswordPanel";
|
import PasswordPanel from "../../Components/TabPanels/Account/PasswordPanel";
|
||||||
import TeamPanel from "../../Components/TabPanels/Account/TeamPanel";
|
import TeamPanel from "../../Components/TabPanels/Account/TeamPanel";
|
||||||
import { useNavigate } from "react-router";
|
import { useNavigate } from "react-router";
|
||||||
import "react-toastify/dist/ReactToastify.css";
|
|
||||||
import { ToastContainer } from "react-toastify";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account component renders a settings page with tabs for Profile, Password, and Team settings.
|
* Account component renders a settings page with tabs for Profile, Password, and Team settings.
|
||||||
@@ -75,7 +73,6 @@ const Account = ({ open = "profile" }) => {
|
|||||||
<PasswordPanel />
|
<PasswordPanel />
|
||||||
<TeamPanel />
|
<TeamPanel />
|
||||||
</TabContext>
|
</TabContext>
|
||||||
<ToastContainer />
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import axiosInstance from "../../Utils/axiosConfig";
|
|||||||
import { loginValidation } from "../../Validation/validation";
|
import { loginValidation } from "../../Validation/validation";
|
||||||
import { login } from "../../Features/Auth/authSlice";
|
import { login } from "../../Features/Auth/authSlice";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
|
import { createToast } from "../../Utils/toastUtils";
|
||||||
|
|
||||||
const Login = () => {
|
const Login = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@@ -74,16 +75,26 @@ const Login = () => {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.name === "ValidationError") {
|
if (error.name === "ValidationError") {
|
||||||
// TODO Handle validation errors
|
// validation errors
|
||||||
console.log(error.details);
|
createToast({
|
||||||
alert(error);
|
variant: "info",
|
||||||
|
body: error.details[0].message,
|
||||||
|
hasIcon: false,
|
||||||
|
});
|
||||||
} else if (error.response) {
|
} else if (error.response) {
|
||||||
// TODO handle dispatch errors
|
// dispatch errors
|
||||||
alert(error.response.msg);
|
createToast({
|
||||||
|
variant: "info",
|
||||||
|
body: error.response.msg,
|
||||||
|
hasIcon: false,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// TODO handle unknown errors
|
// unknown errors
|
||||||
console.log(error);
|
createToast({
|
||||||
alert("Unknown error");
|
variant: "info",
|
||||||
|
body: "Unknown error.",
|
||||||
|
hasIcon: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { registerValidation } from "../../Validation/validation";
|
|||||||
import axiosInstance from "../../Utils/axiosConfig";
|
import axiosInstance from "../../Utils/axiosConfig";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { register } from "../../Features/Auth/authSlice";
|
import { register } from "../../Features/Auth/authSlice";
|
||||||
|
import { createToast } from "../../Utils/toastUtils";
|
||||||
|
|
||||||
const Register = () => {
|
const Register = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@@ -91,16 +92,26 @@ const Register = () => {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.name === "ValidationError") {
|
if (error.name === "ValidationError") {
|
||||||
// TODO Handle validation errors
|
// validation errors
|
||||||
console.log(error);
|
createToast({
|
||||||
alert(error);
|
variant: "info",
|
||||||
|
body: error.details[0].message,
|
||||||
|
hasIcon: false,
|
||||||
|
});
|
||||||
} else if (error.response) {
|
} else if (error.response) {
|
||||||
// TODO handle dispatch errors
|
// dispatch errors
|
||||||
alert(error.response.msg);
|
createToast({
|
||||||
|
variant: "info",
|
||||||
|
body: error.response.msg,
|
||||||
|
hasIcon: false,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// TODO handle unknown errors
|
// unknown errors
|
||||||
console.log(error);
|
createToast({
|
||||||
alert("Unknown error");
|
variant: "info",
|
||||||
|
body: "Unknown error.",
|
||||||
|
hasIcon: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user