fix redirections
continuous-integration/drone/push Build is passing Details

pull/107/head
maxime 1 year ago
parent b322ffecaa
commit defd53c9bc

@ -3,8 +3,6 @@
line-height: 1.5;
font-weight: 400;
color-scheme: light dark;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;

@ -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
}}
/>

@ -1,7 +1,7 @@
import "../style/home/home.css"
import { getSession } from "../api/session.ts"
import { useNavigate } from "react-router-dom"
import { startTransition, useLayoutEffect, useState } from "react"
import { startTransition, useEffect, useState } from "react"
import { User } from "../model/User.ts"
import { fetchAPIGet } from "../Fetcher.ts"
@ -28,7 +28,7 @@ export default function HomePage() {
const navigate = useNavigate()
useLayoutEffect(() => {
useEffect(() => {
const session = getSession()
if (!session.auth) {
@ -59,10 +59,10 @@ export default function HomePage() {
}
function Home({
lastTactics,
allTactics,
teams,
}: {
lastTactics,
allTactics,
teams,
}: {
lastTactics: Tactic[]
allTactics: Tactic[]
teams: Team[]
@ -79,10 +79,10 @@ function Home({
}
function Body({
lastTactics,
allTactics,
teams,
}: {
lastTactics,
allTactics,
teams,
}: {
lastTactics: Tactic[]
allTactics: Tactic[]
teams: Team[]
@ -102,10 +102,10 @@ function Body({
}
function SideMenu({
width,
lastTactics,
teams,
}: {
width,
lastTactics,
teams,
}: {
width: number
lastTactics: Tactic[]
teams: Team[]
@ -125,9 +125,9 @@ function SideMenu({
}
function PersonalSpace({
width,
allTactics,
}: {
width,
allTactics,
}: {
width: number
allTactics: Tactic[]
}) {
@ -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)}
</td>
@ -221,7 +223,7 @@ function Team({ teams }: { teams: Team[] }) {
<div id="teams">
<div className="titre-side-menu">
<h2 className="title">Mes équipes</h2>
<button className="new" onClick={() => navigate("/team/new")}>
<button className="new" onClick={() => startTransition(() => navigate("/team/new"))}>
+
</button>
</div>
@ -240,7 +242,7 @@ function Tactic({ lastTactics }: { lastTactics: Tactic[] }) {
<button
className="new"
id="create-tactic"
onClick={() => navigate("/tactic/new")}>
onClick={() => startTransition(() => navigate("/tactic/new"))}>
+
</button>
</div>
@ -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}
</div>
@ -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}
</div>

@ -85,17 +85,18 @@ export default function LoginApp() {
<form onSubmit={handleSubmit}>
<div className="form-group">
<label htmlFor="email">Email :</label>
<input type="text" id="email" name="email" required />
<input className="text-input" type="text" id="email" name="email" required />
<label htmlFor="password">Mot de passe :</label>
<input
className="password-input"
type="password"
id="password"
name="password"
required
/>
<Link to={"register"} className="inscr">
<Link to={"/register"} className="inscr">
Vous n'avez pas de compte ?
</Link>
<br />

@ -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(() => {

@ -95,6 +95,7 @@ export default function RegisterPage() {
<label htmlFor="username">Nom d'utilisateur :</label>
<input
ref={usernameField}
className="text-input"
type="text"
id="username"
name="username"
@ -104,6 +105,7 @@ export default function RegisterPage() {
<label htmlFor="password">Mot de passe :</label>
<input
ref={passwordField}
className="password-input"
type="password"
id="password"
name="password"
@ -115,6 +117,7 @@ export default function RegisterPage() {
</label>
<input
ref={confirmpasswordField}
className="password-input"
type="password"
id="confirmpassword"
name="confirmpassword"
@ -124,6 +127,7 @@ export default function RegisterPage() {
<label htmlFor="email">Email :</label>
<input
ref={emailField}
className="text-input"
type="text"
id="email"
name="email"
@ -131,7 +135,9 @@ export default function RegisterPage() {
/>
<label className="consentement">
<input type="checkbox" name="consentement" required />
<input type="checkbox"
name="consentement"
required />
En cochant cette case, j'accepte que mes données
personnelles, tel que mon adresse e-mail, soient
collectées et traitées conformément à la politique de

@ -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,13 +12,15 @@ export function Header() {
)
const navigate = useNavigate()
const location = useLocation()
useEffect(() => {
async function loadUsername() {
const response = await fetchAPIGet("user")
if (response.status != 401) {
//if unauthorized
if (response.status === 401) {
//if unauthorized, the header will display a login button instead,
//based on the nullity of username
return
}

@ -25,8 +25,8 @@ label {
margin-bottom: 5px;
}
input[type="text"],
input[type="password"] {
.text-input,
.password-input {
width: 95%;
padding: 10px;
border: 1px solid #ccc;

@ -32,7 +32,8 @@
#username {
color: var(--main-contrast-color);
margin: 0 0 0 10px;
margin-right: 20px;
margin-left: 10px;
}
#clickable-header-right:hover #username {
@ -41,9 +42,8 @@
#clickable-header-right {
border-radius: 1cap;
padding: 2%;
margin-right: 20px;
display: flex;
align-items: center;
justify-content: space-evenly;

@ -1,3 +1,5 @@
.title-input {
background: transparent;
border-top: none;

Loading…
Cancel
Save