File size: 1,493 Bytes
ec47790 | 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 | import React from "react";
import { Link, useNavigate, useLocation } from "react-router-dom";
function Sidebar() {
const navigate = useNavigate();
const location = useLocation();
const handleLogout = () => {
localStorage.removeItem("user");
localStorage.removeItem("predictionResult");
navigate("/login");
};
const isActive = (path) => location.pathname === path;
return (
<div className="sidebar">
<div>
<h2 className="logo">AI Doctor</h2>
<div className="sidebar-links">
<Link className={isActive("/dashboard") ? "active-link" : ""} to="/dashboard">π Dashboard</Link>
<Link className={isActive("/prediction") ? "active-link" : ""} to="/prediction">π©Ί Prediction</Link>
<Link className={isActive("/result") ? "active-link" : ""} to="/result">π Result</Link>
<Link className={isActive("/history") ? "active-link" : ""} to="/history">π History</Link>
<Link className={isActive("/appointments") ? "active-link" : ""} to="/appointments">π
Appointments</Link>
<Link className={isActive("/doctors") ? "active-link" : ""} to="/doctors">π¨ββοΈ Doctors</Link>
<Link className={isActive("/reports") ? "active-link" : ""} to="/reports">π Reports</Link>
</div>
</div>
<button className="logout-btn" onClick={handleLogout}>
Logout
</button>
</div>
);
}
export default Sidebar; |