feat: exel export register data
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 10m16s
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 10m16s
This commit is contained in:
parent
0fc871bd46
commit
587173c79f
@ -2,8 +2,8 @@ package fr.titionfire.ffsaf.rest.data;
|
|||||||
|
|
||||||
import fr.titionfire.ffsaf.data.model.LicenceModel;
|
import fr.titionfire.ffsaf.data.model.LicenceModel;
|
||||||
import fr.titionfire.ffsaf.data.model.MembreModel;
|
import fr.titionfire.ffsaf.data.model.MembreModel;
|
||||||
import fr.titionfire.ffsaf.net2.data.SimpleClubModel;
|
|
||||||
import fr.titionfire.ffsaf.data.model.RegisterModel;
|
import fr.titionfire.ffsaf.data.model.RegisterModel;
|
||||||
|
import fr.titionfire.ffsaf.net2.data.SimpleClubModel;
|
||||||
import fr.titionfire.ffsaf.utils.Utils;
|
import fr.titionfire.ffsaf.utils.Utils;
|
||||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@ -18,6 +18,7 @@ public class SimpleRegisterComb {
|
|||||||
private long id;
|
private long id;
|
||||||
private String fname;
|
private String fname;
|
||||||
private String lname;
|
private String lname;
|
||||||
|
private String genre;
|
||||||
private String categorie;
|
private String categorie;
|
||||||
private SimpleClubModel club;
|
private SimpleClubModel club;
|
||||||
private Integer licence;
|
private Integer licence;
|
||||||
@ -29,6 +30,7 @@ public class SimpleRegisterComb {
|
|||||||
public static SimpleRegisterComb fromModel(RegisterModel register, List<LicenceModel> licences) {
|
public static SimpleRegisterComb fromModel(RegisterModel register, List<LicenceModel> licences) {
|
||||||
MembreModel membreModel = register.getMembre();
|
MembreModel membreModel = register.getMembre();
|
||||||
return new SimpleRegisterComb(membreModel.getId(), membreModel.getFname(), membreModel.getLname(),
|
return new SimpleRegisterComb(membreModel.getId(), membreModel.getFname(), membreModel.getLname(),
|
||||||
|
membreModel.getGenre().name(),
|
||||||
(register.getCategorie() == null) ? "Catégorie inconnue" : register.getCategorie().getName(),
|
(register.getCategorie() == null) ? "Catégorie inconnue" : register.getCategorie().getName(),
|
||||||
SimpleClubModel.fromModel(register.getClub()), membreModel.getLicence(), register.getWeight(),
|
SimpleClubModel.fromModel(register.getClub()), membreModel.getLicence(), register.getWeight(),
|
||||||
register.getOverCategory(),
|
register.getOverCategory(),
|
||||||
|
|||||||
@ -200,7 +200,6 @@ function FileOutput() {
|
|||||||
<small>À utiliser comme template pour mettre à jour les informations</small>
|
<small>À utiliser comme template pour mettre à jour les informations</small>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -4,12 +4,14 @@ import {useFetch} from "../../hooks/useFetch.js";
|
|||||||
import {AxiosError} from "../../components/AxiosError.jsx";
|
import {AxiosError} from "../../components/AxiosError.jsx";
|
||||||
import {ThreeDots} from "react-loader-spinner";
|
import {ThreeDots} from "react-loader-spinner";
|
||||||
import {useEffect, useReducer, useRef, useState} from "react";
|
import {useEffect, useReducer, useRef, useState} from "react";
|
||||||
import {apiAxios} from "../../utils/Tools.js";
|
import {apiAxios, errFormater} from "../../utils/Tools.js";
|
||||||
import {toast} from "react-toastify";
|
import {toast} from "react-toastify";
|
||||||
import {SimpleReducer} from "../../utils/SimpleReducer.jsx";
|
import {SimpleReducer} from "../../utils/SimpleReducer.jsx";
|
||||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||||
import {faAdd, faGavel, faTrashCan} from "@fortawesome/free-solid-svg-icons";
|
import {faAdd, faGavel, faTrashCan} from "@fortawesome/free-solid-svg-icons";
|
||||||
import "./CompetitionRegisterAdmin.css"
|
import "./CompetitionRegisterAdmin.css"
|
||||||
|
import * as XLSX from "xlsx-js-style";
|
||||||
|
import * as Tools from "../../utils/Tools.js";
|
||||||
|
|
||||||
export function CompetitionRegisterAdmin({source}) {
|
export function CompetitionRegisterAdmin({source}) {
|
||||||
const {id} = useParams()
|
const {id} = useParams()
|
||||||
@ -81,6 +83,7 @@ export function CompetitionRegisterAdmin({source}) {
|
|||||||
setCatFilter={setCatFilter} source={source}/>
|
setCatFilter={setCatFilter} source={source}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{source === "admin" && <FileOutput data={data}/>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -427,7 +430,7 @@ function MakeCentralPanel({data, dispatch, id, setModalState, source}) {
|
|||||||
<div className="row">
|
<div className="row">
|
||||||
<span className="col-auto">{req.data.licence ? String(req.data.licence).padStart(5, '0') : "-------"}</span>
|
<span className="col-auto">{req.data.licence ? String(req.data.licence).padStart(5, '0') : "-------"}</span>
|
||||||
<div className="ms-2 col-auto">
|
<div className="ms-2 col-auto">
|
||||||
<div className="fw-bold">{req.data.fname} {req.data.lname}</div>
|
<div><strong>{req.data.fname} {req.data.lname}</strong> <small>{req.data.genre}</small></div>
|
||||||
<small>{req.data.club?.name || "Sans club"}</small>
|
<small>{req.data.club?.name || "Sans club"}</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -495,6 +498,40 @@ function MakeCentralPanel({data, dispatch, id, setModalState, source}) {
|
|||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function FileOutput({data}) {
|
||||||
|
const handleFileDownload = () => {
|
||||||
|
const dataOut = []
|
||||||
|
for (const e of data) {
|
||||||
|
const tmp = {
|
||||||
|
licence: e.licence,
|
||||||
|
nom: e.lname,
|
||||||
|
prenom: e.fname,
|
||||||
|
genre: e.genre,
|
||||||
|
weight: e.weight,
|
||||||
|
categorie: e.categorie,
|
||||||
|
overCategory: e.overCategory,
|
||||||
|
club: e.club ? e.club.name : '',
|
||||||
|
}
|
||||||
|
dataOut.push(tmp)
|
||||||
|
}
|
||||||
|
|
||||||
|
const wb = XLSX.utils.book_new();
|
||||||
|
const ws = XLSX.utils.json_to_sheet(dataOut);
|
||||||
|
XLSX.utils.sheet_add_aoa(ws, [["Licence", "Nom", "Prénom", "Genre", "Poids", "Catégorie normalizer", "Surclassement", "Club"]], {origin: 'A1'});
|
||||||
|
|
||||||
|
ws["!cols"] = [{wch: 7}, {wch: 16}, {wch: 16}, {wch: 6}, {wch: 6}, {wch: 10}, {wch: 10}, {wch: 60}]
|
||||||
|
|
||||||
|
XLSX.utils.book_append_sheet(wb, ws, "Feuille 1");
|
||||||
|
XLSX.writeFile(wb, "output.xlsx");
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<button className="btn btn-primary" onClick={handleFileDownload}>Exporter les inscription</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function Def() {
|
function Def() {
|
||||||
return <div className="list-group">
|
return <div className="list-group">
|
||||||
<li className="list-group-item"><ThreeDots/></li>
|
<li className="list-group-item"><ThreeDots/></li>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user