Skip to content

Commit bafd812

Browse files
author
Uttam Singh
committed
Redesigned Admin Dashboard with top navigation bar and logo
1 parent d498a15 commit bafd812

File tree

1 file changed

+78
-73
lines changed

1 file changed

+78
-73
lines changed

frontend/src/pages/AdminDashboard.jsx

Lines changed: 78 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ export default function AdminDashboard() {
1212
const [message, setMessage] = useState("");
1313
const [users, setUsers] = useState([]);
1414

15-
// handle inputs
1615
const handleChange = (e) =>
1716
setFormData({ ...formData, [e.target.name]: e.target.value });
1817

19-
// Create new user
2018
const handleSubmit = async (e) => {
2119
e.preventDefault();
2220
setMessage("Creating user...");
@@ -41,23 +39,22 @@ export default function AdminDashboard() {
4139
role: "auditee",
4240
});
4341
} else {
44-
setMessage(`❌ ${data.detail || data.error || "Failed to create user"}`);
42+
setMessage(`❌ ${data.detail || "Failed to create user"}`);
4543
}
46-
} catch (err) {
44+
} catch {
4745
setMessage("⚠️ Network error. Please try again later.");
4846
}
4947
};
5048

51-
// Fetch users
5249
const fetchUsers = async () => {
5350
try {
5451
const res = await fetch(
5552
"https://fat-eibl-backend-x1sp.onrender.com/users/all"
5653
);
5754
const data = await res.json();
5855
if (data.ok) setUsers(data.users);
59-
} catch (err) {
60-
console.error(err);
56+
} catch (e) {
57+
console.error(e);
6158
}
6259
};
6360

@@ -67,30 +64,33 @@ export default function AdminDashboard() {
6764

6865
return (
6966
<div style={styles.container}>
70-
{/* Sidebar */}
71-
<aside style={styles.sidebar}>
72-
<div style={styles.logo}>💼 FAT-EIBL</div>
73-
<nav>
74-
<ul style={styles.navList}>
75-
<li style={styles.active}>Dashboard</li>
76-
<li>Users</li>
77-
<li>Departments</li>
78-
<li>Reports</li>
79-
<li>Settings</li>
80-
</ul>
81-
</nav>
82-
</aside>
67+
{/* TOP NAVBAR */}
68+
<nav style={styles.navbar}>
69+
<div style={styles.logoSection}>
70+
<img
71+
src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Blue_circle_logo.svg/120px-Blue_circle_logo.svg.png"
72+
alt="logo"
73+
style={styles.logo}
74+
/>
75+
<span style={styles.logoText}>FAT-EIBL</span>
76+
</div>
77+
<div style={styles.navLinks}>
78+
<a href="#" style={styles.linkActive}>Dashboard</a>
79+
<a href="#">Users</a>
80+
<a href="#">Departments</a>
81+
<a href="#">Reports</a>
82+
<a href="#">Settings</a>
83+
</div>
84+
</nav>
8385

84-
{/* Main content */}
86+
{/* MAIN CONTENT */}
8587
<main style={styles.main}>
86-
<header style={styles.header}>
87-
<h1 style={styles.title}>Admin Dashboard</h1>
88-
<p style={styles.subtitle}>
89-
Manage users, departments, and system access.
90-
</p>
91-
</header>
88+
<h1 style={styles.title}>Admin Dashboard</h1>
89+
<p style={styles.subtitle}>
90+
Manage users, departments, and system access.
91+
</p>
9292

93-
{/* Create User Card */}
93+
{/* FORM CARD */}
9494
<div style={styles.card}>
9595
<h2 style={styles.cardTitle}>Create New User</h2>
9696
<form onSubmit={handleSubmit} style={styles.form}>
@@ -114,7 +114,6 @@ export default function AdminDashboard() {
114114
required
115115
/>
116116
</div>
117-
118117
<div style={styles.row}>
119118
<input
120119
type="password"
@@ -134,7 +133,6 @@ export default function AdminDashboard() {
134133
style={styles.input}
135134
/>
136135
</div>
137-
138136
<div style={styles.row}>
139137
<input
140138
type="email"
@@ -164,7 +162,8 @@ export default function AdminDashboard() {
164162
{message && (
165163
<p
166164
style={{
167-
...styles.message,
165+
marginTop: "15px",
166+
textAlign: "center",
168167
color: message.startsWith("✅")
169168
? "green"
170169
: message.startsWith("⚠️")
@@ -177,11 +176,11 @@ export default function AdminDashboard() {
177176
)}
178177
</div>
179178

180-
{/* User Table */}
179+
{/* USER LIST */}
181180
<div style={styles.tableCard}>
182181
<h3 style={styles.tableTitle}>Registered Users</h3>
183182
{users.length === 0 ? (
184-
<p style={{ color: "#777", textAlign: "center" }}>
183+
<p style={{ textAlign: "center", color: "#777" }}>
185184
No users found.
186185
</p>
187186
) : (
@@ -196,7 +195,10 @@ export default function AdminDashboard() {
196195
</thead>
197196
<tbody>
198197
{users.map((u, i) => (
199-
<tr key={i} style={i % 2 ? styles.rowAlt : styles.rowNormal}>
198+
<tr
199+
key={i}
200+
style={i % 2 === 0 ? styles.rowNormal : styles.rowAlt}
201+
>
200202
<td style={styles.td}>{u.name}</td>
201203
<td style={styles.td}>{u.email}</td>
202204
<td style={styles.td}>{u.department || "-"}</td>
@@ -212,67 +214,73 @@ export default function AdminDashboard() {
212214
);
213215
}
214216

215-
// ====== STYLES =======
217+
// =======================
218+
// STYLES
219+
// =======================
216220
const styles = {
217221
container: {
218-
display: "flex",
219-
backgroundColor: "#f4f7fb",
220-
minHeight: "100vh",
221222
fontFamily: "'Inter', sans-serif",
223+
backgroundColor: "#f5f8fc",
224+
minHeight: "100vh",
222225
},
223-
sidebar: {
224-
width: "220px",
225-
background: "#004aad",
226+
navbar: {
227+
display: "flex",
228+
justifyContent: "space-between",
229+
alignItems: "center",
230+
backgroundColor: "#004aad",
226231
color: "white",
227-
padding: "20px 15px",
232+
padding: "10px 40px",
233+
boxShadow: "0 2px 10px rgba(0,0,0,0.1)",
234+
},
235+
logoSection: {
228236
display: "flex",
229-
flexDirection: "column",
230237
alignItems: "center",
238+
gap: "12px",
231239
},
232240
logo: {
233-
fontWeight: 700,
241+
width: "35px",
242+
height: "35px",
243+
borderRadius: "50%",
244+
backgroundColor: "white",
245+
objectFit: "cover",
246+
},
247+
logoText: {
234248
fontSize: "1.3rem",
235-
marginBottom: "40px",
249+
fontWeight: "700",
250+
letterSpacing: "0.5px",
236251
},
237-
navList: {
238-
listStyle: "none",
239-
padding: 0,
240-
width: "100%",
241-
textAlign: "left",
252+
navLinks: {
253+
display: "flex",
254+
gap: "30px",
242255
},
243-
active: {
244-
background: "#003b80",
245-
borderRadius: "8px",
246-
padding: "10px 15px",
247-
marginBottom: "10px",
248-
cursor: "pointer",
256+
linkActive: {
257+
fontWeight: "600",
258+
textDecoration: "underline",
249259
},
250260
main: {
251-
flex: 1,
252-
padding: "40px 60px",
253-
},
254-
header: {
255-
marginBottom: "30px",
261+
padding: "40px 80px",
256262
},
257263
title: {
258264
fontSize: "2rem",
259-
color: "#003b80",
260265
fontWeight: "700",
266+
color: "#003b80",
261267
marginBottom: "5px",
262268
},
263269
subtitle: {
264270
color: "#6b7a99",
265271
fontSize: "1rem",
272+
marginBottom: "30px",
266273
},
267274
card: {
268-
background: "white",
275+
backgroundColor: "white",
269276
borderRadius: "12px",
270277
padding: "30px",
271278
boxShadow: "0 3px 10px rgba(0,0,0,0.1)",
272279
marginBottom: "40px",
273280
},
274281
cardTitle: {
275282
color: "#004aad",
283+
fontWeight: "600",
276284
borderBottom: "2px solid #004aad",
277285
display: "inline-block",
278286
marginBottom: "20px",
@@ -299,21 +307,19 @@ const styles = {
299307
borderRadius: "8px",
300308
border: "1px solid #d0d7e2",
301309
fontSize: "1rem",
302-
backgroundColor: "white",
303310
},
304311
button: {
305-
background: "#004aad",
312+
backgroundColor: "#004aad",
306313
color: "white",
307314
border: "none",
308315
padding: "12px",
309316
borderRadius: "8px",
310317
fontSize: "1rem",
311318
fontWeight: "600",
312319
cursor: "pointer",
313-
marginTop: "10px",
314320
},
315321
tableCard: {
316-
background: "white",
322+
backgroundColor: "white",
317323
borderRadius: "12px",
318324
padding: "25px",
319325
boxShadow: "0 3px 10px rgba(0,0,0,0.08)",
@@ -340,11 +346,10 @@ const styles = {
340346
color: "#333",
341347
fontSize: "0.95rem",
342348
},
343-
rowAlt: { backgroundColor: "#f9faff" },
344-
rowNormal: { backgroundColor: "white" },
345-
message: {
346-
marginTop: "15px",
347-
textAlign: "center",
348-
fontWeight: "500",
349+
rowAlt: {
350+
backgroundColor: "#f9faff",
351+
},
352+
rowNormal: {
353+
backgroundColor: "white",
349354
},
350355
};

0 commit comments

Comments
 (0)