diff --git a/frontend/public/js/app.js b/frontend/public/js/app.js index 927b41d..53d23ff 100644 --- a/frontend/public/js/app.js +++ b/frontend/public/js/app.js @@ -428,23 +428,25 @@ function renderGallery(container, items) { ${formatDate(item.createdAt)} `).join(''); -} -async function deleteContent(id) { - if (!confirm('Are you sure you want to delete this content?')) return; - - try { - await api(`/content/${id}`, { method: 'DELETE' }); - loadGallery(currentPage); - } catch (error) { - alert(error.message); - } + container.querySelectorAll('.delete-content-btn').forEach(btn => { + btn.addEventListener('click', async function() { + const contentId = parseInt(this.dataset.contentId, 10); + if (!confirm('Are you sure you want to delete this content?')) return; + try { + await api(`/content/${contentId}`, { method: 'DELETE' }); + loadGallery(currentPage); + } catch (error) { + alert(error.message); + } + }); + }); } // Admin