// get products async function getProducts() { try { const response = await fetch("/Disable"); if (response.ok) { const data = await response.json(); let rows = ""; data.forEach(function (p) { rows += `${p.id}`; rows += ``; rows += `${p.name}`; rows += `
Disable
`; rows += ``; rows += ``; }); document.querySelector('tbody').innerHTML = rows; } else { throw Error("Connection error"); } } catch (err) { console.error(err); alert(err.message); } } // get all products getProducts(); // -------------- off/on async function offandonproduct(idproduct, status) { try { if (status == 0) { status = 1; } else { status = 0; } const options = { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ idproduct: idproduct, status: status, }), }; const res = await fetch("/onoffitem", options); if (res.ok) { getProducts(); } } catch (err) {} } document .getElementById("staffhome") .addEventListener("click", function (event) { event.preventDefault(); // Prevent the default link behavior window.location.href = "/staffHomepage"; }); document.getElementById("staffass").addEventListener("click", function (event) { event.preventDefault(); // Prevent the default link behavior window.location.href = "/staffAsset"; }); document.getElementById("staffhis").addEventListener("click", function (event) { event.preventDefault(); // Prevent the default link behavior window.location.href = "/staffHistory"; }); document.getElementById("rolepage").addEventListener("click", function (event) { event.preventDefault(); // Prevent the default link behavior window.location.href = "/rolePage"; });