mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 14:32:03 +00:00
feat(insights): link the overview Trends cards to their detail pages
The overview charted each trend but never offered a way into the metric's detail page — the steps page in particular exists and is used, yet Insights never linked to it. Give every Trends-row chart a routed detail target and a discreet "view details" link below the caption, so a metric the row surfaces (steps included, when the briefing flags it) drills into /insights/<slug>.
This commit is contained in:
1 parent
71b29f5b6f
commit
34fbfe1c67
10 files changed
+83
-7
No files matched your search
@@ -284,4 +284,22 @@ describe("<TrendsRow>", () => {
|
||||
expect(html).toContain("Moderate confidence");
|
||||
expect(html).toContain("Low confidence");
|
||||
});
|
||||
|
||||
// ── v1.18.6 — detail-page cross-links (the Insights→steps gap) ──────
|
||||
it("links each metric card to its detail page", () => {
|
||||
const html = render(<TrendsRow />);
|
||||
// The default BP / weight / mood triple each link to their sub-page.
|
||||
expect(html).toContain('data-slot="trends-row-detail-link"');
|
||||
expect(html).toContain('href="/insights/blood-pressure"');
|
||||
expect(html).toContain('href="/insights/weight"');
|
||||
expect(html).toContain('href="/insights/mood"');
|
||||
});
|
||||
|
||||
it("offers the steps detail link when the briefing flags steps", () => {
|
||||
// Steps has a routed sub-page but the overview never linked to it; a
|
||||
// briefing finding on steps now charts it AND drills into /insights/steps.
|
||||
const html = render(<TrendsRow briefing={briefing(["steps"])} />);
|
||||
expect(html).toMatch(/data-metric="steps"/);
|
||||
expect(html).toContain('href="/insights/steps"');
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,8 @@
|
||||
"use client";
|
||||
|
||||
import dynamic from "next/dynamic";
|
||||
import { TrendingUp } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { ArrowRight, TrendingUp } from "lucide-react";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { ChartSkeleton } from "@/components/charts/chart-skeleton";
|
||||
@@ -301,6 +302,22 @@ export function TrendsRow({
|
||||
text={t(config.captionKey)}
|
||||
/>
|
||||
)}
|
||||
{/* v1.18.6 — drill-in link to the metric's detail page. The
|
||||
overview charted these metrics but never offered a way INTO
|
||||
their detail pages — notably the steps page, which exists and
|
||||
is used but was unreachable from Insights. The link sits below
|
||||
the caption so the chart keeps its own interactions. */}
|
||||
{config.detailHref ? (
|
||||
<Link
|
||||
href={config.detailHref}
|
||||
data-slot="trends-row-detail-link"
|
||||
data-metric={config.metric}
|
||||
className="text-muted-foreground hover:text-foreground mt-auto inline-flex items-center gap-1 self-start text-xs font-medium transition-colors"
|
||||
>
|
||||
{t("insights.trendsRow.viewDetail", { metric: title })}
|
||||
<ArrowRight className="h-3.5 w-3.5" aria-hidden="true" />
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
Reference in new issue
Block a user