feat(targets): card layout with status pill + consistency + coach handoff

Replaces the inline 790-line page.tsx composition with the W3e
primitives extracted in the previous phase. The page is now ~270
lines of orchestration:

- TanStack-Query pulls the redesigned targets payload (with the
  v1.4.25 consistency + summary additions).
- A second query reads /api/insights/provider-chain to derive
  `aiEnabled = chainStatus?.activeProvider != null`. The flag threads
  down into every <TargetCard>, which uses it to gate the per-card
  Coach CTA — no broken-button state when the user has no provider
  configured.
- A new `useCoachHandoff()` hook (src/hooks/use-coach-handoff.ts)
  owns the drawer's open + prefill + scope triple. Per-card buttons
  call `askCoach()`; the hook flips state and the drawer mounts
  inline at the page level.
- Cards now render in a fixed order (BP / BP-in-target / WEIGHT /
  PULSE / BMI / MOOD / COMPLIANCE / SLEEP / BODY_FAT / STEPS) — Marc
  directive: stable visual hierarchy beats status-sorting because
  the user's eye lands on the same metric in the same place every
  visit.
- Source-citation URLs stay on the page (declarative routing) and
  thread into <TargetCard> via the `sourceLink` prop.

The old inline TargetCard / RangeBar / TrendIcon / status-category
map are deleted along with the dead `Badge` + lucide imports.
Existing targets-i18n + targets-spacing tests updated to mock the
new useQueryClient + useMutation surfaces that the embedded
<CoachDrawer> needs at SSR; both suites still assert the same
visual contracts and pass.

Wave 2 deliverables also folded into this commit:
- pageSummary mounts via the W3e header above the grid
- consistency strip renders only when insufficientData === false
- recency caption ("last met goal: 2 days ago") renders only when
  lastMetGoalAt !== null
- streak chip ("4-day streak") renders only when streakDays ≥ 3
This commit is contained in:
Marc-André Bombeck committed 2026-05-14 12:33:53 +02:00
1 parent 96c5e79539
commit f2b9f843b1
9 files changed
+269 -606

No files matched your search

+2 -4
View File
@@ -58,8 +58,7 @@ const TEMPLATES_EN: Record<string, Template> = {
MOOD_SCORE: (i) =>
`My latest mood score is ${fmt(i.current)} / 5 and my target is ${i.range ? `${i.range.min}+ / 5` : "3.5+ / 5"}. How does my mood compare to recent weeks and what could I try?`,
MOOD_STABILITY: (i) => {
const label =
i.current != null ? moodStabilityLabel(i.current) : "stable";
const label = i.current != null ? moodStabilityLabel(i.current) : "stable";
const verbal =
label === "stable"
? "stable"
@@ -86,8 +85,7 @@ const TEMPLATES_DE: Record<string, Template> = {
MOOD_SCORE: (i) =>
`Mein letzter Stimmungs-Wert ist ${fmt(i.current)} / 5, mein Ziel liegt bei ${i.range ? `${i.range.min}+ / 5` : "3,5+ / 5"}. Wie ist meine Stimmung im Vergleich zu den letzten Wochen, und was könnte ich ausprobieren?`,
MOOD_STABILITY: (i) => {
const label =
i.current != null ? moodStabilityLabel(i.current) : "stable";
const label = i.current != null ? moodStabilityLabel(i.current) : "stable";
const verbal =
label === "stable"
? "stabil"