 import {Link} from 'react-router-dom'

 function Navbar(){
    const token = localStorage.getItem("token");
    return(
        <nav className="bg-[#ea580c] p-4 flex flex-col gap-2 shadow-md">
            {/* Title Heading */}
            <h1 className="text-gray-900 font-black text-lg tracking-tight px-2">
                School Fee Management System
            </h1>
            
            {/* Navigation Links Row */}
            <div className="flex items-center gap-6 px-2 text-sm font-semibold text-gray-800 w-full">
                {token ? (
                    <>
                    <Link to="/dashboard" className="hover:text-black transition-colors">Dashboard</Link>
                    <Link to="/fees" className="hover:text-black transition-colors">Fees</Link>
                    <Link to="/payments" className="hover:text-black transition-colors">Payments</Link>
                    <Link to="/records" className="hover:text-black transition-colors">Records</Link>
                    <Link to="/student" className="hover:text-black transition-colors">Student</Link>
                    <button 
                        onClick={() => {
                           localStorage.removeItem("token");
                           window.location.href ="/login";
                        }} 
                        className="hover:text-black transition-colors font-semibold cursor-pointer"
                    >
                        Logout
                    </button>
                    </>
                ):(
                    <>
                    {/* Pushes login and register to the far right when not logged in */}
                    <div className="flex gap-6 ml-auto">
                        <Link to="/login" className="hover:text-black transition-colors">Login</Link>
                        <Link to="/register" className="hover:text-black transition-colors">Register</Link>
                    </div>
                    </>
                )}
            </div>
        </nav>
    )
 }
 export default Navbar;
