|
|
@@ -10,7 +10,7 @@ import Divider from "@mui/material/Divider"; |
|
|
|
import Typography from "@mui/material/Typography"; |
|
|
|
import { useTranslation } from "react-i18next"; |
|
|
|
import { signOut } from "next-auth/react"; |
|
|
|
import { useRouter } from "next/navigation"; |
|
|
|
import { usePathname, useRouter, useSearchParams } from "next/navigation"; |
|
|
|
|
|
|
|
type Props = Pick<AppBarProps, "avatarImageSrc" | "profileName">; |
|
|
|
|
|
|
@@ -26,8 +26,17 @@ const Profile: React.FC<Props> = ({ avatarImageSrc, profileName }) => { |
|
|
|
setProfileMenuAnchorEl(undefined); |
|
|
|
}; |
|
|
|
|
|
|
|
const { t } = useTranslation("login"); |
|
|
|
const { t, i18n: { language } } = useTranslation("login"); |
|
|
|
const router = useRouter(); |
|
|
|
const pathname = usePathname(); |
|
|
|
const searchParams = useSearchParams() |
|
|
|
|
|
|
|
const onLangClick = React.useCallback((lang: string) => { |
|
|
|
const params = new URLSearchParams(searchParams.toString()) |
|
|
|
params.set("lang", lang) |
|
|
|
router.replace(`${pathname}?${params.toString()}`); |
|
|
|
window.location.reload(); |
|
|
|
}, [router, pathname, searchParams]); |
|
|
|
|
|
|
|
return ( |
|
|
|
<> |
|
|
@@ -54,7 +63,9 @@ const Profile: React.FC<Props> = ({ avatarImageSrc, profileName }) => { |
|
|
|
{profileName} |
|
|
|
</Typography> |
|
|
|
<Divider /> |
|
|
|
<MenuItem onClick={() => {router.replace("/settings/changepassword")}}>{t("Change Password")}</MenuItem> |
|
|
|
<MenuItem onClick={() => { router.replace("/settings/changepassword") }}>{t("Change Password")}</MenuItem> |
|
|
|
{language === "zh" && <MenuItem onClick={() => { onLangClick("en") }}>{t("Change To English Version")}</MenuItem>} |
|
|
|
{language === "en" && <MenuItem onClick={() => { onLangClick("zh") }}>{t("Change To Chinese Version")}</MenuItem>} |
|
|
|
<MenuItem onClick={() => signOut()}>{t("Sign out")}</MenuItem> |
|
|
|
</Menu> |
|
|
|
</> |
|
|
|