const editCategorybtn=document.querySelectorAll('.editCategorybtn');
const showCatUpdate=document.querySelector(".show-cat-update")

editCategorybtn.forEach(btn=>{
    btn.addEventListener('click',()=>{
        document.getElementById('editCategoryId').value=btn.dataset.id;
        document.getElementById('editCategoryname').value=btn.dataset.name;
        console.log(btn.dataset.name)
    })
})
setTimeout(()=>{
    showCatUpdate.style.display='none'
},1000);
document.querySelectorAll(".dlt-btn-cat").forEach(btn=>{
    btn.addEventListener("click",()=>{
        if(confirm("Are you sure you want to delete this category?")){
            const ID=btn.dataset.id;
            fetch("../pages/submissions/categoriesSubmission.php",{
                method:"POST",
                headers:{"Content-Type":"application/x-www-form-urlencoded"},
                body:"id="+ID
            }).then(res=>{res.text()})
            .then(data=>{
                location.reload()
            })
        }
    })
})

