This commit is contained in:
parent
bf53e957ac
commit
f64264b930
@ -14,11 +14,13 @@ type Team = {
|
|||||||
const Navbar = () => {
|
const Navbar = () => {
|
||||||
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
const [isMenuOpen, setIsMenuOpen] = useState(false);
|
||||||
const [isTeamsOpen, setIsTeamsOpen] = useState(false);
|
const [isTeamsOpen, setIsTeamsOpen] = useState(false);
|
||||||
|
const [isAccountOpen, setIsAccountOpen] = useState(false);
|
||||||
const { isAuthenticated, username, logout } = useAuth();
|
const { isAuthenticated, username, logout } = useAuth();
|
||||||
const [teams, setTeams] = useState<Team[]>([]);
|
const [teams, setTeams] = useState<Team[]>([]);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
let hoverTimeout: ReturnType<typeof setTimeout>
|
let hoverTimeout: ReturnType<typeof setTimeout>
|
||||||
|
let accountHoverTimeout: ReturnType<typeof setTimeout>
|
||||||
|
|
||||||
const handleMouseEnter = () => {
|
const handleMouseEnter = () => {
|
||||||
clearTimeout(hoverTimeout);
|
clearTimeout(hoverTimeout);
|
||||||
@ -86,32 +88,43 @@ const Navbar = () => {
|
|||||||
<button onClick={() => navigateAndScroll("contact")} className="text-gray-700 hover:text-frog-600 px-3 py-2 rounded-md font-medium">Kontakt</button>
|
<button onClick={() => navigateAndScroll("contact")} className="text-gray-700 hover:text-frog-600 px-3 py-2 rounded-md font-medium">Kontakt</button>
|
||||||
|
|
||||||
<Link to="/mitglied-werden" className="w-full">
|
<Link to="/mitglied-werden" className="w-full">
|
||||||
<Button className="w-full bg-frog-500 hover:bg-frog-600 text-white">
|
<Button className="bg-frog-500 hover:bg-frog-600 text-white">
|
||||||
Mitglied werden
|
Mitglied werden
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<div className="relative group ml-4">
|
<div
|
||||||
<Button
|
className="relative ml-4"
|
||||||
variant="ghost"
|
onMouseEnter={() => {
|
||||||
size="icon"
|
clearTimeout(accountHoverTimeout);
|
||||||
onClick={() => {
|
setIsAccountOpen(true);
|
||||||
if (isAuthenticated) {
|
}}
|
||||||
navigate("/admin");
|
onMouseLeave={() => {
|
||||||
} else {
|
accountHoverTimeout = setTimeout(() => {
|
||||||
navigate("/admin/login");
|
setIsAccountOpen(false);
|
||||||
}
|
}, 100);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Users className="h-6 w-6 text-frog-600 hover:text-frog-800" />
|
<div
|
||||||
</Button>
|
onClick={() => {
|
||||||
|
if (isAuthenticated) {
|
||||||
|
navigate("/admin");
|
||||||
|
} else {
|
||||||
|
navigate("/admin/login");
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="flex items-center space-x-2 cursor-pointer"
|
||||||
|
>
|
||||||
|
<Users className="h-6 w-6 text-frog-600 hover:text-frog-800" />
|
||||||
|
{isAuthenticated && (
|
||||||
|
<span className="text-sm text-frog-600 hidden md:inline">
|
||||||
|
{username}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
{isAuthenticated && (
|
{isAuthenticated && isAccountOpen && (
|
||||||
<>
|
<div className="absolute left-0 mt-2 bg-white rounded-md shadow-lg z-20 p-2">
|
||||||
<span className="text-sm text-frog-600 ml-2 hidden md:inline">
|
|
||||||
{username}
|
|
||||||
</span>
|
|
||||||
<div className="absolute right-0 mt-2 hidden group-hover:block bg-white rounded-md shadow-lg z-20 p-2">
|
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className="w-full text-left text-gray-700 hover:bg-frog-50 hover:text-frog-600"
|
className="w-full text-left text-gray-700 hover:bg-frog-50 hover:text-frog-600"
|
||||||
@ -123,9 +136,11 @@ const Navbar = () => {
|
|||||||
Logout
|
Logout
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</>
|
)}
|
||||||
)}
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Mobile menu button */}
|
{/* Mobile menu button */}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user