Skip to content

Commit

Permalink
fix(frontend): refactor logic for roles
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiodmota committed May 14, 2024
1 parent f103b02 commit 41165db
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import { useState, useRef, useContext } from "react";
import { useState, useRef, useContext, useEffect } from "react";
import {
UserAvatar,
UserMenu,
Expand All @@ -36,7 +36,16 @@ import { CompanyUserContext } from "../../../../contexts/companyuser";
export const UserInfo = () => {
const [menuOpen, setMenuOpen] = useState(false);
const wrapperRef = useRef(null);
const { companyUser } = useContext(CompanyUserContext);
const { companyUser, setCompanyUser } = useContext(CompanyUserContext);

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable setCompanyUser.
const [cleanedRoles, setCleanedRoles] = useState([]);

useEffect(() => {
// Clean up roles by trimming whitespace
if (companyUser && companyUser.roles) {
const cleanedRoles = companyUser.roles.map((role) => role.trim());
setCleanedRoles(cleanedRoles);
}
}, [companyUser]);

const openCloseMenu = () => setMenuOpen((prevVal) => !prevVal);

Expand All @@ -56,7 +65,6 @@ export const UserInfo = () => {
},
];

const cleanedRoles = companyUser.roles.map((role) => role.trim());
// Add negotiation link for users with Negotiator or Admin roles
if (
cleanedRoles.includes("Negotiator") ||
Expand Down Expand Up @@ -89,3 +97,5 @@ export const UserInfo = () => {
</div>
);
};

export default UserInfo;

0 comments on commit 41165db

Please sign in to comment.