feat(insights): enable Generate weekly report button on hero

Phase B4 shipped /insights/report/[week] but the hero action-row
button stayed disabled with a "Coming soon" tooltip. Wire it into the
current ISO week so a click opens this week's report. Older parents
that don't pass weeklyReportHref still get the disabled placeholder.

Fixes Design pushback (item 6).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marc-André BombeckandClaude Opus 4.7 committed 2026-05-10 18:04:07 +02:00
1 parent 249607d0b2
commit 046d78862a
2 files changed
+45 -17

No files matched your search

+6
View File
@@ -48,6 +48,7 @@ import { TrendsRow } from "@/components/insights/trends-row";
import { CorrelationRow } from "@/components/insights/correlation-row";
import { useInsightsAdvisorQuery } from "@/components/insights/use-insights-advisor";
import type { CorrelationResult } from "@/lib/insights/correlations";
import { toWeekISO } from "@/lib/insights/week-iso";
import { CompareToggle } from "@/components/comparison/compare-toggle";
// Recharts is ~108 KiB Brotli — defer-load it via a self-contained scatter
// wrapper so the bundle only lands once a correlation card actually renders.
@@ -906,6 +907,10 @@ export default function InsightsPage() {
href: `/insights/report/${weeklyReport.weekISO}`,
}
: undefined;
// v1.4.20 phase D reconcile — the action-row "Generate weekly report"
// button links into the current ISO week's report (B4 shipped the
// route, so the disabled-primary placeholder no longer makes sense).
const currentWeekHref = `/insights/report/${toWeekISO(new Date())}`;
// v1.4.20 phase B4 — storyboard annotations for the 90-day BP chart.
// The advisor payload may carry up to 20 entries; we transform them
@@ -955,6 +960,7 @@ export default function InsightsPage() {
setCoachOpen(true);
}}
weeklyReportReady={weeklyReportReady}
weeklyReportHref={currentWeekHref}
healthScore={analytics?.healthScore ?? undefined}
/>
+39 -17
View File
@@ -89,6 +89,13 @@ interface HeroStripProps {
weekISO: string;
href: string;
};
/**
* v1.4.20 phase D reconcile — href to the current week's report. When
* supplied, the action-row "Generate weekly report" button becomes a
* real link instead of the disabled placeholder. B4 shipped the
* route, so the button should not paint as disabled-primary anymore.
*/
weeklyReportHref?: string;
/**
* Now() override for tests so the greeting bucket is deterministic.
* Defaults to `new Date()`. Production callers omit this.
@@ -156,6 +163,7 @@ export function HeroStrip({
onPickPrompt,
onAskCoach,
weeklyReportReady,
weeklyReportHref,
now,
healthScore,
}: HeroStripProps) {
@@ -237,24 +245,38 @@ export function HeroStrip({
<div className="flex flex-wrap items-center gap-2">
{/*
* v1.4.20 phase B4 ships the weekly-report route. Disabled
* here so the affordance lives in the hero from B1 onwards
* without dead links — title= surfaces the "Coming soon"
* caption on hover/focus without dragging in a Radix
* tooltip provider for a single static label.
* v1.4.20 phase B4 shipped /insights/report/[week]; phase D
* reconcile enables this button as a real link to the
* current ISO week. Older parents that haven't adopted the
* weeklyReportHref prop still get the disabled affordance.
*/}
<Button
type="button"
variant="default"
size="sm"
disabled
title={comingSoon}
data-slot="insights-hero-strip-action-weekly-report"
className="gap-1.5"
>
<FileText className="h-3.5 w-3.5" aria-hidden="true" />
<span>{t("insights.heroActionWeeklyReport")}</span>
</Button>
{weeklyReportHref ? (
<Button
asChild
variant="default"
size="sm"
data-slot="insights-hero-strip-action-weekly-report"
className="gap-1.5"
>
<Link href={weeklyReportHref}>
<FileText className="h-3.5 w-3.5" aria-hidden="true" />
<span>{t("insights.heroActionWeeklyReport")}</span>
</Link>
</Button>
) : (
<Button
type="button"
variant="default"
size="sm"
disabled
title={comingSoon}
data-slot="insights-hero-strip-action-weekly-report"
className="gap-1.5"
>
<FileText className="h-3.5 w-3.5" aria-hidden="true" />
<span>{t("insights.heroActionWeeklyReport")}</span>
</Button>
)}
{/* B2b wires this into the Coach drawer. The button is
enabled whenever the parent supplies an `onAskCoach`
handler; older parents that haven't adopted B2b yet