-
-
Notifications
You must be signed in to change notification settings - Fork 611
fix(edit-user): redirect current user to profile page when accessing … #2743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,17 +9,29 @@ import Button from "@mui/material/Button"; | |
| import RoleTable from "../components/RoleTable"; | ||
|
|
||
| // Utils | ||
| import { useParams } from "react-router-dom"; | ||
| import { Navigate, useParams } from "react-router-dom"; | ||
| import { useTheme } from "@emotion/react"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { useGetUser, useEditUser } from "../../../Hooks/userHooks"; | ||
| import { EDITABLE_ROLES, ROLES } from "../../../Utils/roleUtils"; | ||
| import { useEditUserForm, useValidateEditUserForm } from "./hooks/editUser"; | ||
| import { useSelector } from "react-redux"; | ||
| import { useEffect } from "react"; | ||
|
|
||
| const EditUser = () => { | ||
| const { userId } = useParams(); | ||
| const theme = useTheme(); | ||
| const { t } = useTranslation(); | ||
| const currentUser = useSelector((state) => state.auth.user); | ||
|
|
||
| if (currentUser?._id && userId === currentUser._id) { | ||
| return ( | ||
| <Navigate | ||
| to="/account/profile" | ||
| replace | ||
| /> | ||
| ); | ||
| } | ||
| const BREADCRUMBS = [ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Conditionally returning a redirect before calling hooks is a violation of the rules of hooks. This redirect should occur only after hooks have been called. Please use our include |
||
| { name: t("menu.team"), path: "/account/team" }, | ||
| { name: t("editUserPage.title"), path: "" }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dependency is unused, please do remove it