feat: cm home page
This commit is contained in:
@@ -43,9 +43,9 @@ function AffiliationMenu() {
|
||||
}
|
||||
|
||||
function CompMenu() {
|
||||
const {is_authenticated} = useAuth()
|
||||
const {is_authenticated, userinfo} = useAuth()
|
||||
|
||||
if (!is_authenticated)
|
||||
if (!is_authenticated || !userinfo?.roles?.includes("federation_admin"))
|
||||
return <></>
|
||||
|
||||
return <li className="nav-item dropdown">
|
||||
|
||||
@@ -36,6 +36,10 @@ export function CompetitionEdit() {
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
refresh(`/competition/${id}?light=false`)
|
||||
}, [id]);
|
||||
|
||||
return <>
|
||||
<button type="button" className="btn btn-link" onClick={() => navigate("/competition")}>
|
||||
« retour
|
||||
@@ -284,17 +288,18 @@ function Content({data}) {
|
||||
toast.promise(
|
||||
apiAxios.post(`/competition`, out),
|
||||
{
|
||||
pending: "Enregistrement du club en cours",
|
||||
success: "Club enregistrée avec succès 🎉",
|
||||
pending: "Enregistrement de la competition en cours",
|
||||
success: "Competition enregistrée avec succès 🎉",
|
||||
error: {
|
||||
render({data}) {
|
||||
return errFormater(data, "Échec de l'enregistrement du club")
|
||||
return errFormater(data, "Échec de l'enregistrement de la competition")
|
||||
}
|
||||
},
|
||||
}
|
||||
).then(data => {
|
||||
if (data.id !== undefined)
|
||||
navigate("/competition/" + data.id)
|
||||
console.log(data.data)
|
||||
if (data.data.id !== undefined)
|
||||
navigate("/competition/" + data.data.id)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -315,7 +320,7 @@ function Content({data}) {
|
||||
<div id="collapseOne" className="accordion-collapse collapse" data-bs-parent="#accordionExample">
|
||||
<div className="accordion-body">
|
||||
<TextField name="uuid" text="UUID" value={data.uuid} disabled={true}/>
|
||||
<OptionField name="system" text="System" value={data.system} values={{SAFCA: 'SAFCA', NONE: "intranet"}}
|
||||
<OptionField name="system" text="System" value={data.system} values={{SAFCA: 'SAFCA', INTERNAL: "Intranet"}}
|
||||
disabled={data.id !== null}/>
|
||||
{data.id !== null &&
|
||||
<div className="row">
|
||||
@@ -383,11 +388,11 @@ function Content({data}) {
|
||||
<span className="input-group-text" id="startRegister">Du</span>
|
||||
<input type="datetime-local" className="form-control" placeholder="jj/mm/aaaa" aria-label="date"
|
||||
name="startRegister" aria-describedby="startRegister"
|
||||
defaultValue={data.startRegister ? data.startRegister.split('+')[0] : ''}/>
|
||||
defaultValue={data.startRegister ? data.startRegister.substring(0, 16) : ''}/>
|
||||
<span className="input-group-text" id="endRegister">Au</span>
|
||||
<input type="datetime-local" className="form-control" placeholder="jj/mm/aaaa" aria-label="endRegister"
|
||||
name="endRegister" aria-describedby="endRegister"
|
||||
defaultValue={data.endRegister ? data.endRegister.split('+')[0] : ''}/>
|
||||
defaultValue={data.endRegister ? data.endRegister.substring(0, 16) : ''}/>
|
||||
</div>
|
||||
|
||||
<div style={{display: registerMode === "HELLOASSO" ? "initial" : "none"}}>
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import {Route, Routes, useNavigate, useParams} from "react-router-dom";
|
||||
import {LoadingProvider} from "../../../hooks/useLoading.jsx";
|
||||
import {LoadingProvider, useLoadingSwitcher} from "../../../hooks/useLoading.jsx";
|
||||
import {useEffect, useState} from "react";
|
||||
import {useWS, WSProvider} from "../../../hooks/useWS.jsx";
|
||||
import {ColoredCircle} from "../../../components/ColoredCircle.jsx";
|
||||
import {CMAdmin} from "./CMAdmin.jsx";
|
||||
import {CombsProvider} from "../../../hooks/useComb.jsx";
|
||||
import {CMTable} from "./CMTable.jsx";
|
||||
import {ThreeDots} from "react-loader-spinner";
|
||||
import {AxiosError} from "../../../components/AxiosError.jsx";
|
||||
import {useFetch} from "../../../hooks/useFetch.js";
|
||||
|
||||
const vite_url = import.meta.env.VITE_URL;
|
||||
|
||||
@@ -22,13 +25,33 @@ export default function CompetitionManagerRoot() {
|
||||
}
|
||||
|
||||
function Home() {
|
||||
const nav = useNavigate();
|
||||
return <div>
|
||||
<h2>Home</h2>
|
||||
<button onClick={() => nav("d3dc76a6-2058-423a-b34b-6d15d7ae5848")}>Go comp</button>
|
||||
const navigate = useNavigate();
|
||||
const setLoading = useLoadingSwitcher()
|
||||
const {data, error} = useFetch(`/competition/admin/all/INTERNAL/table`, setLoading, 1)
|
||||
|
||||
return <div className="row">
|
||||
{data
|
||||
? <MakeCentralPanel data={data} navigate={navigate}/>
|
||||
: error
|
||||
? <AxiosError error={error}/>
|
||||
: <Def/>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
function MakeCentralPanel({data, navigate}) {
|
||||
return <>
|
||||
<div className="mb-4">
|
||||
<h4>Compétition:</h4>
|
||||
<div className="list-group">
|
||||
{data.sort((a, b) => new Date(b.date.split('T')[0]) - new Date(a.date.split('T')[0])).map((o) => (
|
||||
<li className="list-group-item list-group-item-action" key={o.id}
|
||||
onClick={__ => navigate(o.uuid)}>{o.name}</li>))}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
|
||||
function HomeComp() {
|
||||
let {compUuid} = useParams();
|
||||
const [perm, setPerm] = useState("")
|
||||
@@ -98,11 +121,12 @@ function Home2({perm}) {
|
||||
</div>
|
||||
}
|
||||
|
||||
function Test2() {
|
||||
let {compUuid} = useParams();
|
||||
const nav = useNavigate();
|
||||
return <div>
|
||||
<h2>Product ID: {compUuid}</h2>
|
||||
<button onClick={() => nav(-1)}>Go Back</button>
|
||||
function Def() {
|
||||
return <div className="list-group">
|
||||
<li className="list-group-item"><ThreeDots/></li>
|
||||
<li className="list-group-item"><ThreeDots/></li>
|
||||
<li className="list-group-item"><ThreeDots/></li>
|
||||
<li className="list-group-item"><ThreeDots/></li>
|
||||
<li className="list-group-item"><ThreeDots/></li>
|
||||
</div>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user