import { Box, Flex, Menu, MenuButton, MenuGroup, MenuItem, MenuList, Popover, PopoverArrow, PopoverContent, PopoverHeader, PopoverTrigger, } from "@chakra-ui/react"; import { t, Trans } from "@lingui/macro"; import { useLingui } from "@lingui/react"; import { useMyTheme } from "lib/useMyTheme"; import { useRouter } from "next/dist/client/router"; import Image from "next/image"; import Link from "next/link"; export const navIcons: { code: string; displayName: string; menuItems: { code: string; displayName: string; toAppend?: string; }[]; }[] = [ { code: "xsearch", displayName: t`Top 500`, menuItems: [ { code: "xsearch", displayName: t`Browser` }, { code: "xtrends", displayName: t`Tier Lists` }, ], }, // { // code: "leaderboards", // displayName: t`Leaderboards`, // menuItems: [], // }, // { code: "sr", displayName: "Salmon Run", menuItems: [] }, { code: "builds", displayName: t`Builds`, menuItems: [], }, { code: "analyzer", displayName: t`Build Analyzer`, menuItems: [] }, { code: "calendar", displayName: t`Calendar`, menuItems: [] }, { code: "u", displayName: t`User Search`, menuItems: [] }, { code: "freeagents", displayName: t`Free Agents`, menuItems: [] }, // { code: "teams", displayName: t`Teams`, menuItems: [] }, { code: "plans", displayName: t`Map Planner`, menuItems: [] }, { code: "tournaments", displayName: t`Tournaments`, menuItems: [] }, { code: "plus", displayName: t`Plus Server`, menuItems: [ { code: "plus/voting", displayName: t`Voting`, toAppend: ": " + getFirstFridayDate().toLocaleString("default", { month: "short", day: "numeric", }), }, { code: "plus", displayName: t`Suggested and vouched players` }, { code: "plus/history", displayName: t`Voting history` }, { code: "draft", displayName: t`Draft Cup` }, { code: "plus/faq", displayName: t`FAQ` }, ], }, { code: "links", displayName: t`External links`, menuItems: [] }, ]; const IconNavBar = () => { const { i18n } = useLingui(); const { secondaryBgColor, textColor, themeColorHex: themeColor, } = useMyTheme(); const pathname = useRouter().pathname; //const isVoting = !!plusInfoData?.plusInfo?.voting_ends; const isVoting = false; return ( {navIcons.map(({ displayName, code, menuItems }) => { if (!menuItems.length) { return ( ); } return ( {menuItems.map((item) => ( {pathname === "/" + item.code ? ( ) : ( )} ))} ); })} ); function MenuNavIcon({ code, showDownArrow, }: { code: string; showDownArrow?: boolean; }) { return ( {code} {showDownArrow && ( )} ); } function MenuDialog({ children, displayName, }: { children: React.ReactNode; displayName: string; }) { return ( {children} {displayName} ); } }; function getFirstFridayDate() { const today = new Date(); const month = today.getDate() - ((1 + today.getDay()) % 7) <= 0 ? today.getMonth() : today.getMonth() + 1; let day = 1; while (day <= 7) { const dateOfVoting = new Date( Date.UTC(today.getFullYear(), month, day, 15, 0, 0) ); if (dateOfVoting.getDay() === 5) return dateOfVoting; day++; } console.error("Couldn't resolve first friday of the month for voting"); return new Date(2000, 1, 1); } export default IconNavBar;