75 lines
2.8 KiB
HTML
75 lines
2.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<title>Equipos Disponibles</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="css/equipoDisponible.css" rel="stylesheet">
|
|
</head>
|
|
<body>
|
|
<!-- NAV -->
|
|
<nav class="navbar navbar-expand-lg navbar-dark bg-primary sticky-top shadow-sm px-4 py-3">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand fw-bold text-white" href="#">SwimArt</a>
|
|
<div class="ms-auto d-flex gap-4">
|
|
<a href="coach.html" class="nav-link text-white">Inicializar Rutina</a>
|
|
<a href="equipoDisponibles.html" class="nav-link text-white">Equipos Disponibles</a>
|
|
<a href="piscina.html" class="nav-link text-white">Piscina</a>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<!-- MAIN -->
|
|
<main class="px-5 my-4" style="max-width: 90%; margin: 0 auto;">
|
|
<h2 class="fw-bold fs-3 mb-4">Equipos Disponibles</h2>
|
|
<div class="d-flex flex-wrap gap-4" id="routinesList"></div>
|
|
</main>
|
|
|
|
<script>
|
|
async function loadRoutines() {
|
|
const response = await fetch('/api/rutinas');
|
|
const routines = await response.json();
|
|
const routinesList = document.getElementById('routinesList');
|
|
routinesList.innerHTML = '';
|
|
|
|
for (const routine of routines) {
|
|
const formaciones = await fetch(`/api/rutinas/${routine._id}/formations`).then(res => res.json());
|
|
const ultimaFormacion = formaciones?.at(-1);
|
|
|
|
const atletas = ultimaFormacion?.atletas || [];
|
|
const atletasHTML = atletas.length
|
|
? atletas.map(a => `
|
|
<li>${a.atletaId?.name || a.idPersonalizado || 'Atleta'}${a.rol ? ' - ' + a.rol : ''}</li>
|
|
`).join('')
|
|
: '<li class="text-muted fst-italic">Sin atletas en formación</li>';
|
|
|
|
const card = document.createElement('div');
|
|
card.classList.add('card', 'border-primary', 'shadow');
|
|
card.style.width = '300px';
|
|
|
|
card.innerHTML = `
|
|
<div class="card-body">
|
|
<h5 class="card-title fw-bold">${routine.nombreCompetencia}</h5>
|
|
<p><strong>Competencia:</strong> ${routine.tipoCompetencia}</p>
|
|
<p><strong>Modalidad:</strong> ${routine.modalidad}</p>
|
|
<h6 class="mt-2">Atletas:</h6>
|
|
<ul class="text-start px-3">${atletasHTML}</ul>
|
|
<div class="text-center">
|
|
<button class="btn btn-primary mt-3" onclick="redirectToPiscina('${routine._id}')">Ver detalles</button>
|
|
</div>
|
|
</div>
|
|
`;
|
|
routinesList.appendChild(card);
|
|
}
|
|
}
|
|
|
|
function redirectToPiscina(routineId) {
|
|
window.location.href = `piscina.html?routineId=${routineId}`;
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', loadRoutines);
|
|
</script>
|
|
</body>
|
|
</html>
|