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:
@@ -200,7 +200,6 @@ function FileOutput() {
|
||||
<small>À utiliser comme template pour mettre à jour les informations</small>
|
||||
</div>
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,12 +4,14 @@ import {useFetch} from "../../hooks/useFetch.js";
|
||||
import {AxiosError} from "../../components/AxiosError.jsx";
|
||||
import {ThreeDots} from "react-loader-spinner";
|
||||
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 {SimpleReducer} from "../../utils/SimpleReducer.jsx";
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
import {faAdd, faGavel, faTrashCan} from "@fortawesome/free-solid-svg-icons";
|
||||
import "./CompetitionRegisterAdmin.css"
|
||||
import * as XLSX from "xlsx-js-style";
|
||||
import * as Tools from "../../utils/Tools.js";
|
||||
|
||||
export function CompetitionRegisterAdmin({source}) {
|
||||
const {id} = useParams()
|
||||
@@ -81,6 +83,7 @@ export function CompetitionRegisterAdmin({source}) {
|
||||
setCatFilter={setCatFilter} source={source}/>
|
||||
</div>
|
||||
</div>
|
||||
{source === "admin" && <FileOutput data={data}/>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -427,7 +430,7 @@ function MakeCentralPanel({data, dispatch, id, setModalState, source}) {
|
||||
<div className="row">
|
||||
<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>
|
||||
<div><strong>{req.data.fname} {req.data.lname}</strong> <small>{req.data.genre}</small></div>
|
||||
<small>{req.data.club?.name || "Sans club"}</small>
|
||||
</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() {
|
||||
return <div className="list-group">
|
||||
<li className="list-group-item"><ThreeDots/></li>
|
||||
|
||||
Reference in New Issue
Block a user