📡 Enable Cross-Device Sync
To sync data between your phone and computer, follow these one-time steps:
- Go to script.google.com and sign in
- Click New Project
- Delete all existing code and paste the script from the instructions below
- Click Deploy → New Deployment → Web App
- Set Execute as: Me and Who has access: Anyone
- Click Deploy and copy the Web App URL
- Open this tracker's HTML file and paste the URL in the
SHEETS_URL variable
- Re-upload to GitHub — Netlify will auto-deploy
Apps Script code to paste:
const SS_ID = ''; // Paste your Google Sheet ID here
function doGet(e){ return handle(e) }
function doPost(e){ return handle(e) }
function handle(e){
const ss = SpreadsheetApp.openById(SS_ID);
const p = e.parameter || {};
const action = p.action || (e.postData ? JSON.parse(e.postData.contents).action : 'load');
if(action==='load'){
const cs = ss.getSheetByName('customers');
const as = ss.getSheetByName('appointments');
const customers = cs ? JSON.parse(cs.getRange(1,1).getValue()||'[]') : [];
const appointments = as ? JSON.parse(as.getRange(1,1).getValue()||'[]') : [];
return out({status:'ok',customers,appointments});
}
if(action==='save'){
const body = JSON.parse(e.postData.contents);
getOrCreate(ss,'customers').getRange(1,1).setValue(JSON.stringify(body.customers));
getOrCreate(ss,'appointments').getRange(1,1).setValue(JSON.stringify(body.appointments));
return out({status:'ok'});
}
}
function getOrCreate(ss,name){
return ss.getSheetByName(name) || ss.insertSheet(name);
}
function out(obj){
return ContentService.createTextOutput(JSON.stringify(obj))
.setMimeType(ContentService.MimeType.JSON);
}