mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 06:32:03 +00:00
Settings → Gesundheitsakte mounts the one scope picker twice: the export panel at the top, the share-link create form under `#sharing`. Sharing the component is deliberate, but it also meant every test id inside it resolved to two elements on that page, so nothing in the picker could be addressed without guessing which one you got. The picker now takes a required `surface` and every id under it ends with that surface — `report-group-row-vitals-export` and `report-group-row-vitals-share` are two controls and read as two controls. The summary line beside each picker follows the same rule. A third mount picks a value and stays addressable by construction.
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
"use client";
|
|
|
|
/**
|
|
* The one line that says what the artefact will contain.
|
|
*
|
|
* This is the consent check: reading it IS the review. Fenced inclusions are
|
|
* restated by name rather than folded into the count, because a number cannot
|
|
* be checked at a glance and "incl. Mood, PHQ-9" can.
|
|
*
|
|
* Meta tier — one sentence about the form beside it, not content.
|
|
*
|
|
* One per picker, so the test id ends with the same surface its picker does.
|
|
*/
|
|
import { scopeSummary } from "@/lib/report-selection/panel-state";
|
|
import type { ReportLeafId } from "@/lib/report-selection/catalogue";
|
|
|
|
import type { ReportScopeSurface } from "./surface";
|
|
|
|
export function ScopeSummary({
|
|
t,
|
|
surface,
|
|
selected,
|
|
}: {
|
|
t: (key: string, vars?: Record<string, string | number>) => string;
|
|
surface: ReportScopeSurface;
|
|
selected: ReadonlySet<ReportLeafId>;
|
|
}) {
|
|
const summary = scopeSummary(selected);
|
|
if (summary.total === 0) {
|
|
return (
|
|
<p
|
|
className="text-muted-foreground text-xs"
|
|
data-testid={`report-scope-summary-${surface}`}
|
|
>
|
|
{t("reportSelection.scopeNone")}
|
|
</p>
|
|
);
|
|
}
|
|
const base = t("reportSelection.scopeCount", {
|
|
count: summary.total,
|
|
groups: summary.groups,
|
|
});
|
|
const sensitive =
|
|
summary.sensitiveLabelKeys.length > 0
|
|
? t("reportSelection.scopeSensitive", {
|
|
names: summary.sensitiveLabelKeys.map((key) => t(key)).join(", "),
|
|
})
|
|
: null;
|
|
return (
|
|
<p
|
|
className="text-muted-foreground text-xs"
|
|
data-testid={`report-scope-summary-${surface}`}
|
|
>
|
|
{sensitive ? `${base} · ${sensitive}` : base}
|
|
</p>
|
|
);
|
|
}
|