import { Burger, Container, Group, Header as MantineHeader, Paper, Text, Transition, } from "@mantine/core"; import { useBooleanToggle } from "@mantine/hooks"; import { NextLink } from "@mantine/next"; import getConfig from "next/config"; import Image from "next/image"; import { ReactNode, useEffect, useState } from "react"; import useUser from "../../hooks/user.hook"; import headerStyle from "../../styles/header.style"; import ActionAvatar from "./ActionAvatar"; const { publicRuntimeConfig } = getConfig(); type Link = { link?: string; label?: string; component?: ReactNode; action?: () => Promise; }; const Header = () => { const [opened, toggleOpened] = useBooleanToggle(false); const [active, setActive] = useState(); const user = useUser(); const { classes, cx } = headerStyle(); const authenticatedLinks: Link[] = [ { link: "/upload", label: "Upload", }, { component: , }, ]; const unauthenticatedLinks: Link[] | undefined = [ { link: "/auth/signIn", label: "Sign in", }, ]; if (publicRuntimeConfig.SHOW_HOME_PAGE == "true") unauthenticatedLinks.unshift({ link: "/", label: "Home", }); if (publicRuntimeConfig.ALLOW_REGISTRATION == "true") unauthenticatedLinks.push({ link: "/auth/signUp", label: "Sign up", }); const links = user ? authenticatedLinks : unauthenticatedLinks; const items = links.map((link, i) => { if (link.component) { return ( {link.component} ); } if (link) { // eslint-disable-next-line react-hooks/rules-of-hooks useEffect(() => { if (window.location.pathname == link.link) { setActive(link.link); } }, []); return ( {link.label} ); } }); return ( Pinvgin Share Logo Pingvin Share {items} toggleOpened()} className={classes.burger} size="sm" /> {(styles) => ( {items} )} ); }; export default Header;