Actualiser js/admin.js
This commit is contained in:
+30
-14
@@ -47,25 +47,41 @@ document.addEventListener('change', (e) => {
|
||||
}
|
||||
});
|
||||
|
||||
async function executeBulkDelete() {
|
||||
const ids = Array.from(document.querySelectorAll('.film-checkbox:checked')).map(cb => cb.value);
|
||||
if (!confirm(`Supprimer ces ${ids.length} films ?`)) return;
|
||||
|
||||
await fetch(`${API_URL}?action=bulk_delete`, {
|
||||
method: 'POST',
|
||||
headers: { 'Authorization': localStorage.getItem('token'), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ ids, type: currentAdminTab })
|
||||
});
|
||||
loadDashboardData();
|
||||
document.getElementById('bulk-actions-bar').style.display = 'none';
|
||||
}
|
||||
// Remplacez les deux fonctions de suppression par celles-ci :
|
||||
|
||||
async function deleteSingleFilm(id) {
|
||||
if (!confirm('Supprimer ce film ?')) return;
|
||||
await fetch(`${API_URL}?action=delete_film&id=${id}&type=${currentAdminTab}`, {
|
||||
|
||||
const token = localStorage.getItem('token');
|
||||
const res = await fetch(`${API_URL}?action=delete_film&id=${id}&type=${currentAdminTab}`, {
|
||||
method: 'DELETE',
|
||||
headers: { 'Authorization': localStorage.getItem('token') }
|
||||
headers: { 'Authorization': token } // <-- Vérifiez que ce token est bien présent
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
console.log("Réponse suppression simple :", data);
|
||||
loadDashboardData();
|
||||
}
|
||||
|
||||
async function executeBulkDelete() {
|
||||
const ids = Array.from(document.querySelectorAll('.film-checkbox:checked')).map(cb => cb.value);
|
||||
if (ids.length === 0) return;
|
||||
if (!confirm(`Supprimer ces ${ids.length} films ?`)) return;
|
||||
|
||||
const token = localStorage.getItem('token');
|
||||
const res = await fetch(`${API_URL}?action=bulk_delete`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': token, // <-- Vérifiez que ce token est bien présent
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ ids, type: currentAdminTab })
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
console.log("Réponse suppression masse :", data);
|
||||
|
||||
document.getElementById('bulk-actions-bar').style.display = 'none';
|
||||
loadDashboardData();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user