|
|
@ -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, useEffect, useState } from "react"
|
|
|
|
import { 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"
|
|
|
|
|
|
|
|
|
|
|
@ -32,9 +32,7 @@ export default function HomePage() {
|
|
|
|
const session = getSession()
|
|
|
|
const session = getSession()
|
|
|
|
|
|
|
|
|
|
|
|
if (!session.auth) {
|
|
|
|
if (!session.auth) {
|
|
|
|
startTransition(() => {
|
|
|
|
|
|
|
|
navigate("/login")
|
|
|
|
navigate("/login")
|
|
|
|
})
|
|
|
|
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -177,9 +175,7 @@ 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>
|
|
|
@ -194,25 +190,25 @@ function TableData({ allTactics }: { allTactics: Tactic[] }) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const data = listTactic.map((tactic, rowIndex) => (
|
|
|
|
return listTactic.map((tactic, rowIndex) => (
|
|
|
|
<tr key={rowIndex + "row"}>{tactic}</tr>
|
|
|
|
<tr key={rowIndex + "row"}>{tactic}</tr>
|
|
|
|
))
|
|
|
|
))
|
|
|
|
return data
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function BodyPersonalSpace({ allTactics }: { allTactics: Tactic[] }) {
|
|
|
|
function BodyPersonalSpace({ allTactics }: { allTactics: Tactic[] }) {
|
|
|
|
let data
|
|
|
|
|
|
|
|
if (allTactics.length == 0) {
|
|
|
|
|
|
|
|
data = <p>Aucune tactique créée !</p>
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
data = <TableData allTactics={allTactics} />
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div id="body-personal-space">
|
|
|
|
<div id="body-personal-space">
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
allTactics.length == 0
|
|
|
|
|
|
|
|
? <p>Aucune tactique créée !</p>
|
|
|
|
|
|
|
|
:
|
|
|
|
<table>
|
|
|
|
<table>
|
|
|
|
<tbody key="tbody">{data}</tbody>
|
|
|
|
<tbody key="tbody">
|
|
|
|
|
|
|
|
<TableData allTactics={allTactics} />
|
|
|
|
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -223,7 +219,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={() => startTransition(() => navigate("/team/new"))}>
|
|
|
|
<button className="new" onClick={() => navigate("/team/new")}>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
@ -242,7 +238,7 @@ function Tactic({ lastTactics }: { lastTactics: Tactic[] }) {
|
|
|
|
<button
|
|
|
|
<button
|
|
|
|
className="new"
|
|
|
|
className="new"
|
|
|
|
id="create-tactic"
|
|
|
|
id="create-tactic"
|
|
|
|
onClick={() => startTransition(() => navigate("/tactic/new"))}>
|
|
|
|
onClick={() => navigate("/tactic/new")}>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
@ -275,9 +271,7 @@ 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>
|
|
|
@ -294,9 +288,7 @@ 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>
|
|
|
|