import React from 'react';
import { Link, useNavigate } from 'react-router-dom';
import './header.css';

const Header = ({ isLoggedIn }) => {
  const navigate = useNavigate();

  const handleLogout = () => {
    localStorage.removeItem('token');
    navigate('/login');
    window.location.reload();
  };

  return (
    <header className="header">
      <nav className="nav">
        <ul className="navList">
          <li className="navItem">
            <Link to="/" className="navLink">Startseite</Link>
          </li>
          {!isLoggedIn && (
            <>
              <li className="navItem">
                <Link to="/login" className="navLink">Anmelden</Link>
              </li>
              <li className="navItem">
                <Link to="/register" className="navLink">Registrieren</Link>
              </li>
            </>
          )}
          {isLoggedIn && (
            <li className="navItem">
              <Link to="/profile" className="navLink">Profil</Link>
            </li>
          )}
        </ul>
      </nav>
    </header>
  );
};

export default Header;