diff --git a/frontend/src/components/NoDirectAccessRoutes/index.tsx b/frontend/src/components/NoDirectAccessRoutes/index.tsx index 0af10ae54c..2dea467c8d 100644 --- a/frontend/src/components/NoDirectAccessRoutes/index.tsx +++ b/frontend/src/components/NoDirectAccessRoutes/index.tsx @@ -1,9 +1,10 @@ import { Navigate, Outlet, useLocation } from "react-router-dom"; +import { LocationState } from "../../hooks/useAppNavigate"; const NoDirectAccessRoutes: React.FC = () => { const location = useLocation(); - if (location.state?.from !== "app-navigation") { + if ((location.state as LocationState)?.from !== "app-navigation") { return ; } diff --git a/frontend/src/hooks/useAppNavigate.tsx b/frontend/src/hooks/useAppNavigate.tsx index d68826bf65..873078c4e5 100644 --- a/frontend/src/hooks/useAppNavigate.tsx +++ b/frontend/src/hooks/useAppNavigate.tsx @@ -1,12 +1,16 @@ import { useNavigate } from "react-router-dom"; +export interface LocationState { + from: string; +} + export const useAppNavigate = () => { const navigate = useNavigate(); const appNavigate = (path: string) => { navigate(path, { replace: location.pathname !== "/home", - state: { from: "app-navigation" }, + state: { from: "app-navigation" } as LocationState, }); };