diff --git a/src/app/page.tsx b/src/app/page.tsx index 6773edc..a091522 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,35 +1,167 @@ +"use client"; + +import { useState, useEffect } from "react"; + +interface LogModalProps { + type: "feed" | "diaper" | "sleep" | null; + childId: string; + onClose: () => void; +} + +function LogModal({ type, childId, onClose }: LogModalProps) { + const [loading, setLoading] = useState(false); + const [subType, setSubType] = useState("breast_milk"); + const [amountMl, setAmountMl] = useState(""); + const [notes, setNotes] = useState(""); + + if (!type) return null; + + const handleSubmit = async () => { + setLoading(true); + try { + await fetch("/api/logs", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + type, + childId, + subType, + amountMl: amountMl ? Number(amountMl) : undefined, + notes: notes || undefined, + }), + }); + onClose(); + } catch (err) { + console.error(err); + } + setLoading(false); + }; + + return ( +
+
+

+ {type === "feed" && "Log Feed"} + {type === "diaper" && "Log Diaper"} + {type === "sleep" && "Log Sleep"} +

+ + {type === "feed" && ( + <> + + setAmountMl(e.target.value)} + className="w-full p-3 border rounded-xl mb-3" + /> + + )} + + {type === "diaper" && ( + + )} + + {type === "sleep" && ( + + )} + + setNotes(e.target.value)} + className="w-full p-3 border rounded-xl mb-4" + /> + +
+ + +
+
+
+ ); +} + export default function HomePage() { + const [modalType, setModalType] = useState<"feed" | "diaper" | "sleep" | null>(null); + const [childId, setChildId] = useState("5ad3b16a-1e0d-45ab-bc91-038397d75d0a"); + return (
-

Welcome to Tia 👶

+

Tia 👶

Your baby tracking companion

- - - -
-

Baby: Tia (2 years old)

+

Baby: Baby Tia

+ + setModalType(null)} />
); } \ No newline at end of file