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; line-height: 1.5;
font-weight: 400; font-weight: 400;
color-scheme: light dark;
font-synthesis: none; font-synthesis: none;
text-rendering: optimizeLegibility; text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;

@ -2,7 +2,7 @@ import {
CSSProperties, CSSProperties,
Dispatch, Dispatch,
RefObject, RefObject,
SetStateAction, SetStateAction, startTransition,
useCallback, useCallback,
useEffect, useEffect,
useMemo, useMemo,
@ -196,9 +196,9 @@ function Editor({ id, name, courtType, content }: EditorProps) {
{ content }, { content },
"PUT", "PUT",
) )
if (response.status == 401) { if (response.status == 401) startTransition(() => {
navigate("/login") navigate("/login")
} })
return response.ok ? SaveStates.Ok : SaveStates.Err return response.ok ? SaveStates.Ok : SaveStates.Err
}} }}
onNameChange={async (name: string) => { onNameChange={async (name: string) => {
@ -212,9 +212,9 @@ function Editor({ id, name, courtType, content }: EditorProps) {
{ name }, { name },
"PUT", "PUT",
) )
if (response.status == 401) { if (response.status == 401) startTransition(() => {
navigate("/login") navigate("/login")
} })
return response.ok return response.ok
}} }}
/> />

@ -1,7 +1,7 @@
import "../style/home/home.css" import "../style/home/home.css"
import { getSession } from "../api/session.ts" import { getSession } from "../api/session.ts"
import { useNavigate } from "react-router-dom" 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 { User } from "../model/User.ts"
import { fetchAPIGet } from "../Fetcher.ts" import { fetchAPIGet } from "../Fetcher.ts"
@ -28,7 +28,7 @@ export default function HomePage() {
const navigate = useNavigate() const navigate = useNavigate()
useLayoutEffect(() => { useEffect(() => {
const session = getSession() const session = getSession()
if (!session.auth) { if (!session.auth) {
@ -177,7 +177,9 @@ function TableData({ allTactics }: { allTactics: Tactic[] }) {
key={tactic.id} key={tactic.id}
className="data" className="data"
onClick={() => { onClick={() => {
startTransition(() => {
navigate("/tactic/" + tactic.id + "/edit") navigate("/tactic/" + tactic.id + "/edit")
})
}}> }}>
{truncateString(tactic.name, 25)} {truncateString(tactic.name, 25)}
</td> </td>
@ -221,7 +223,7 @@ function Team({ teams }: { teams: Team[] }) {
<div id="teams"> <div id="teams">
<div className="titre-side-menu"> <div className="titre-side-menu">
<h2 className="title">Mes équipes</h2> <h2 className="title">Mes équipes</h2>
<button className="new" onClick={() => navigate("/team/new")}> <button className="new" onClick={() => startTransition(() => navigate("/team/new"))}>
+ +
</button> </button>
</div> </div>
@ -240,7 +242,7 @@ function Tactic({ lastTactics }: { lastTactics: Tactic[] }) {
<button <button
className="new" className="new"
id="create-tactic" id="create-tactic"
onClick={() => navigate("/tactic/new")}> onClick={() => startTransition(() => navigate("/tactic/new"))}>
+ +
</button> </button>
</div> </div>
@ -273,7 +275,9 @@ function ButtonTeam({ team }: { team: Team }) {
id={"button-team" + team.id} id={"button-team" + team.id}
className="button-side-menu data" className="button-side-menu data"
onClick={() => { onClick={() => {
startTransition(() => {
navigate("/team/" + team.id) navigate("/team/" + team.id)
})
}}> }}>
{name} {name}
</div> </div>
@ -290,7 +294,9 @@ function ButtonLastTactic({ tactic }: { tactic: Tactic }) {
id={"button" + tactic.id} id={"button" + tactic.id}
className="button-side-menu data" className="button-side-menu data"
onClick={() => { onClick={() => {
startTransition(() => {
navigate("/tactic/" + tactic.id + "/edit") navigate("/tactic/" + tactic.id + "/edit")
})
}}> }}>
{name} {name}
</div> </div>

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

@ -66,11 +66,11 @@ function CourtKindButton({
"POST", "POST",
) )
if (response.status === 401) { if (response.status === 401) startTransition(() => {
// if unauthorized // if unauthorized
navigate("/login") navigate("/login")
return return
} })
const { id } = await response.json() const { id } = await response.json()
startTransition(() => { startTransition(() => {

@ -95,6 +95,7 @@ export default function RegisterPage() {
<label htmlFor="username">Nom d'utilisateur :</label> <label htmlFor="username">Nom d'utilisateur :</label>
<input <input
ref={usernameField} ref={usernameField}
className="text-input"
type="text" type="text"
id="username" id="username"
name="username" name="username"
@ -104,6 +105,7 @@ export default function RegisterPage() {
<label htmlFor="password">Mot de passe :</label> <label htmlFor="password">Mot de passe :</label>
<input <input
ref={passwordField} ref={passwordField}
className="password-input"
type="password" type="password"
id="password" id="password"
name="password" name="password"
@ -115,6 +117,7 @@ export default function RegisterPage() {
</label> </label>
<input <input
ref={confirmpasswordField} ref={confirmpasswordField}
className="password-input"
type="password" type="password"
id="confirmpassword" id="confirmpassword"
name="confirmpassword" name="confirmpassword"
@ -124,6 +127,7 @@ export default function RegisterPage() {
<label htmlFor="email">Email :</label> <label htmlFor="email">Email :</label>
<input <input
ref={emailField} ref={emailField}
className="text-input"
type="text" type="text"
id="email" id="email"
name="email" name="email"
@ -131,7 +135,9 @@ export default function RegisterPage() {
/> />
<label className="consentement"> <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 En cochant cette case, j'accepte que mes données
personnelles, tel que mon adresse e-mail, soient personnelles, tel que mon adresse e-mail, soient
collectées et traitées conformément à la politique de 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 { startTransition, useEffect, useState } from "react"
import { fetchAPIGet } from "../../Fetcher.ts" import { fetchAPIGet } from "../../Fetcher.ts"
import { getSession, saveSession } from "../../api/session.ts" import { getSession, saveSession } from "../../api/session.ts"
import { useNavigate } from "react-router-dom" import { useLocation, useNavigate } from "react-router-dom"
export function Header() { export function Header() {
const session = getSession() const session = getSession()
@ -12,13 +12,15 @@ export function Header() {
) )
const navigate = useNavigate() const navigate = useNavigate()
const location = useLocation()
useEffect(() => { useEffect(() => {
async function loadUsername() { async function loadUsername() {
const response = await fetchAPIGet("user") const response = await fetchAPIGet("user")
if (response.status != 401) { if (response.status === 401) {
//if unauthorized //if unauthorized, the header will display a login button instead,
//based on the nullity of username
return return
} }

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

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

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

Loading…
Cancel
Save