diff --git a/src/pages/common/Page404.tsx b/src/pages/common/Page404.tsx index d87104d..4c1bf0e 100644 --- a/src/pages/common/Page404.tsx +++ b/src/pages/common/Page404.tsx @@ -1,5 +1,6 @@ import { Box } from "@mui/material"; import { PageID } from "codes/page"; +import useAuth from "hooks/useAuth"; import useNavigateCustom from "hooks/useNavigateCustom"; import { useEffect } from "react"; import { getPath } from "routes/path"; @@ -7,9 +8,15 @@ import { StoreId, getStore } from "storage/localstorage"; export default function Page404() { const { navigateWhenChanged } = useNavigateCustom(); + const { authenticated } = useAuth(); // ログインページにアクセス経験ある場合は、ログインページへ遷移させる useEffect(() => { + if (authenticated) { + navigateWhenChanged(getPath(PageID.DASHBOARD_OVERVIEW)); + return; + } + const canLoginRoute = !!getStore(StoreId.LOGIN_ROUTE); if (canLoginRoute) {