feat(vorsorge): add 7-day trend strip + measurements deep link to reminder cards

Enrich the Vorsorge cards with a discreet 7-day trend strip and a path
into the underlying readings.

- A quiet seven-bar strip of the reminder metric's last seven readings
  sits under the metric context on both the dashboard summary card and
  the full-grid cards, mirroring how a dashboard tile carries a small
  trend. Neutral muted bars, no status colour. A free-text reminder or a
  metric with fewer than two readings shows nothing, so card height stays
  stable. The strip reads a bounded last-7 window per type through the
  existing measurements endpoint, cached by type under the measurements
  invalidation prefix.
- The card kebab gains a 'Show measurements' item for measurement-linked
  reminders that opens /measurements pre-filtered to that type.
- The measurements list accepts a ?type=<MEASUREMENT_TYPE> deep link that
  seeds the existing client-side type filter while leaving the rail
  interactive; unknown tokens are dropped. The ?add= behaviour is
  unchanged.
- New labels added across all six locales.
This commit is contained in:
Marc-André Bombeck committed 2026-06-19 19:45:14 +02:00
1 parent f931f2f5c2
commit c7425ca426
13 files changed
+205 -9

No files matched your search

+24 -5
View File
@@ -10,6 +10,7 @@ import {
resolveAddToken,
} from "@/components/measurements/measurement-form";
import { MeasurementList } from "@/components/measurements/measurement-list";
import { MEASUREMENT_TYPE_LABEL_KEYS } from "@/components/measurements/measurement-list-meta";
import { Button } from "@/components/ui/button";
import { PullToRefreshIndicator } from "@/components/ui/pull-to-refresh-indicator";
import { ResponsiveSheet } from "@/components/ui/responsive-sheet";
@@ -41,6 +42,18 @@ export default function MeasurementsPage() {
// effect, so that path stays render-driven.
const addParam = searchParams.get("add");
const initialAdd = addParam ? resolveAddToken(addParam) : null;
// v1.18.7 (Wave E) — a `?type=<MEASUREMENT_TYPE>` deep link (e.g. the
// Vorsorge card's "Show measurements") seeds the list's type filter on
// first paint. Captured once via a lazy initializer so the value is
// stable even after the effect below strips the query string; an unknown
// token is dropped (validated against the canonical type-label map), so a
// stale link never traps the user on a broken filter.
const typeParam = searchParams.get("type");
const [initialType] = useState<string | undefined>(() =>
typeParam && typeParam in MEASUREMENT_TYPE_LABEL_KEYS
? typeParam
: undefined,
);
const [dialogOpen, setDialogOpen] = useState(() => initialAdd != null);
const [defaultType, setDefaultType] = useState<string | undefined>(
() => initialAdd ?? undefined,
@@ -82,11 +95,14 @@ export default function MeasurementsPage() {
}
// Drop the query string so the back-button leaves the user on
// `/measurements` rather than re-opening the dialog. Effect-driven
// (client-only) because `router.replace` is not callable during SSR.
// `/measurements` rather than re-opening the dialog (or re-seeding the
// type filter). The type filter is already seeded into the list's own
// state via `initialType`, so stripping the param doesn't lose it.
// Effect-driven (client-only) because `router.replace` is not callable
// during SSR.
useEffect(() => {
if (addParam) router.replace("/measurements");
}, [addParam, router]);
if (addParam || typeParam) router.replace("/measurements");
}, [addParam, typeParam, router]);
useEffect(() => {
if (!isLoading && !isAuthenticated) {
@@ -157,7 +173,10 @@ export default function MeasurementsPage() {
/>
</ResponsiveSheet>
<MeasurementList onAddFirst={() => setDialogOpen(true)} />
<MeasurementList
onAddFirst={() => setDialogOpen(true)}
initialType={initialType}
/>
</div>
);
}