|
|
|
@ -1,6 +1,4 @@
|
|
|
|
|
import "../style/home/home.css"
|
|
|
|
|
|
|
|
|
|
import { BASE } from "../Constants"
|
|
|
|
|
import { getSession } from "../api/session.ts"
|
|
|
|
|
import { useNavigate } from "react-router-dom"
|
|
|
|
|
import { startTransition, useLayoutEffect, useState } from "react"
|
|
|
|
@ -42,6 +40,10 @@ export default function HomePage() {
|
|
|
|
|
|
|
|
|
|
async function getUser() {
|
|
|
|
|
const response = await fetchAPIGet("user-data")
|
|
|
|
|
if (response.status == 401) {
|
|
|
|
|
navigate("/login")
|
|
|
|
|
return // if unauthorized
|
|
|
|
|
}
|
|
|
|
|
setInfo(await response.json())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -166,6 +168,8 @@ function TableData({ allTactics }: { allTactics: Tactic[] }) {
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
|
|
|
|
|
i = 0
|
|
|
|
|
while (i < nbRow) {
|
|
|
|
|
listTactic[i] = listTactic[i].map((tactic: Tactic) => (
|
|
|
|
@ -173,7 +177,7 @@ function TableData({ allTactics }: { allTactics: Tactic[] }) {
|
|
|
|
|
key={tactic.id}
|
|
|
|
|
className="data"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
location.pathname = BASE + "/tactic/" + tactic.id + "/edit"
|
|
|
|
|
navigate("/tactic/" + tactic.id + "/edit")
|
|
|
|
|
}}>
|
|
|
|
|
{truncateString(tactic.name, 25)}
|
|
|
|
|
</td>
|
|
|
|
@ -212,13 +216,12 @@ function BodyPersonalSpace({ allTactics }: { allTactics: Tactic[] }) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Team({ teams }: { teams: Team[] }) {
|
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
return (
|
|
|
|
|
<div id="teams">
|
|
|
|
|
<div className="titre-side-menu">
|
|
|
|
|
<h2 className="title">Mes équipes</h2>
|
|
|
|
|
<button
|
|
|
|
|
className="new"
|
|
|
|
|
onClick={() => (location.pathname = BASE + "/team/new")}>
|
|
|
|
|
<button className="new" onClick={() => navigate("/team/new")}>
|
|
|
|
|
+
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
@ -228,6 +231,8 @@ function Team({ teams }: { teams: Team[] }) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Tactic({ lastTactics }: { lastTactics: Tactic[] }) {
|
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div id="tactic">
|
|
|
|
|
<div className="titre-side-menu">
|
|
|
|
@ -235,7 +240,7 @@ function Tactic({ lastTactics }: { lastTactics: Tactic[] }) {
|
|
|
|
|
<button
|
|
|
|
|
className="new"
|
|
|
|
|
id="create-tactic"
|
|
|
|
|
onClick={() => (location.pathname = BASE + "/tactic/new")}>
|
|
|
|
|
onClick={() => navigate("/tactic/new")}>
|
|
|
|
|
+
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
@ -246,25 +251,29 @@ function Tactic({ lastTactics }: { lastTactics: Tactic[] }) {
|
|
|
|
|
|
|
|
|
|
function SetButtonTactic({ tactics }: { tactics: Tactic[] }) {
|
|
|
|
|
const lastTactics = tactics.map((tactic) => (
|
|
|
|
|
<ButtonLastTactic tactic={tactic} />
|
|
|
|
|
<ButtonLastTactic key={tactic.id} tactic={tactic} />
|
|
|
|
|
))
|
|
|
|
|
return <div className="set-button">{lastTactics}</div>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function SetButtonTeam({ teams }: { teams: Team[] }) {
|
|
|
|
|
const listTeam = teams.map((teams) => <ButtonTeam team={teams} />)
|
|
|
|
|
const listTeam = teams.map((team) => (
|
|
|
|
|
<ButtonTeam key={team.id} team={team} />
|
|
|
|
|
))
|
|
|
|
|
return <div className="set-button">{listTeam}</div>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ButtonTeam({ team }: { team: Team }) {
|
|
|
|
|
const name = truncateString(team.name, 20)
|
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<div
|
|
|
|
|
id={"button-team" + team.id}
|
|
|
|
|
className="button-side-menu data"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
location.pathname = BASE + "/team/" + team.id
|
|
|
|
|
navigate("/team/" + team.id)
|
|
|
|
|
}}>
|
|
|
|
|
{name}
|
|
|
|
|
</div>
|
|
|
|
@ -274,12 +283,14 @@ function ButtonTeam({ team }: { team: Team }) {
|
|
|
|
|
|
|
|
|
|
function ButtonLastTactic({ tactic }: { tactic: Tactic }) {
|
|
|
|
|
const name = truncateString(tactic.name, 20)
|
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
id={"button" + tactic.id}
|
|
|
|
|
className="button-side-menu data"
|
|
|
|
|
onClick={() => {
|
|
|
|
|
location.pathname = BASE + "/tactic/" + tactic.id + "/edit"
|
|
|
|
|
navigate("/tactic/" + tactic.id + "/edit")
|
|
|
|
|
}}>
|
|
|
|
|
{name}
|
|
|
|
|
</div>
|
|
|
|
|