diff --git a/src/app/page.tsx b/src/app/page.tsx
index fe254da..efd174b 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -96,27 +96,35 @@ function LogModal({ type, childId, onClose }: { type: "feed" | "diaper" | "sleep
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" />
-
+ {type === "feed" && (<>
setAmountMl(e.target.value)} className="w-full p-3 border dark:border-gray-600 rounded-xl mb-3 bg-white dark:bg-gray-700 dark:text-white dark:placeholder-gray-400" />>)}
+ {type === "diaper" && (
)}
+ {type === "sleep" && (
)}
+
setNotes(e.target.value)} className="w-full p-3 border dark:border-gray-600 rounded-xl mb-4 bg-white dark:bg-gray-700 dark:text-white dark:placeholder-gray-400" />
+
);
}
function calculateAge(birthDate: string) {
+ if (!birthDate) return "";
const birth = new Date(birthDate);
const now = new Date();
- const days = Math.floor((now.getTime() - birth.getTime()) / (1000 * 60 * 60 * 24));
- const months = Math.floor(days / 30);
- const years = Math.floor(months / 12);
- if (years > 0) return `${years} year${years > 1 ? "s" : ""} old`;
- if (months > 0) return `${months} month${months > 1 ? "s" : ""} old`;
- return `${days} day${days > 1 ? "s" : ""} old`;
+ let years = now.getFullYear() - birth.getFullYear();
+ let months = now.getMonth() - birth.getMonth();
+ let days = now.getDate() - birth.getDate();
+ if (days < 0) {
+ months--;
+ days += new Date(now.getFullYear(), now.getMonth(), 0).getDate();
+ }
+ if (months < 0) { years--; months += 12; }
+ const parts = [];
+ if (years > 0) parts.push(`${years} year${years > 1 ? "s" : ""}`);
+ if (months > 0) parts.push(`${months} month${months > 1 ? "s" : ""}`);
+ if (days > 0) parts.push(`${days} day${days > 1 ? "s" : ""}`);
+ return parts.length > 0 ? parts.join(", ") : "Newborn";
}
function getGreeting() {
@@ -256,13 +264,13 @@ export default function HomePage() {
{getGreeting()} 👋
-
How is {child?.name || "your baby"} doing today?
+
How is {child?.name || "your baby"} doing today?
-
+
-
👶
-
{child?.name || "Baby"}
{calculateAge(child?.birthDate || "")}
+
👶
+
{child?.name || "Baby"}
{calculateAge(child?.birthDate || "")}
@@ -287,10 +295,10 @@ export default function HomePage() {
Quick Log
-
-
-
- 💊Medical
+
+
+
+ 💊Medical
@@ -299,13 +307,13 @@ export default function HomePage() {
Ask AI
View all chats →
-
@@ -314,12 +322,12 @@ export default function HomePage() {
Recent Activity
{lastLogs.length === 0 ?
No logs yet today
: lastLogs.filter(Boolean).map((log: any, i: number) => (
-
+
{log.type === "feed" && "🍼"}{log.type === "sleep" && "😴"}{log.type === "diaper" && "👶"}
-
{log.type}
{new Date(log.logged_at).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}
+
{log.type}
{new Date(log.logged_at).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}
- {log.amount_ml &&
{log.amount_ml}ml}
+ {log.amount_ml &&
{log.amount_ml}ml}
))}
@@ -336,7 +344,7 @@ export default function HomePage() {
{aiLoading &&
Thinking...
}
- setAiInput(e.target.value)} onKeyDown={e => e.key === "Enter" && handleAiChat()} placeholder="Ask a question..." className="flex-1 p-2 border rounded-xl text-sm" disabled={aiLoading} />
+ setAiInput(e.target.value)} onKeyDown={e => e.key === "Enter" && handleAiChat()} placeholder="Ask a question..." className="flex-1 p-2 border dark:border-gray-600 rounded-xl text-sm dark:bg-gray-700 dark:text-white dark:placeholder-gray-400" disabled={aiLoading} />