document.getElementById("syncButton").addEventListener("click", async function () {
console.log("Starting sync...");
try {
const response = await fetch("https://script.google.com/macros/s/AKfycbwVeLtfVnkV0S5d2_TAIXttEJfmN8vmeMxUGapP1FuemEKTycda--KIO19WcuOY1hzVdg/exec", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ action: "syncData" }) // Send proper JSON
});
const result = await response.json();
console.log("Sync result:", result);
document.getElementById("syncStatus").innerText = result;
} catch (error) {
console.error("Sync error:", error);
document.getElementById("syncStatus").innerText = "❌ Error: Sync Failed.";
}
});