feat(insc): add frontend
This commit is contained in:
parent
3f1fddccd1
commit
743a6911f5
@ -21,12 +21,19 @@ export function CompetitionRegisterAdmin() {
|
||||
const setLoading = useLoadingSwitcher()
|
||||
const {data, error} = useFetch(`/competition/${id}/register`, setLoading, 1)
|
||||
|
||||
const sortName = (a, b) => {
|
||||
if (a.data.fname === b.data.fname)
|
||||
return a.data.lname.localeCompare(b.data.lname);
|
||||
return a.data.fname.localeCompare(b.data.fname);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!data)
|
||||
return;
|
||||
data.forEach((d, index) => {
|
||||
dispatch({type: 'UPDATE_OR_ADD', payload: {id: index, data: d}})
|
||||
})
|
||||
dispatch({type: 'SORT', payload: sortName})
|
||||
}, [data, clubFilter, catFilter]);
|
||||
|
||||
const sendRegister = (event, new_state) => {
|
||||
@ -57,6 +64,7 @@ export function CompetitionRegisterAdmin() {
|
||||
})
|
||||
}
|
||||
dispatch({type: 'UPDATE_OR_ADD', payload: {id: maxId + 1, data: response.data}})
|
||||
dispatch({type: 'SORT', payload: sortName})
|
||||
document.getElementById("closeModal").click();
|
||||
})
|
||||
}
|
||||
@ -188,7 +196,7 @@ function Modal({sendRegister, modalState, setModalState}) {
|
||||
</div>
|
||||
</div>
|
||||
<div className="modal-footer">
|
||||
<button type="submit" className="btn btn-primary">Ajouter</button>
|
||||
<button type="submit" className="btn btn-primary">{editMode? "Modifier" : "Ajouter"}</button>
|
||||
<button type="reset" className="btn btn-secondary" data-bs-dismiss="modal" id="closeModal">Annuler</button>
|
||||
</div>
|
||||
</form>
|
||||
@ -243,11 +251,14 @@ function MakeCentralPanel({data, dispatch, id, setModalState}) {
|
||||
<span className="col-auto">{req.data.licence ? String(req.data.licence).padStart(5, '0') : "-------"}</span>
|
||||
<div className="ms-2 col-auto">
|
||||
<div className="fw-bold">{req.data.fname} {req.data.lname}</div>
|
||||
<small>{req.data.club?.name || "Sans club"}</small>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<div className="col-auto" style={{textAlign: "right"}}>
|
||||
<small>{req.data.club?.name || "Sans club"}<br/>{req.data.categorie}</small>
|
||||
<small>{req.data.categorie + (req.data.overCategory === 0 ? "" : (" avec " + req.data.overCategory + " de surclassement"))}<br/>
|
||||
{req.data.weight ? req.data.weight : "---"} kg
|
||||
</small>
|
||||
</div>
|
||||
<div className="col-auto">
|
||||
<button className="btn btn-danger" type="button"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user