diff --git a/admin.php b/admin.php
index 686714e..9c2e985 100644
--- a/admin.php
+++ b/admin.php
@@ -96,6 +96,35 @@ $locations = $stmt->fetchAll();
+
+
+
+
+
Moderación de Peticiones
+
+
+
+
+
+
+ | Artista |
+ Canción |
+ Solicitado por |
+ Fecha |
+ Estado |
+ Acciones |
+
+
+
+
+ | Cargando peticiones... |
+
+
+
+
+
+
+
@@ -113,6 +142,75 @@ $locations = $stmt->fetchAll();
.bindPopup(`${loc.country}
${loc.count} usuario(s)`);
}
});
+
+ async function fetchRequests() {
+ const tbody = document.getElementById('requests-body');
+ try {
+ const response = await fetch('api/song_requests.php?status=all&limit=50');
+ const data = await response.json();
+
+ if (data.success) {
+ if (data.requests.length === 0) {
+ tbody.innerHTML = '| No hay peticiones registradas |
';
+ return;
+ }
+
+ tbody.innerHTML = data.requests.map(req => `
+
+ | ${req.artist} |
+ ${req.song} |
+ ${req.requester} |
+ ${new Date(req.created_at).toLocaleString()} |
+
+
+ ${req.status === 'played' ? 'Reproducida' : 'Pendiente'}
+
+ |
+
+
+ ${req.status === 'pending' ? `
+
+ ` : ''}
+
+
+ |
+
+ `).join('');
+ }
+ } catch (error) {
+ tbody.innerHTML = '| Error al cargar peticiones |
';
+ }
+ }
+
+ async function updateStatus(id, action) {
+ if (action === 'delete' && !confirm('¿Estás seguro de eliminar esta petición?')) return;
+
+ const formData = new FormData();
+ formData.append('id', id);
+ formData.append('action', action);
+
+ try {
+ const response = await fetch('api/song_requests.php', {
+ method: 'POST',
+ body: formData
+ });
+ const data = await response.json();
+ if (data.success) {
+ fetchRequests();
+ } else {
+ alert('Error: ' + data.error);
+ }
+ } catch (error) {
+ alert('Error al procesar la solicitud');
+ }
+ }
+
+ fetchRequests();
+ setInterval(fetchRequests, 15000);