fix: add classement array in competition.js

This commit is contained in:
Thibaut Valentin 2026-02-06 13:23:09 +01:00
parent 2e846bf801
commit ab4d57985c
2 changed files with 34 additions and 2 deletions

View File

@ -270,6 +270,35 @@ function buildTree(treeData) {
return drawGraph(initTree(treeData.filter(d => d.data.level >= 0)))
}
function buildClassementArray(classement) {
const classement2 = classement.sort((a, b) => {
if (a.rank === b.rank)
return a.name.localeCompare(b.name);
return a.rank - b.rank;
})
const arrayDiv = document.createElement('div');
let arrayContent = `<figure class="wp-block-table is-style-stripes" style="font-size: 16px; margin-top: 2em">
<table style="width: 600px;overflow: auto">
<thead>
<tr>
<th class="has-text-align-center" data-align="center">${i18next.t('place')}</th>
<th class="has-text-align-center" data-align="center">${i18next.t('nom')}</th>
</tr>
</thead><tbody>`
for (const row of classement2) {
arrayContent += `
<tr>
<td class="has-text-align-center" data-align="center">${row.rank}</td>
<td class="has-text-align-left" data-align="left">${row.name}</td>
</tr>`
}
arrayContent += `</tbody></table></figure>`
arrayDiv.innerHTML = arrayContent;
return arrayDiv;
}
function poulePage(location) {
rootDiv.innerHTML = `<h4>${i18next.t('résultatDeLaCompétition')} :</h4><a id="homeLink" href="javascript:void(0);">${i18next.t('back')}</a>`;
document.getElementById('homeLink').addEventListener('click', () => setSubPage('home'));
@ -343,6 +372,9 @@ function poulePage(location) {
date: d.data.date,
}))));
}
if (poule['treeIsClassement']){
dataContainer.append(buildClassementArray(poule['classement']));
}
}
location[2] = isPoule ? 1 : 2;

View File

@ -181,8 +181,8 @@ function ClassementList({classement}) {
<table className="table table-striped">
<thead>
<tr>
<th scope="col" style={{textAlign: "center"}}>Place</th>
<th scope="col" style={{textAlign: "center"}}>Nom</th>
<th scope="col" style={{textAlign: "center"}}>{t('place')}</th>
<th scope="col" style={{textAlign: "center"}}>{t('nom')}</th>
</tr>
</thead>
<tbody>