From c49c9cf501dbd6b8a6fdac529e752ce0f4edb8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20MARQUET?= Date: Thu, 14 Nov 2024 16:43:38 +0100 Subject: [PATCH] Fix --- Front/js/backend/match.js | 69 ++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/Front/js/backend/match.js b/Front/js/backend/match.js index cf850c7..411afc6 100644 --- a/Front/js/backend/match.js +++ b/Front/js/backend/match.js @@ -331,7 +331,7 @@ if (window.location.href.includes("arbitrage.html")) { //Récupération des données du formulaire let equipe1 = document.getElementById('equipe1').value; let equipe2 = document.getElementById('equipe2').value; - let sportID = document.getElementById("sport").value; + sportID = document.getElementById("sport").value; //Récupération de l'id de l'équipe if (!sportID.toLowerCase().includes("badminton")) { equipe1 = equipe1.substring(0, 6); @@ -430,45 +430,43 @@ if (window.location.href.includes("index.html") || window.location.href === "htt let finishedMatch = []; let container = document.getElementById('cardContainer'); matchList.forEach(match => { + const isFinished = match.status === "finished"; // Define isFinished here const cardHTML = ` -
-
- ${match.status === "in_progress" || match.status === "finished" ? '' : new Date(match.heure_debut).toLocaleString()} - ${match.status === "in_progress" || match.status === "finished" ? ` -
-

${match.point1}

-

-

-

${match.point2}

-
- ` : ''} -
-
- ${match.team1 && match.team2 ? `
${match.expand.team1.name} VS ${match.expand.team2.name}
` : ''} -

${match.expand.sport.name}

- ${match.name !== "" ? `

${match.name}

` : ''} -
-
- -
-
-
+
+
+ ${match.status === "in_progress" || match.status === "finished" ? '' : new Date(match.heure_debut).toLocaleString()} + ${match.status === "in_progress" || match.status === "finished" ? ` +
+

${match.point1}

+

-

+

${match.point2}

- -
- + ` : ''}
- `; +
+ ${match.team1 && match.team2 ? `
${match.expand.team1.name} VS ${match.expand.team2.name}
` : ''} +

${match.expand.sport.name}

+ ${match.name !== "" ? `

${match.name}

` : ''} +
+
+ +
+
+
+
+ +
+ +
+ `; if(match.status == "finished"){ finishedMatch.push(cardHTML); } else { container.insertAdjacentHTML('beforeend', cardHTML); } }); - finishedMatch.forEach(card => { - container.insertAdjacentHTML('beforeend', card); - }); } // Add event listeners for voting buttons @@ -478,10 +476,13 @@ matchList.forEach(record => { const progressTeam1 = document.getElementById(`progressTeam1${record.id}`); const progressTeam2 = document.getElementById(`progressTeam2${record.id}`); - voteTeam1Button.addEventListener('click', () => handleVote(record.id, 'team1', progressTeam1, progressTeam2)); - voteTeam2Button.addEventListener('click', () => handleVote(record.id, 'team2', progressTeam1, progressTeam2)); + if (voteTeam1Button) { + voteTeam1Button.addEventListener('click', () => handleVote(record.id, 'team1', progressTeam1, progressTeam2)); + } + if (voteTeam2Button) { + voteTeam2Button.addEventListener('click', () => handleVote(record.id, 'team2', progressTeam1, progressTeam2)); + } }); - // Function to handle voting async function handleVote(matchId, team, progressTeam1, progressTeam2) { const match = await pb.collection('match').getOne(matchId);