feat: display staff information and improve empty state handling in game details modal
This commit is contained in:
+57
-1
@@ -519,7 +519,9 @@
|
|||||||
})
|
})
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
const sortedPlayers = data.convocation.available
|
// Check if available players data exists
|
||||||
|
const availablePlayers = data.convocation.available || [];
|
||||||
|
const sortedPlayers = availablePlayers
|
||||||
.sort((a, b) => (a.number || 0) - (b.number || 0));
|
.sort((a, b) => (a.number || 0) - (b.number || 0));
|
||||||
|
|
||||||
// Calculate player statistics
|
// Calculate player statistics
|
||||||
@@ -551,6 +553,57 @@
|
|||||||
return numA - numB;
|
return numA - numB;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 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 = `
|
||||||
|
<div class="card border-warning">
|
||||||
|
<div class="card-body text-center">
|
||||||
|
<h5 class="card-title">${data.title}</h5>
|
||||||
|
<p class="card-text"><strong>Type:</strong> ${data.type}</p>
|
||||||
|
<p class="card-text"><strong>Lieu:</strong> ${data.place}</p>
|
||||||
|
<p class="card-text"><strong>Heure:</strong> ${data.time_start} - ${data.time_end}</p>
|
||||||
|
<div class="alert alert-warning" role="alert">
|
||||||
|
<h6 class="alert-heading">Aucun joueur ni personnel convoqué</h6>
|
||||||
|
<p>Il n'y a actuellement aucun joueur ni personnel convoqué pour ce match.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
} else {
|
||||||
|
let staffHtml = '';
|
||||||
|
if (totalStaff > 0) {
|
||||||
|
staffHtml = `
|
||||||
|
<h6>Personnel (${totalStaff}):</h6>
|
||||||
|
<ul>${staffList.map(staff => {
|
||||||
|
return `<li><strong>${staff.role}:</strong> ${staff.fname} ${staff.lname}</li>`;
|
||||||
|
}).join('')}</ul>
|
||||||
|
`;
|
||||||
|
} else {
|
||||||
|
staffHtml = `
|
||||||
|
<div class="alert alert-info" role="alert">
|
||||||
|
<h6>Aucun personnel convoqué</h6>
|
||||||
|
<p>Il n'y a actuellement aucun personnel convoqué pour ce match.</p>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalPlayers === 0) {
|
||||||
|
eventDetailsContent.innerHTML = `
|
||||||
|
<h5>${data.title}</h5>
|
||||||
|
<p><strong>Type:</strong> ${data.type}</p>
|
||||||
|
<p><strong>Lieu:</strong> ${data.place}</p>
|
||||||
|
<p><strong>Heure:</strong> ${data.time_start} - ${data.time_end}</p>
|
||||||
|
<div class="alert alert-warning" role="alert">
|
||||||
|
<h6 class="alert-heading">Aucun joueur convoqué</h6>
|
||||||
|
<p>Il n'y a actuellement aucun joueur convoqué pour ce match.</p>
|
||||||
|
</div>
|
||||||
|
${staffHtml}
|
||||||
|
`;
|
||||||
|
} else {
|
||||||
eventDetailsContent.innerHTML = `
|
eventDetailsContent.innerHTML = `
|
||||||
<h5>${data.title}</h5>
|
<h5>${data.title}</h5>
|
||||||
<p><strong>Type:</strong> ${data.type}</p>
|
<p><strong>Type:</strong> ${data.type}</p>
|
||||||
@@ -563,7 +616,10 @@
|
|||||||
let position = player.position ? player.position : "N/A";
|
let position = player.position ? player.position : "N/A";
|
||||||
return `<li>[${position}] ${number} - ${player.fname} ${player.lname} (${player.dob})</li>`;
|
return `<li>[${position}] ${number} - ${player.fname} ${player.lname} (${player.dob})</li>`;
|
||||||
}).join('')}</ul>
|
}).join('')}</ul>
|
||||||
|
${staffHtml}
|
||||||
`;
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
new bootstrap.Modal(document.getElementById('eventDetailsModal')).show();
|
new bootstrap.Modal(document.getElementById('eventDetailsModal')).show();
|
||||||
})
|
})
|
||||||
.catch(error => console.error("Erreur lors du chargement des détails de l'événement:", error));
|
.catch(error => console.error("Erreur lors du chargement des détails de l'événement:", error));
|
||||||
|
|||||||
Reference in New Issue
Block a user