From f7e2b9216d81fd896522f1d08067de18d6961505 Mon Sep 17 00:00:00 2001 From: maxime Date: Sat, 9 Mar 2024 16:52:40 +0100 Subject: [PATCH] keep initial route in memory if redirected to login page from /tactic/new --- src/App.tsx | 3 ++- src/pages/NewTacticPage.tsx | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 29ab83b..f79f052 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,7 +2,7 @@ import { BrowserRouter, Outlet, Route, Routes } from "react-router-dom" import { Header } from "./pages/template/Header.tsx" import "./style/app.css" -import { lazy, ReactNode, Suspense } from "react" +import { lazy, ReactNode, Suspense, useEffect } from "react" import { BASE } from "./Constants.ts" const HomePage = lazy(() => import("./pages/HomePage.tsx")) @@ -15,6 +15,7 @@ const NewTacticPage = lazy(() => import("./pages/NewTacticPage.tsx")) const Editor = lazy(() => import("./pages/Editor.tsx")) export default function App() { + function suspense(node: ReactNode) { return ( Loading, please wait...

}> diff --git a/src/pages/NewTacticPage.tsx b/src/pages/NewTacticPage.tsx index ab77f13..98568d3 100644 --- a/src/pages/NewTacticPage.tsx +++ b/src/pages/NewTacticPage.tsx @@ -6,8 +6,8 @@ import halfCourt from "../assets/court/half_court.svg" import { CourtType } from "../model/tactic/Tactic.ts" import { useCallback } from "react" import { fetchAPI } from "../Fetcher.ts" -import { getSession } from "../api/session.ts" -import { useNavigate } from "react-router-dom" +import { getSession, saveSession } from "../api/session.ts" +import { useLocation, useNavigate } from "react-router-dom" export const DEFAULT_TACTIC_NAME = "Nouvelle tactique" @@ -45,6 +45,7 @@ function CourtKindButton({ courtType: CourtType }) { const navigate = useNavigate() + const location = useLocation() return (
+ }, [courtType, location.pathname, navigate])}>