diff --git a/src/App.jsx b/src/App.jsx index e1ddebf..28a162e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -12,16 +12,10 @@ const storage = { try { const val = localStorage.getItem(key); return val ? { value: val } : null; - } catch { - return null; - } + } catch { return null; } }, set: async (key, val) => { - try { - localStorage.setItem(key, val); - } catch (e) { - console.error("Storage set failed:", e); - } + try { localStorage.setItem(key, val); } catch (e) { console.error("Storage set failed:", e); } } }; @@ -30,24 +24,15 @@ async function loadData() { const result = await storage.get(STORAGE_KEY); if (result) { const parsed = JSON.parse(result.value); - return { - beans: parsed.beans || [], - brewLogs: parsed.brewLogs || [], - lastSyncedAt: parsed.lastSyncedAt || null - }; + return { beans: parsed.beans || [], brewLogs: parsed.brewLogs || [], lastSyncedAt: parsed.lastSyncedAt || null }; } return defaultData; - } catch { - return defaultData; - } + } catch { return defaultData; } } async function saveData(data) { - try { - await storage.set(STORAGE_KEY, JSON.stringify(data)); - } catch (e) { - console.error("Save failed:", e); - } + try { await storage.set(STORAGE_KEY, JSON.stringify(data)); } + catch (e) { console.error("Save failed:", e); } } const uid = () => Date.now().toString(36) + Math.random().toString(36).slice(2, 7); @@ -58,12 +43,42 @@ const METHOD_LABELS = { pourover: "Pour Over", espresso: "Espresso", coldbrew: " const METHOD_ICONS = { pourover: "☕", espresso: "⚡", coldbrew: "❄️" }; const METHOD_COLORS = { pourover: "#8B6914", espresso: "#5C3317", coldbrew: "#2F4F6F" }; -// ─── Shared input/label styles ─── -const inputCls = "w-full px-3.5 py-3 border border-[#E8DFD3] rounded-lg bg-white font-sans text-sm text-[#2C1810] transition-colors outline-none focus:border-[#8B6914]"; +const inputCls = "w-full px-3.5 py-3 border border-[#E8DFD3] rounded-lg bg-white text-sm text-[#2C1810] transition-colors outline-none focus:border-[#8B6914]"; const labelCls = "block text-[10px] font-semibold uppercase tracking-wider text-[#6B5744] mb-1.5"; -// ─── Components ─── +// ─── Create Modal ─── +function CreateModal({ onClose, onAddBean, onAddBrew }) { + return ( +
+
e.stopPropagation()}> +
+
What would you like to add?
+
+ + +
+
+
+ ); +} +// ─── Bean Form ─── function BeanForm({ onSave, onClose, initial }) { const [form, setForm] = useState(initial || { name: "", roastery: "", roastDate: "", roastType: "", image: "", tastingNotes: "" }); const set = (k, v) => setForm(p => ({ ...p, [k]: v })); @@ -80,62 +95,39 @@ function BeanForm({ onSave, onClose, initial }) { return (
-
e.stopPropagation()}> +
e.stopPropagation()}>
{initial ? "Edit Bean" : "Add Bean"}
- -
- - set("name", e.target.value)} /> -
-
- - set("roastery", e.target.value)} /> -
+
+ set("name", e.target.value)} />
+
+ set("roastery", e.target.value)} />
-
- - set("roastDate", e.target.value)} /> -
-
- +
+ set("roastDate", e.target.value)} />
+
-
+
-
-
+
{form.image ? ( - <> - Bean + <>Bean - - ) : ( - <> -
📷
-
Tap to upload a photo
- - )} + onClick={(e) => { e.stopPropagation(); set("image", ""); }} type="button">× + ) : (<>
📷
Tap to upload a photo
)}
Max 2 MB · JPG, PNG, or WebP
- -
- -