|
| 1 | +import React from 'react'; |
| 2 | +import { NavLink, useLocation } from 'react-router-dom'; |
| 3 | +import { useSelector } from 'react-redux'; |
| 4 | +import { useSidebar } from '../SidebarContext'; |
| 5 | +import styles from './EducationPortalSideNav.module.css'; |
| 6 | + |
| 7 | +const EducationPortalSideNav = () => { |
| 8 | + const location = useLocation(); |
| 9 | + const authUser = useSelector(state => state.auth?.user); |
| 10 | + const { isMinimized, setIsMinimized } = useSidebar(); |
| 11 | + |
| 12 | + const menuItems = [ |
| 13 | + { icon: '🏠', label: 'Homepage', path: '/educationportal' }, |
| 14 | + { icon: '📊', label: 'Knowledge Evaluation', path: '#' }, |
| 15 | + { icon: '📋', label: 'Past Lesson Plans', path: '#' }, |
| 16 | + { icon: '⭐', label: 'My Saved Interests', path: '#' }, |
| 17 | + { icon: '📈', label: 'Evaluation results', path: '/educationportal/evaluation-results' }, |
| 18 | + { icon: '🏗️', label: 'Build Lesson Plan', path: '#' }, |
| 19 | + ]; |
| 20 | + |
| 21 | + const isActive = path => path !== '#' && location.pathname === path; |
| 22 | + |
| 23 | + return ( |
| 24 | + <aside className={`${styles.sidebar} ${isMinimized ? styles.minimized : ''}`}> |
| 25 | + {/* User Welcome Section */} |
| 26 | + <div className={styles.userSection}> |
| 27 | + <div className={styles.welcomeIcon}>👋</div> |
| 28 | + {!isMinimized && ( |
| 29 | + <> |
| 30 | + <div className={styles.welcomeText}> |
| 31 | + <div className={styles.welcomeLabel}>Welcome</div> |
| 32 | + <div className={styles.userName}>{authUser?.firstName || 'Student'}</div> |
| 33 | + </div> |
| 34 | + <div className={styles.notifyIcon}>🔔</div> |
| 35 | + </> |
| 36 | + )} |
| 37 | + {isMinimized && ( |
| 38 | + <button |
| 39 | + className={styles.toggleButton} |
| 40 | + onClick={() => setIsMinimized(!isMinimized)} |
| 41 | + title="Expand sidebar" |
| 42 | + aria-label="Expand sidebar" |
| 43 | + > |
| 44 | + ➜ |
| 45 | + </button> |
| 46 | + )} |
| 47 | + </div> |
| 48 | + |
| 49 | + {/* Toggle Button - Only show when expanded */} |
| 50 | + {!isMinimized && ( |
| 51 | + <div className={styles.toggleButtonContainer}> |
| 52 | + <button |
| 53 | + className={styles.minimizeBtn} |
| 54 | + onClick={() => setIsMinimized(!isMinimized)} |
| 55 | + title="Minimize sidebar" |
| 56 | + aria-label="Minimize sidebar" |
| 57 | + > |
| 58 | + ⬅️ |
| 59 | + </button> |
| 60 | + </div> |
| 61 | + )} |
| 62 | + |
| 63 | + {/* Navigation Menu */} |
| 64 | + <nav className={styles.nav}> |
| 65 | + <ul className={styles.menuList}> |
| 66 | + {menuItems.map(item => ( |
| 67 | + <li key={item.label} className={styles.menuItem}> |
| 68 | + {item.path !== '#' ? ( |
| 69 | + <NavLink |
| 70 | + to={item.path} |
| 71 | + className={`${styles.menuLink} ${isActive(item.path) ? styles.active : ''}`} |
| 72 | + > |
| 73 | + <span className={styles.icon}>{item.icon}</span> |
| 74 | + <span className={styles.label}>{item.label}</span> |
| 75 | + </NavLink> |
| 76 | + ) : ( |
| 77 | + <div className={styles.menuLink}> |
| 78 | + <span className={styles.icon}>{item.icon}</span> |
| 79 | + <span className={styles.label}>{item.label}</span> |
| 80 | + </div> |
| 81 | + )} |
| 82 | + </li> |
| 83 | + ))} |
| 84 | + </ul> |
| 85 | + </nav> |
| 86 | + </aside> |
| 87 | + ); |
| 88 | +}; |
| 89 | + |
| 90 | +export default EducationPortalSideNav; |
0 commit comments