Fix Quick Log save and diaper icon
- Fix handleSubmit to properly wait for API response before closing - Change diaper icon from 🧷 to 👶 - Update activity scroller diaper icon Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
9e258d74b4
commit
797c970d81
1 changed files with 19 additions and 4 deletions
|
|
@ -87,9 +87,24 @@ function LogModal({ type, childId, onClose }: { type: "feed" | "diaper" | "sleep
|
|||
const data = { type, childId, subType, amountMl: amountMl ? Number(amountMl) : undefined, notes: notes || undefined };
|
||||
try {
|
||||
const res = await fetch("/api/logs", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(data) });
|
||||
if (!res.ok && !navigator.onLine) addToOfflineQueue({ type: type as any, data });
|
||||
if (!res.ok) {
|
||||
if (!navigator.onLine) {
|
||||
addToOfflineQueue({ type: type as any, data });
|
||||
} else {
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
onClose();
|
||||
} catch { addToOfflineQueue({ type: type as any, data }); onClose(); }
|
||||
} catch {
|
||||
if (!navigator.onLine) {
|
||||
addToOfflineQueue({ type: type as any, data });
|
||||
onClose();
|
||||
} else {
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
|
|
@ -155,7 +170,7 @@ function ActivityScroller({ lastLogs }: { lastLogs: any[] }) {
|
|||
const items = [
|
||||
{ icon: "🍼", label: "Fed", time: feedLog?.logged_at },
|
||||
{ icon: "😴", label: "Sleep", time: sleepLog?.logged_at },
|
||||
{ icon: "🧷", label: "Diaper", time: diaperLog?.logged_at },
|
||||
{ icon: "👶", label: "Diaper", time: diaperLog?.logged_at },
|
||||
].filter(item => item.time);
|
||||
|
||||
if (items.length === 0) return null;
|
||||
|
|
@ -339,7 +354,7 @@ export default function HomePage() {
|
|||
<div className="grid grid-cols-4 gap-2">
|
||||
<button onClick={() => setModalType("feed")} className="flex flex-col items-center p-4 bg-white dark:bg-gray-800 rounded-xl shadow-sm"><span className="text-3xl">🍼</span><span className="text-sm mt-1">Feed</span></button>
|
||||
<button onClick={() => setModalType("sleep")} className="flex flex-col items-center p-4 bg-white dark:bg-gray-800 rounded-xl shadow-sm"><span className="text-3xl">😴</span><span className="text-sm mt-1">Sleep</span></button>
|
||||
<button onClick={() => setModalType("diaper")} className="flex flex-col items-center p-4 bg-white dark:bg-gray-800 rounded-xl shadow-sm"><span className="text-3xl">🧷</span><span className="text-sm mt-1">Diaper</span></button>
|
||||
<button onClick={() => setModalType("diaper")} className="flex flex-col items-center p-4 bg-white dark:bg-gray-800 rounded-xl shadow-sm"><span className="text-3xl">👶</span><span className="text-sm mt-1">Diaper</span></button>
|
||||
<Link href="/medical" className="flex flex-col items-center p-4 bg-white dark:bg-gray-800 rounded-xl shadow-sm"><span className="text-3xl">💊</span><span className="text-sm mt-1">Medical</span></Link>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue