diff --git a/frontend/app/components/header/header.tsx b/frontend/app/components/header/header.tsx index 64cde6b7..201d94eb 100644 --- a/frontend/app/components/header/header.tsx +++ b/frontend/app/components/header/header.tsx @@ -1,28 +1,64 @@ +"use client"; +import {useEffect, useState} from "react"; import styles from "./header.module.scss" +import {fetchSeasonList} from "@/app/utils/clientSideFetch"; +import {useRouter} from "next/router"; - -export type NavLinks = { +type NavLinks = { label: string; - path: string; + path: string } -export type HeaderProps = { - nav_links: NavLinks[]; -} +const Header = () => { + const [navLinks, setNavLinks] = useState([]) + const router = useRouter(); + useEffect(() => { + fetchSeasonList().then(seasonList => { + setNavLinks(seasonList.reverse().map(season => { + const seasonNumber = season.split("_")[0] + return {label: `Season ${seasonNumber}`, path: `/season/${seasonNumber}`} + })) + if (router.pathname === "/" && typeof window !== undefined) { + const element = document.getElementById("curseason") + if (element) { + element.innerText = `Season ${seasonList[0].split("_")[0]}` + } + } + + if (typeof window !== undefined){ + const element = document.getElementById('navbar') + if (element){ + element.addEventListener('wheel', function(e) { + // @ts-ignore + if (e.deltaY != 0) { + // @ts-ignore + this.scrollLeft += (e.deltaY * 1.5); + e.preventDefault(); + } + }, false); + } + + } + + }) + + }, []); + -const Header = ({nav_links}: HeaderProps) => { return (

Top 500 Aggregator

-
+