diff --git a/src/app/milestones/page.tsx b/src/app/milestones/page.tsx index 2b35038..031120a 100644 --- a/src/app/milestones/page.tsx +++ b/src/app/milestones/page.tsx @@ -3,6 +3,7 @@ import { useEffect, useState, useMemo } from "react"; import { useFamily } from "@/app/FamilyProvider"; import { useStageCheck } from "@/hooks/useStageCheck"; import { MILESTONES, type MilestoneDef } from "@/lib/milestones"; +import { Button, Input } from "@/components/ui"; type Category = "all" | "social" | "motor" | "language" | "cognitive"; type Filter = "all" | "achieved" | "upcoming"; @@ -29,7 +30,6 @@ export default function MilestonesPage() { const [filter, setFilter] = useState("all"); const [category, setCategory] = useState("all"); - // date picker state per milestone key const [pendingKey, setPendingKey] = useState(null); const [pendingDate, setPendingDate] = useState( new Date().toISOString().slice(0, 10) @@ -46,7 +46,6 @@ export default function MilestonesPage() { async function toggleMilestone(m: MilestoneWithStatus) { if (m.achieved) { - // un-mark await fetch(`/api/milestones/${m.key}?childId=${child!.id}`, { method: "DELETE" }); setItems(prev => prev.map(x => x.key === m.key ? { ...x, achieved: false, achievedAt: null } : x)); if (pendingKey === m.key) setPendingKey(null); @@ -84,76 +83,83 @@ export default function MilestonesPage() { }, [items, stage]); if (!child) return ( -
+

Select a child to view milestones.

); return ( -
-
- {/* Header */} -
+
+ {/* Header */} +
+
+
-

Milestones

-

{child.name}

-
- {stage && ( - - {stage.emoji} {stage.label} - - )} -
- - {/* Progress bar */} -
-
- {achievedCount} of {items.length} milestones - {Math.round(achievedCount / Math.max(items.length, 1) * 100)}% -
-
-
+

Milestones 🌱

+

{child.name}

+ {stage && ( + + {stage.emoji} {stage.label} + + )} +
- {/* Filter tabs */} -
- {(["all", "achieved", "upcoming"] as Filter[]).map(f => ( - - ))} + {/* Progress bar */} +
+
+ + {achievedCount} of {items.length} milestones + + + {Math.round(achievedCount / Math.max(items.length, 1) * 100)}% +
- - {/* Category chips */} -
- {(["all", "social", "motor", "language", "cognitive"] as Category[]).map(c => ( - - ))} +
+
+
- {/* Milestone grid */} + {/* Filter tabs */} +
+ {(["all", "achieved", "upcoming"] as Filter[]).map(f => ( + + ))} +
+ + {/* Category chips */} +
+ {(["all", "social", "motor", "language", "cognitive"] as Category[]).map(c => ( + + ))} +
+ + {/* Milestone grid */} +
{loading ? (
{Array.from({ length: 6 }).map((_, i) => ( @@ -161,7 +167,10 @@ export default function MilestonesPage() { ))}
) : filtered.length === 0 ? ( -

No milestones match this filter.

+
+
🌱
+

No milestones match this filter.

+
) : (
{filtered.map(m => ( @@ -195,28 +204,22 @@ export default function MilestonesPage() { {/* Inline date picker */} {pendingKey === m.key && ( -
-

When did this happen?

- +

When did this happen?

+ setPendingDate(e.target.value)} - className="w-full text-sm border dark:border-gray-600 rounded-lg px-2 py-1.5 dark:bg-gray-700 dark:text-white mb-2" + className="mb-2" />
- - + +
)}