Skip to content

Commit

Permalink
Merge pull request #34 from atlp-rwanda/Fix-profile-settings
Browse files Browse the repository at this point in the history
fixing profile settings
  • Loading branch information
UmuhireJessie authored Jul 24, 2024
2 parents 2b0cb9e + be99a4c commit 78e9fe9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 31 deletions.
3 changes: 3 additions & 0 deletions src/Pages/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,15 @@ const Login: React.FC = () => {
navigate(`/update/new-password?q=${token}`);
}else{
if (decodedToken.role === "buyer") {
localStorage.setItem("userId", `${decodedToken.userId}`);
navigate(`/${decodedToken.userId}`);
}
if (decodedToken.role === "seller") {
localStorage.setItem("userId", `${decodedToken.userId}`);
navigate(`/sellerDash/${decodedToken.userId}`);
}
if (decodedToken.role === "admin") {
localStorage.setItem("userId", `${decodedToken.userId}`);
navigate(`/adminDash/${decodedToken.userId}`);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const Navbar: React.FC<NavbarProps> = ({

const handleLogout = () => {
localStorage.removeItem("token");
localStorage.removeItem("userId");

window.location.href = "/";
};

Expand Down
36 changes: 5 additions & 31 deletions src/components/userDashHeader/UserHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const Header: React.FC = () => {
setIsLoading(true);
setTimeout(() => {
localStorage.removeItem("token");
localStorage.removeItem("userId");

dispatch(logoutUser());
setIsLoading(false);
navigate("/");
Expand Down Expand Up @@ -83,40 +85,12 @@ const Header: React.FC = () => {
width={35}
height={35}
/>
<h4 onClick={toggleVisibility}>MyAccount</h4>
<img
width={13}
height={13}
src="https://img.icons8.com/ios-glyphs/30/FFFFFF/chevron-down.png"
alt="chevron-down"
onClick={toggleVisibility}
className="arrow-down"
/>
</div>
</div>
</div>
<div className={`account-float ${isVisible ? "visible" : "hidden"}`}>
<div className="chat-container">
<div className="chat">
<div className="profile">
<img src={account} alt="Profile" />
</div>
<div className="name">
<h4>Hello,</h4>
</div>
<div className="time">{user ? user.firstName : "Loading..."}</div>
<div className="message">
<Link to={`/MyAccount/${id}`} className="linkStyle">
MyAccount
</Link>
</div>

<div className="pin" onClick={logout}>
Sign Out
</div>
<h4 onClick={toggleVisibility}>{user ? user.firstName : "Loading..."}</h4>

</div>
</div>
</div>

</div>
);
};
Expand Down

0 comments on commit 78e9fe9

Please sign in to comment.