11import React , { useState , useEffect , useRef } from "react" ;
2- import "./AdminDashboard.css" ; // You can use CSS or keep inline styles
32
43export default function AdminDashboard ( ) {
54 const [ formData , setFormData ] = useState ( {
@@ -14,11 +13,14 @@ export default function AdminDashboard() {
1413 const [ message , setMessage ] = useState ( "" ) ;
1514 const [ users , setUsers ] = useState ( [ ] ) ;
1615 const [ dropdownOpen , setDropdownOpen ] = useState ( false ) ;
16+ const [ isCompact , setIsCompact ] = useState ( false ) ;
1717 const dropdownRef = useRef ( null ) ;
1818
19+ // === Handle Input Change ===
1920 const handleChange = ( e ) =>
2021 setFormData ( { ...formData , [ e . target . name ] : e . target . value } ) ;
2122
23+ // === Handle Form Submit ===
2224 const handleSubmit = async ( e ) => {
2325 e . preventDefault ( ) ;
2426 setMessage ( "Creating user..." ) ;
@@ -50,6 +52,7 @@ export default function AdminDashboard() {
5052 }
5153 } ;
5254
55+ // === Fetch Users ===
5356 const fetchUsers = async ( ) => {
5457 try {
5558 const res = await fetch (
@@ -66,6 +69,7 @@ export default function AdminDashboard() {
6669 fetchUsers ( ) ;
6770 } , [ ] ) ;
6871
72+ // === Handle Click Outside Dropdown ===
6973 useEffect ( ( ) => {
7074 const handleClickOutside = ( event ) => {
7175 if ( dropdownRef . current && ! dropdownRef . current . contains ( event . target ) ) {
@@ -76,20 +80,40 @@ export default function AdminDashboard() {
7680 return ( ) => document . removeEventListener ( "mousedown" , handleClickOutside ) ;
7781 } , [ ] ) ;
7882
83+ // === Compact Navbar on Scroll ===
84+ useEffect ( ( ) => {
85+ const handleScroll = ( ) => setIsCompact ( window . scrollY > 40 ) ;
86+ window . addEventListener ( "scroll" , handleScroll ) ;
87+ return ( ) => window . removeEventListener ( "scroll" , handleScroll ) ;
88+ } , [ ] ) ;
89+
7990 const handleLogout = ( ) => {
8091 localStorage . removeItem ( "user" ) ;
8192 window . location . href = "/" ;
8293 } ;
8394
8495 return (
8596 < div style = { styles . container } >
86- { /* === TOP NAVBAR === */ }
87- < header style = { styles . navbar } >
97+ { /* === NAVBAR === */ }
98+ < header
99+ style = { {
100+ ...styles . navbar ,
101+ padding : isCompact ? "6px 30px" : "14px 40px" ,
102+ transition : "all 0.3s ease" ,
103+ boxShadow : isCompact
104+ ? "0 3px 10px rgba(0,0,0,0.2)"
105+ : "0 2px 6px rgba(0,0,0,0.08)" ,
106+ } }
107+ >
88108 < div style = { styles . navLeft } >
89109 < img
90- src = { ` ${ process . env . PUBLIC_URL } /edme_logo.png` }
110+ src = " /edme_logo.png"
91111 alt = "FAT-EIBL Logo"
92- style = { styles . logo }
112+ style = { {
113+ ...styles . logo ,
114+ width : isCompact ? "36px" : "46px" ,
115+ height : isCompact ? "36px" : "46px" ,
116+ } }
93117 onError = { ( e ) => {
94118 e . target . src =
95119 "https://upload.wikimedia.org/wikipedia/commons/a/ac/No_image_available.svg" ;
@@ -143,7 +167,7 @@ export default function AdminDashboard() {
143167 Manage users, departments, and system access.
144168 </ p >
145169
146- { /* CREATE USER */ }
170+ { /* === CREATE USER CARD === */ }
147171 < div style = { styles . card } >
148172 < h2 style = { styles . cardTitle } > Create New User</ h2 >
149173 < form onSubmit = { handleSubmit } style = { styles . form } >
@@ -236,7 +260,7 @@ export default function AdminDashboard() {
236260}
237261
238262//
239- // === STYLES ===
263+ // === INLINE STYLES ===
240264//
241265const styles = {
242266 container : {
@@ -253,13 +277,9 @@ const styles = {
253277 display : "flex" ,
254278 justifyContent : "space-between" ,
255279 alignItems : "center" ,
256- padding : "12px 40px" ,
257- boxShadow : "0 2px 8px rgba(0,0,0,0.1)" ,
258280 } ,
259281 navLeft : { display : "flex" , alignItems : "center" , gap : "10px" } ,
260282 logo : {
261- width : "42px" ,
262- height : "42px" ,
263283 borderRadius : "6px" ,
264284 background : "#fff" ,
265285 padding : "4px" ,
@@ -268,19 +288,30 @@ const styles = {
268288 brand : { fontSize : "1.3rem" , fontWeight : "700" , color : "#fff" } ,
269289 navCenter : { display : "flex" , gap : "25px" } ,
270290 navLink : {
271- color : "#dbe9ff " ,
291+ color : "#dce7ff " ,
272292 textDecoration : "none" ,
273293 fontWeight : "500" ,
274294 transition : "color 0.3s ease" ,
275295 } ,
276296 activeLink : {
277297 color : "#fff" ,
278298 fontWeight : "700" ,
279- textDecoration : "underline" ,
299+ borderBottom : "2px solid white" ,
300+ paddingBottom : "2px" ,
280301 } ,
281302 userMenu : { position : "relative" } ,
282- userWrapper : { display : "flex" , alignItems : "center" , gap : "8px" , cursor : "pointer" } ,
283- avatar : { width : "40px" , height : "40px" , borderRadius : "50%" , border : "2px solid #fff" } ,
303+ userWrapper : {
304+ display : "flex" ,
305+ alignItems : "center" ,
306+ gap : "8px" ,
307+ cursor : "pointer" ,
308+ } ,
309+ avatar : {
310+ width : "40px" ,
311+ height : "40px" ,
312+ borderRadius : "50%" ,
313+ border : "2px solid #fff" ,
314+ } ,
284315 userName : { color : "#fff" , fontWeight : "500" } ,
285316 dropdown : {
286317 position : "absolute" ,
@@ -320,7 +351,7 @@ const styles = {
320351 marginBottom : "20px" ,
321352 } ,
322353 form : { display : "flex" , flexDirection : "column" , gap : "15px" } ,
323- row : { display : "flex" , gap : "15px" } ,
354+ row : { display : "flex" , gap : "15px" , flexWrap : "wrap" } ,
324355 input : {
325356 flex : 1 ,
326357 padding : "12px" ,
0 commit comments