diff --git a/src/pages/Editor.tsx b/src/pages/Editor.tsx
index 11df02c..1a1e177 100644
--- a/src/pages/Editor.tsx
+++ b/src/pages/Editor.tsx
@@ -2,7 +2,7 @@ import {
CSSProperties,
Dispatch,
RefObject,
- SetStateAction,
+ SetStateAction, startTransition,
useCallback,
useEffect,
useMemo,
@@ -196,9 +196,9 @@ function Editor({ id, name, courtType, content }: EditorProps) {
{ content },
"PUT",
)
- if (response.status == 401) {
+ if (response.status == 401) startTransition(() => {
navigate("/login")
- }
+ })
return response.ok ? SaveStates.Ok : SaveStates.Err
}}
onNameChange={async (name: string) => {
@@ -212,9 +212,9 @@ function Editor({ id, name, courtType, content }: EditorProps) {
{ name },
"PUT",
)
- if (response.status == 401) {
+ if (response.status == 401) startTransition(() => {
navigate("/login")
- }
+ })
return response.ok
}}
/>
diff --git a/src/pages/HomePage.tsx b/src/pages/HomePage.tsx
index 1ec9647..65cf3e8 100644
--- a/src/pages/HomePage.tsx
+++ b/src/pages/HomePage.tsx
@@ -177,7 +177,9 @@ function TableData({ allTactics }: { allTactics: Tactic[] }) {
key={tactic.id}
className="data"
onClick={() => {
- navigate("/tactic/" + tactic.id + "/edit")
+ startTransition(() => {
+ navigate("/tactic/" + tactic.id + "/edit")
+ })
}}>
{truncateString(tactic.name, 25)}
@@ -221,7 +223,7 @@ function Team({ teams }: { teams: Team[] }) {
Mes équipes
-
@@ -240,7 +242,7 @@ function Tactic({ lastTactics }: { lastTactics: Tactic[] }) {
navigate("/tactic/new")}>
+ onClick={() => startTransition(() => navigate("/tactic/new"))}>
+
@@ -273,7 +275,9 @@ function ButtonTeam({ team }: { team: Team }) {
id={"button-team" + team.id}
className="button-side-menu data"
onClick={() => {
- navigate("/team/" + team.id)
+ startTransition(() => {
+ navigate("/team/" + team.id)
+ })
}}>
{name}
@@ -290,7 +294,9 @@ function ButtonLastTactic({ tactic }: { tactic: Tactic }) {
id={"button" + tactic.id}
className="button-side-menu data"
onClick={() => {
- navigate("/tactic/" + tactic.id + "/edit")
+ startTransition(() => {
+ navigate("/tactic/" + tactic.id + "/edit")
+ })
}}>
{name}
diff --git a/src/pages/NewTacticPage.tsx b/src/pages/NewTacticPage.tsx
index c390f0e..149f6e8 100644
--- a/src/pages/NewTacticPage.tsx
+++ b/src/pages/NewTacticPage.tsx
@@ -66,11 +66,11 @@ function CourtKindButton({
"POST",
)
- if (response.status === 401) {
+ if (response.status === 401) startTransition(() => {
// if unauthorized
navigate("/login")
return
- }
+ })
const { id } = await response.json()
startTransition(() => {
diff --git a/src/pages/template/Header.tsx b/src/pages/template/Header.tsx
index c361272..da69cb0 100644
--- a/src/pages/template/Header.tsx
+++ b/src/pages/template/Header.tsx
@@ -3,7 +3,7 @@ import "../../style/template/header.css"
import { startTransition, useEffect, useState } from "react"
import { fetchAPIGet } from "../../Fetcher.ts"
import { getSession, saveSession } from "../../api/session.ts"
-import { useNavigate } from "react-router-dom"
+import { useLocation, useNavigate } from "react-router-dom"
export function Header() {
const session = getSession()
@@ -12,6 +12,7 @@ export function Header() {
)
const navigate = useNavigate()
+ const location = useLocation()
useEffect(() => {
async function loadUsername() {