2024-03-20 13:55:31 +01:00
|
|
|
//info: Header component to display the header of the page including the logo and user information where thr user can logout
|
2024-03-07 11:48:34 +01:00
|
|
|
import { useState } from "react";
|
|
|
|
import { Link } from "react-router-dom";
|
2024-03-18 21:37:31 +01:00
|
|
|
import backgroundImage from "../assets/1.jpg";
|
2024-03-07 10:05:45 +01:00
|
|
|
|
2024-03-20 13:55:31 +01:00
|
|
|
/**
|
|
|
|
* Renders the header component.
|
|
|
|
* @returns JSX.Element representing the header component.
|
|
|
|
*/
|
2024-03-18 10:28:05 +01:00
|
|
|
function Header(): JSX.Element {
|
2024-03-07 10:05:45 +01:00
|
|
|
const [isOpen, setIsOpen] = useState(false);
|
|
|
|
|
2024-03-07 11:48:34 +01:00
|
|
|
const handleLogout = (): void => {
|
2024-03-18 00:41:46 +01:00
|
|
|
localStorage.clear();
|
2024-03-07 10:05:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2024-03-07 11:48:34 +01:00
|
|
|
<header
|
|
|
|
className="fixed top-0 left-0 right-0 border-[1.75px] border-black text-black p-3 pl-5 flex items-center justify-between bg-cover"
|
2024-03-18 21:37:31 +01:00
|
|
|
style={{ backgroundImage: `url(${backgroundImage})` }}
|
2024-03-07 11:48:34 +01:00
|
|
|
>
|
2024-03-07 10:05:45 +01:00
|
|
|
<Link to="/your-projects">
|
2024-03-07 11:48:34 +01:00
|
|
|
<img
|
2024-03-14 11:08:07 +01:00
|
|
|
src="/src/assets/Logo.svg"
|
2024-03-07 11:48:34 +01:00
|
|
|
alt="TTIME Logo"
|
|
|
|
className="w-11 h-14 cursor-pointer"
|
|
|
|
/>
|
2024-03-07 10:05:45 +01:00
|
|
|
</Link>
|
2024-03-07 11:48:34 +01:00
|
|
|
|
|
|
|
<div
|
2024-03-07 10:05:45 +01:00
|
|
|
className="relative"
|
2024-03-07 11:48:34 +01:00
|
|
|
onMouseEnter={() => {
|
|
|
|
setIsOpen(true);
|
|
|
|
}}
|
|
|
|
onMouseLeave={() => {
|
|
|
|
setIsOpen(false);
|
|
|
|
}}
|
2024-03-07 10:05:45 +01:00
|
|
|
>
|
|
|
|
<button className="mr-4 underline font-bold text-white">
|
2024-03-18 10:28:05 +01:00
|
|
|
{localStorage.getItem("username")}
|
2024-03-07 10:05:45 +01:00
|
|
|
</button>
|
2024-03-07 11:48:34 +01:00
|
|
|
|
2024-03-07 10:05:45 +01:00
|
|
|
{isOpen && (
|
|
|
|
<div className="absolute right-0 bg-white border rounded shadow-lg">
|
|
|
|
<Link to="/">
|
2024-03-07 11:48:34 +01:00
|
|
|
<button
|
|
|
|
onClick={handleLogout}
|
|
|
|
className="block px-2 py-1 text-black hover:bg-gray-200"
|
|
|
|
>
|
|
|
|
Logout
|
|
|
|
</button>
|
2024-03-07 10:05:45 +01:00
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
);
|
2024-03-07 11:48:34 +01:00
|
|
|
}
|
2024-03-07 10:05:45 +01:00
|
|
|
|
|
|
|
export default Header;
|