diff --git a/index.html b/index.html index 20c4eca..c704e49 100644 --- a/index.html +++ b/index.html @@ -518,9 +518,11 @@ headers: { "Authorization": `Bearer ${storedApiKey}` } }) .then(response => response.json()) - .then(data => { - const sortedPlayers = data.convocation.available - .sort((a, b) => (a.number || 0) - (b.number || 0)); + .then(data => { + // Check if available players data exists + const availablePlayers = data.convocation.available || []; + const sortedPlayers = availablePlayers + .sort((a, b) => (a.number || 0) - (b.number || 0)); // Calculate player statistics const totalPlayers = sortedPlayers.length; @@ -551,19 +553,73 @@ return numA - numB; }); - eventDetailsContent.innerHTML = ` -
${data.title}
-

Type: ${data.type}

-

Lieu: ${data.place}

-

Heure: ${data.time_start} - ${data.time_end}

-

Joueurs convoqués: ${totalPlayers} joueur${totalPlayers > 1 ? 's' : ''} (${positionBreakdown})

-
Liste des joueurs:
- - `; + // Process staff data + const staffList = data.convocation.staff || []; + const totalStaff = staffList.length; + + // Check if there are no players + if (totalPlayers === 0 && totalStaff === 0) { + eventDetailsContent.innerHTML = ` +
+
+
${data.title}
+

Type: ${data.type}

+

Lieu: ${data.place}

+

Heure: ${data.time_start} - ${data.time_end}

+ +
+
+ `; + } else { + let staffHtml = ''; + if (totalStaff > 0) { + staffHtml = ` +
Personnel (${totalStaff}):
+ + `; + } else { + staffHtml = ` + + `; + } + + if (totalPlayers === 0) { + eventDetailsContent.innerHTML = ` +
${data.title}
+

Type: ${data.type}

+

Lieu: ${data.place}

+

Heure: ${data.time_start} - ${data.time_end}

+ + ${staffHtml} + `; + } else { + eventDetailsContent.innerHTML = ` +
${data.title}
+

Type: ${data.type}

+

Lieu: ${data.place}

+

Heure: ${data.time_start} - ${data.time_end}

+

Joueurs convoqués: ${totalPlayers} joueur${totalPlayers > 1 ? 's' : ''} (${positionBreakdown})

+
Liste des joueurs:
+ + ${staffHtml} + `; + } + } new bootstrap.Modal(document.getElementById('eventDetailsModal')).show(); }) .catch(error => console.error("Erreur lors du chargement des détails de l'événement:", error));