const editProductbtn=document.querySelectorAll('.editProductbtn');
editProductbtn.forEach(btn=>{
    btn.addEventListener('click',()=>{

        document.getElementById('editProductid').value=btn.dataset.id;
        document.getElementById('editProductname').value=btn.dataset.name;
        document.getElementById('editProductprice').value=btn.dataset.price;
        document.getElementById('editProductcategory').value=btn.dataset.category;
    })
});
document.querySelectorAll('.delete-product-btn').forEach(btn=>{
    btn.addEventListener("click",()=>{
        const id=btn.dataset.id;
        if(confirm('Are you sure you want to delete this product?')){
            fetch('../pages/submissions/productsSubmission.php',{
            method:"POST",
            headers:{"Content-Type":"application/x-www-form-urlencoded"},
            body:"id="+id
        })
        .then(res=>{res.text()}
        ).then(
            (data)=>{
               location.reload()
            }
        )
        }
    })
})