mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
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:
1 parent
249607d0b2
commit
046d78862a
2 files changed
+45
-17
No files matched your search
@@ -48,6 +48,7 @@ import { TrendsRow } from "@/components/insights/trends-row";
|
|||||||
import { CorrelationRow } from "@/components/insights/correlation-row";
|
import { CorrelationRow } from "@/components/insights/correlation-row";
|
||||||
import { useInsightsAdvisorQuery } from "@/components/insights/use-insights-advisor";
|
import { useInsightsAdvisorQuery } from "@/components/insights/use-insights-advisor";
|
||||||
import type { CorrelationResult } from "@/lib/insights/correlations";
|
import type { CorrelationResult } from "@/lib/insights/correlations";
|
||||||
|
import { toWeekISO } from "@/lib/insights/week-iso";
|
||||||
import { CompareToggle } from "@/components/comparison/compare-toggle";
|
import { CompareToggle } from "@/components/comparison/compare-toggle";
|
||||||
// Recharts is ~108 KiB Brotli — defer-load it via a self-contained scatter
|
// 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.
|
// 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}`,
|
href: `/insights/report/${weeklyReport.weekISO}`,
|
||||||
}
|
}
|
||||||
: undefined;
|
: 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.
|
// 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
|
// The advisor payload may carry up to 20 entries; we transform them
|
||||||
@@ -955,6 +960,7 @@ export default function InsightsPage() {
|
|||||||
setCoachOpen(true);
|
setCoachOpen(true);
|
||||||
}}
|
}}
|
||||||
weeklyReportReady={weeklyReportReady}
|
weeklyReportReady={weeklyReportReady}
|
||||||
|
weeklyReportHref={currentWeekHref}
|
||||||
healthScore={analytics?.healthScore ?? undefined}
|
healthScore={analytics?.healthScore ?? undefined}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,13 @@ interface HeroStripProps {
|
|||||||
weekISO: string;
|
weekISO: string;
|
||||||
href: 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.
|
* Now() override for tests so the greeting bucket is deterministic.
|
||||||
* Defaults to `new Date()`. Production callers omit this.
|
* Defaults to `new Date()`. Production callers omit this.
|
||||||
@@ -156,6 +163,7 @@ export function HeroStrip({
|
|||||||
onPickPrompt,
|
onPickPrompt,
|
||||||
onAskCoach,
|
onAskCoach,
|
||||||
weeklyReportReady,
|
weeklyReportReady,
|
||||||
|
weeklyReportHref,
|
||||||
now,
|
now,
|
||||||
healthScore,
|
healthScore,
|
||||||
}: HeroStripProps) {
|
}: HeroStripProps) {
|
||||||
@@ -237,24 +245,38 @@ export function HeroStrip({
|
|||||||
|
|
||||||
<div className="flex flex-wrap items-center gap-2">
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
{/*
|
{/*
|
||||||
* v1.4.20 phase B4 ships the weekly-report route. Disabled
|
* v1.4.20 phase B4 shipped /insights/report/[week]; phase D
|
||||||
* here so the affordance lives in the hero from B1 onwards
|
* reconcile enables this button as a real link to the
|
||||||
* without dead links — title= surfaces the "Coming soon"
|
* current ISO week. Older parents that haven't adopted the
|
||||||
* caption on hover/focus without dragging in a Radix
|
* weeklyReportHref prop still get the disabled affordance.
|
||||||
* tooltip provider for a single static label.
|
|
||||||
*/}
|
*/}
|
||||||
<Button
|
{weeklyReportHref ? (
|
||||||
type="button"
|
<Button
|
||||||
variant="default"
|
asChild
|
||||||
size="sm"
|
variant="default"
|
||||||
disabled
|
size="sm"
|
||||||
title={comingSoon}
|
data-slot="insights-hero-strip-action-weekly-report"
|
||||||
data-slot="insights-hero-strip-action-weekly-report"
|
className="gap-1.5"
|
||||||
className="gap-1.5"
|
>
|
||||||
>
|
<Link href={weeklyReportHref}>
|
||||||
<FileText className="h-3.5 w-3.5" aria-hidden="true" />
|
<FileText className="h-3.5 w-3.5" aria-hidden="true" />
|
||||||
<span>{t("insights.heroActionWeeklyReport")}</span>
|
<span>{t("insights.heroActionWeeklyReport")}</span>
|
||||||
</Button>
|
</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
|
{/* B2b wires this into the Coach drawer. The button is
|
||||||
enabled whenever the parent supplies an `onAskCoach`
|
enabled whenever the parent supplies an `onAskCoach`
|
||||||
handler; older parents that haven't adopted B2b yet
|
handler; older parents that haven't adopted B2b yet
|
||||||
|
|||||||
Reference in new issue
Block a user