feat(meds): scope the advanced-settings export to the single medication

The advanced sheet sits on one medication and its import already loads
that medication's intake history, but the co-located export streamed
every medication. Pass the medication id through to the export route,
which narrows both the medication row and the intake history by it
(always alongside userId, so a foreign id 404s rather than leaking).
This commit is contained in:
Marc-André Bombeck committed 2026-05-31 20:22:40 +02:00
1 parent 8363db4146
commit 24ffca7220
4 files changed
+82 -5

No files matched your search

@@ -61,11 +61,14 @@ export function DataPortabilityRow({
setBusy(true);
setError(null);
try {
const query = includeIntake ? "?intake=true" : "?intake=false";
const query = new URLSearchParams({
intake: includeIntake ? "true" : "false",
medicationId,
}).toString();
const stamp = new Date().toISOString().slice(0, 10);
await downloadFromUrl(
`/api/export/medications${query}`,
`healthlog-medications-${stamp}.csv`,
`/api/export/medications?${query}`,
`healthlog-medication-${stamp}.csv`,
);
} catch (err) {
setError(err instanceof Error ? err.message : String(err));