-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.html
More file actions
114 lines (94 loc) · 3.48 KB
/
profile.html
File metadata and controls
114 lines (94 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Pawmart – My Profile</title>
<link rel="stylesheet" href="styles.css" />
<style>
.profile-wrapper {
max-width: 700px;
margin: 40px auto;
background: #fff;
padding: 30px;
border-radius: 18px;
box-shadow: 0 8px 26px rgba(0,0,0,0.08);
text-align: center;
}
.profile-title {
font-size: 24px;
font-weight: 700;
color: #283593;
margin-bottom: 10px;
}
.profile-field {
font-size: 16px;
margin: 12px 0;
color: #444;
}
.profile-label {
font-weight: bold;
}
.profile-btn {
background: #3d43e1;
color: white;
padding: 10px 20px;
border-radius: 999px;
border: none;
margin-top: 20px;
cursor: pointer;
font-size: 14px;
}
.profile-btn:hover {
background: #2f34b8;
}
.error-msg {
color: red;
margin-top: 10px;
}
</style>
</head>
<body class="background">
<header class="banner">
<img class="logo" src="images/pawmart.png" alt="Pawmart Logo" />
<h1 class="banner-title">Welcome to Pawmart!</h1>
</header>
<nav>
<div>
<a href="Homepage.html" id="nav-btn-homepage" class="nav-btn">Home</a>
<a href="profile.html" id="nav-btn-customer" class="nav-btn" style="display:none;">Profile</a>
<a href="admin-users.html" id="nav-btn-admin" class="nav-btn" style="display:none;">Admin Users</a>
<a href="products.html" id="nav-btn-products" class="nav-btn">Products</a>
<a href="sign-in.html" id="nav-btn-signin" class="nav-btn">Sign in</a>
<a href="sign-up.html" id="nav-btn-signup" class="nav-btn">Sign Up</a>
<button id="nav-btn-logout" class="nav-btn" style="display:none;">Log Out</button>
</div>
</nav>
<div class="profile-wrapper">
<h2 class="profile-title">My Profile</h2>
<p id="error" class="error-msg"></p>
<p class="profile-field"><span class="profile-label">Email:</span> <span id="email"></span></p>
<p class="profile-field"><span class="profile-label">Role:</span> <span id="role"></span></p>
<p class="profile-field"><span class="profile-label">User ID:</span> <span id="userid"></span></p>
<button class="profile-btn" id="back-home">Back to Home</button>
</div>
<script>
const token = localStorage.getItem("token");
const errorEl = document.getElementById("error");
if (!token) {
errorEl.textContent = "You are not logged in.";
} else {
try {
const payload = JSON.parse(atob(token.split(".")[1]));
document.getElementById("email").textContent = payload.email || "Unknown";
document.getElementById("role").textContent = payload.role || "Unknown";
document.getElementById("userid").textContent = payload.id || "Unknown";
} catch (err) {
errorEl.textContent = "Unable to read profile information.";
}
}
document.getElementById("back-home").addEventListener("click", () => {
window.location.href = "Homepage.html";
});
</script>
</body>
</html>