import React, { useEffect, useState } from "react"; import { getCookie, setCookie } from "cookies-next"; import { useRouter } from "next/router"; import { useTranslation } from "next-i18next"; import Link from "next/link"; import * as Switch from "@radix-ui/react-switch"; import AboutModal from "~components/AboutModal"; import AccountModal from "~components/AccountModal"; import LoginModal from "~components/LoginModal"; import SignupModal from "~components/SignupModal"; import "./index.scss"; interface Props { authenticated: boolean; username?: string; logout?: () => void; } const HeaderMenu = (props: Props) => { const router = useRouter(); const { t } = useTranslation("common"); const accountCookie = getCookie("account"); const accountData: AccountCookie = accountCookie ? JSON.parse(accountCookie as string) : null; const userCookie = getCookie("user"); const userData: UserCookie = userCookie ? JSON.parse(userCookie as string) : null; const localeCookie = getCookie("NEXT_LOCALE"); const [checked, setChecked] = useState(false); useEffect(() => { const locale = localeCookie; setChecked(locale === "ja" ? true : false); }, [localeCookie]); function handleCheckedChange(value: boolean) { const language = value ? "ja" : "en"; setCookie("NEXT_LOCALE", language, { path: "/" }); router.push(router.asPath, undefined, { locale: language }); } function authItems() { return ( ); } function unauthItems() { return (