diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx index 3eb22bd8..dd50f739 100644 --- a/frontend/app/page.tsx +++ b/frontend/app/page.tsx @@ -165,11 +165,18 @@ export default function Home() { await db.items.add(itemData); // 2. If online, try to push to backend immediately - if (isOnline) { - await inventoryApi.createItem(1, itemData); - toast.success("Item saved to cloud catalog!"); - } else { + if (isOnline && currentUser) { + try { + await inventoryApi.createItem(currentUser.id, itemData); + toast.success("Item saved to cloud catalog!"); + } catch (err: any) { + console.error("Cloud sync failed:", err.message); + toast.error("Item saved locally. Cloud sync failed."); + } + } else if (!isOnline) { toast.success("Item saved locally. Will sync when online."); + } else { + toast("Please log in to save to cloud.", { icon: '⚠️' }); } setShowOnboarding(false);