Magical Inventory
🦄✨ Inventory is live! Default status is Available. Use filters below.

${item.itemName}

Sale: $${item.salePrice}
${item.itemValue?`
Value: $${item.itemValue}
`:""}
${item.internalCode?`
IC: ${item.internalCode}
`:""} ${item.notes?`
${item.notes}
`:""} ${item.amazonLink?`See on Amazon`:""}
❤️
`; grid.appendChild(card); }); } // ===== Favorites ===== function isFavorited(itemId){ let favs = JSON.parse(localStorage.getItem("favs_"+user.id)||"[]"); return favs.includes(itemId); } function toggleFav(itemId,el){ let favs = JSON.parse(localStorage.getItem("favs_"+user.id)||"[]"); if(favs.includes(itemId)){ favs = favs.filter(i=>i!==itemId); el.classList.remove("active"); fetch(`${API_URL}?sheetName=Favorites&idCol=Item ID&idValue=${itemId}`, {method:'DELETE'}); } else { favs.push(itemId); el.classList.add("active"); fetch(`${API_URL}?sheetName=Favorites`, {method:'POST', body: JSON.stringify({ "User ID": user.id, "Item ID": itemId, "Date Saved": new Date().toISOString() })}); } localStorage.setItem("favs_"+user.id, JSON.stringify(favs)); } // ===== Profile ===== function openProfile(){ document.getElementById("profileModal").style.display="flex"; document.getElementById("userIdDisplay").textContent=user.id; } function closeProfile(){ document.getElementById("profileModal").style.display="none"; } function saveProfile(){ user.name=document.getElementById("userName").value; user.email=document.getElementById("userEmail").value; fetch(`${API_URL}?sheetName=Users`, {method:'POST', body: JSON.stringify({ "User ID": user.id, "Name": user.name, "Email": user.email, "Created": new Date().toISOString() })}); closeProfile(); } function importProfile(){ const uid = document.getElementById("importUserId").value; fetch(`${API_URL}?action=read&sheetName=Users`) .then(r=>r.json()) .then(data=>{ const u = data.find(u=>u["User ID"]===uid); if(u){ user={id:u["User ID"], name:u["Name"], email:u["Email"]}; localStorage.setItem("userId", user.id); document.getElementById("userName").value=user.name; document.getElementById("userEmail").value=user.email; alert("Imported profile!"); } else alert("User not found"); }); } // ===== Watchlist ===== function openWatchlist(){ document.getElementById("watchlistModal").style.display="flex"; loadWatchlist(); } function closeWatchlist(){ document.getElementById("watchlistModal").style.display="none"; } function loadWatchlist(){ fetch(`${API_URL}?action=read&sheetName=Watchlist`) .then(r=>r.json()) .then(data=>{ const div = document.getElementById("watchListItems"); div.innerHTML=""; data.filter(w=>w["User ID"]===user.id).forEach(w=>{ const el = document.createElement("div"); el.innerHTML=`${w["Keyword"]} `; div.appendChild(el); }); }); } function addWatch(){ const kw = document.getElementById("watchKeyword").value.trim(); if(!kw) return; fetch(`${API_URL}?sheetName=Watchlist`, {method:'POST', body: JSON.stringify({ "Watch ID": 'W'+Math.floor(Math.random()*1000000), "User ID": user.id, "Keyword": kw, "Created": new Date().toISOString() })}) .then(()=>loadWatchlist()); } function removeWatch(id,el){ fetch(`${API_URL}?sheetName=Watchlist&idCol=Watch ID&idValue=${id}`, {method:'DELETE'}).then(()=>loadWatchlist()); } // ===== Init ===== loadInventory();