refactor(import): derive the CSV example header from the shared column list

The downloadable CSV example pinned its header as an inline string literal
while csv-measurements.ts exported CSV_EXAMPLE_COLUMNS as the documented
single source of truth for that order — so the two could silently drift.
Derive the example header from the constant; the column order now has one
owner and the previously unused export is wired in.
This commit is contained in:
Marc-André Bombeck committed 2026-06-15 01:20:49 +02:00
1 parent a27247f93c
commit 7a96a934bf
1 file changed
+2 -1
+2 -1
View File
@@ -45,6 +45,7 @@ import { queryKeys } from "@/lib/query-keys";
import { useTranslations } from "@/lib/i18n/context";
import { cn } from "@/lib/utils";
import { apiFetchRaw, apiGet } from "@/lib/api/api-fetch";
import { CSV_EXAMPLE_COLUMNS } from "@/lib/import/csv-measurements";
// ─────────────────────────── Section wrapper ───────────────────────────
@@ -641,7 +642,7 @@ function JsonImportCard() {
* drift. Exported so a test can assert it stays a valid header.
*/
export const EXAMPLE_CSV = [
"type,value,unit,measuredAt,glucoseContext,notes,externalId",
CSV_EXAMPLE_COLUMNS.join(","),
"WEIGHT,80.5,kg,2026-05-01T08:00:00Z,,morning,",
"BLOOD_GLUCOSE,5.3,mmol/L,2026-05-01T08:05:00+02:00,FASTING,,meter-001",
"BLOOD_PRESSURE_SYS,120,mmHg,2026-05-01T08:05:00+02:00,,,",