Skip to content

Commit f24a67e

Browse files
committed
Add Logout + Delete Button
1 parent 3e619f7 commit f24a67e

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

Frontend/src/Components/LandingPage/UserProfile.css

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,40 @@
104104
background: none;
105105
border: none;
106106
border-bottom: 3px solid;
107+
}
108+
109+
.profile-delete-container {
110+
display: flex;
111+
justify-content: center;
112+
align-items: center;
113+
gap: 10px;
114+
}
115+
.profile-delete-btn{
116+
display: flex;
117+
align-items: center;
118+
justify-content: center;
119+
padding: 10px;
120+
width: fit-content;
121+
height: 50px;
122+
color: #fff;
123+
background: #d63636;
124+
border: none;
125+
border-radius: 5px;
126+
font-size: 19px;
127+
cursor: pointer;
128+
}
129+
130+
.logout-btn{
131+
display: flex;
132+
align-items: center;
133+
justify-content: center;
134+
padding: 10px;
135+
width: fit-content;
136+
height: 50px;
137+
color: #fff;
138+
background: #000;
139+
border: none;
140+
border-radius: 5px;
141+
font-size: 19px;
142+
cursor: pointer;
107143
}

Frontend/src/Components/LandingPage/UserProfile.jsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ import {
77
getUserPreferredLanguage,
88
updateUserState,
99
} from "../../User/UserState";
10-
import {updateUserData} from "../../User/UserServiceAPI";
10+
import {updateUserData, deleteUser, logoutUser} from "../../User/UserServiceAPI";
11+
import {useNavigate} from "react-router-dom";
1112

1213
import edit_icon from "../Assets/pencil.png";
1314

1415
export const UserProfile = ({setUsername}) => {
16+
const navigate = useNavigate();
17+
1518
const [isEdit, setEdit] = useState(false);
1619
const [name, setName] = useState(getUserName());
1720
const [email, setEmail] = useState(getUserEmail());
@@ -23,6 +26,20 @@ export const UserProfile = ({setUsername}) => {
2326
setUsername(name);
2427
};
2528

29+
const handleLogout = async () => {
30+
const result = await logoutUser();
31+
if(result) {
32+
navigate("/login");
33+
}
34+
}
35+
36+
const handleDeleteUser = async () => {
37+
const result = await deleteUser();
38+
if(result) {
39+
navigate("/login");
40+
}
41+
}
42+
2643
return (
2744
<div className="profile-container">
2845
<div className="edit-container">
@@ -74,7 +91,17 @@ export const UserProfile = ({setUsername}) => {
7491
<div className="profile-detail">{lang}</div>
7592
)}
7693
</div>
94+
<div className="profile-delete-container">
95+
<div className="profile-delete-btn" onClick = {(e) => {handleDeleteUser()}}>
96+
Delete Account
97+
</div>
98+
99+
<div className="logout-btn" onClick = {(e) => {handleLogout()}}>
100+
Logout
101+
</div>
102+
</div>
77103
</div>
104+
78105

79106
{isEdit ? (
80107
<div className="profile-submit-container">

0 commit comments

Comments
 (0)