import { useSearch } from "@/lib/context/isOpenState"; import { getCurrentSeason } from "@/utils/getTimes"; import { ArrowLeftIcon, ArrowUpCircleIcon } from "@heroicons/react/20/solid"; import { UserIcon } from "@heroicons/react/24/solid"; import { signIn, signOut, useSession } from "next-auth/react"; import Image from "next/image"; import Link from "next/link"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; const getScrollPosition = (el = window) => ({ x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft, y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop, }); export function NewNavbar({ info, scrollP = 200, toTop = false, withNav = false, paddingY = "py-3", home = false, back = false, manga = false, shrink = false, }) { const { data: session } = useSession(); const router = useRouter(); const [scrollPosition, setScrollPosition] = useState(); const { setIsOpen } = useSearch(); const year = new Date().getFullYear(); const season = getCurrentSeason(); useEffect(() => { const handleScroll = () => { setScrollPosition(getScrollPosition()); }; // Add a scroll event listener when the component mounts window.addEventListener("scroll", handleScroll); // Clean up the event listener when the component unmounts return () => { window.removeEventListener("scroll", handleScroll); }; }, []); return ( <> {toTop && ( )} ); }