Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion client/src/Pages/Account/EditUser/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Copy link
Collaborator

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


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 = [
Copy link
Collaborator

@ajhollid ajhollid Aug 8, 2025

Choose a reason for hiding this comment

The 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 .eslintrc config to lint your code before submitting PRs, these types of errors should be caught by the linter.

{ name: t("menu.team"), path: "/account/team" },
{ name: t("editUserPage.title"), path: "" },
Expand Down
4 changes: 2 additions & 2 deletions client/src/Pages/Account/components/TeamPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ const TeamPanel = () => {
};
let team = members;
if (filter !== "all")
team = members.filter((member) => {
team = members?.filter((member) => {
if (filter === "admin") {
return member.role.includes("admin") || member.role.includes("superadmin");
}
return member.role.includes(filter);
});

team = team.map((member) => ({
team = team?.map((member) => ({
...member,
id: member._id,
role: member.role.map((role) => ROLE_MAP[role]).join(","),
Expand Down