diff --git a/src/app/growth/page.tsx b/src/app/growth/page.tsx new file mode 100644 index 0000000..8f25402 --- /dev/null +++ b/src/app/growth/page.tsx @@ -0,0 +1,97 @@ +"use client"; + +import { useState, useEffect } from "react"; + +export default function GrowthPage() { + const [childId] = useState("5ad3b16a-1e0d-45ab-bc91-038397d75d0a"); + const [growthData, setGrowthData] = useState([]); + const [loading, setLoading] = useState(true); + const [showAdd, setShowAdd] = useState(false); + const [weight, setWeight] = useState(""); + const [height, setHeight] = useState(""); + + useEffect(() => { + fetch(`/api/growth?childId=${childId}`) + .then(r => r.json()) + .then(data => { + setGrowthData(data.growth || []); + setLoading(false); + }) + .catch(() => setLoading(false)); + }, [childId]); + + const handleAdd = async () => { + await fetch("/api/growth", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + childId, + measuredAt: new Date().toISOString(), + weightKg: weight ? parseFloat(weight) : null, + heightCm: height ? parseFloat(height) : null, + }), + }); + setShowAdd(false); + window.location.reload(); + }; + + return ( +
+
+
+ +

Growth 📈

+
+ +
+ + {showAdd && ( +
+ setWeight(e.target.value)} + className="w-full p-3 border rounded-xl mb-2" + /> + setHeight(e.target.value)} + className="w-full p-3 border rounded-xl mb-2" + /> + +
+ )} + +
+ {loading ? ( +

Loading...

+ ) : growthData.length === 0 ? ( +

No growth records yet

+ ) : ( + growthData.map((record: any, i: number) => ( +
+
+ {new Date(record.measured_at).toLocaleDateString()} +
+
+ {record.weight_kg && ( +
⚖️ {record.weight_kg} kg
+ )} + {record.height_cm && ( +
📏 {record.height_cm} cm
+ )} +
+
+ )) + )} +
+
+ ); +} \ No newline at end of file diff --git a/src/app/memories/page.tsx b/src/app/memories/page.tsx new file mode 100644 index 0000000..c17e98b --- /dev/null +++ b/src/app/memories/page.tsx @@ -0,0 +1,56 @@ +"use client"; + +import { useState } from "react"; + +// Note: Needs Cloudflare R2 configured for actual uploads +// For now, shows placeholders +const memories = [ + { id: 1, date: "2024-01-15", thumbnail: "👶", title: "First day home" }, + { id: 2, date: "2024-02-20", thumbnail: "🍼", title: "First smile" }, + { id: 3, date: "2024-03-10", thumbnail: "🎉", title: "Happy month" }, +]; + +export default function MemoriesPage() { + const [selected, setSelected] = useState(null); + + return ( +
+
+ +

Memories 📸

+
+ +
+
+ {memories.map((mem) => ( + + ))} +
+
+ + {/* Add Button */} +
+ +
+ + {/* Modal */} + {selected && ( +
setSelected(null)}> +
+
{selected.thumbnail}
+
{selected.title}
+
{selected.date}
+
+
+ )} +
+ ); +} \ No newline at end of file