diff --git a/src/components/insights/glucose/__tests__/glucose-clinical-panel.test.tsx b/src/components/insights/glucose/__tests__/glucose-clinical-panel.test.tsx index 6dbb55925..bc39ce83f 100644 --- a/src/components/insights/glucose/__tests__/glucose-clinical-panel.test.tsx +++ b/src/components/insights/glucose/__tests__/glucose-clinical-panel.test.tsx @@ -162,6 +162,11 @@ describe(" asserted state", () => { const de = render(, "de"); expect(de).toContain("(3,9–10,0 mmol/L ist das Ziel)"); expect(de).not.toMatch(/mg\/dl/i); + // Mean, GMI and eA1C read with the German decimal comma. + expect(de).not.toMatch(/>\d+\.\d+\d+,\d<\/span>mmol\/L/, + ); authMock.mockReturnValue({ user: { glucoseUnit: "mg/dL" }, diff --git a/src/components/insights/glucose/glucose-advanced-disclosure.tsx b/src/components/insights/glucose/glucose-advanced-disclosure.tsx index 7fbe90613..e28b2b68d 100644 --- a/src/components/insights/glucose/glucose-advanced-disclosure.tsx +++ b/src/components/insights/glucose/glucose-advanced-disclosure.tsx @@ -4,7 +4,7 @@ import { useId, useState } from "react"; import { ChevronDown } from "lucide-react"; import { InfoPopover } from "@/components/ui/info-popover"; -import { useTranslations } from "@/lib/i18n/context"; +import { useFormatters, useTranslations } from "@/lib/i18n/context"; import { cn } from "@/lib/utils"; import type { GlucoseClinicalMetrics } from "@/lib/analytics/glucose-metrics"; import type { DataSummary } from "@/lib/analytics/trends"; @@ -49,11 +49,12 @@ export function GlucoseAdvancedDisclosure({ fractionDigits = 1, }: GlucoseAdvancedDisclosureProps) { const { t } = useTranslations(); + const number = useFormatters().number; const [open, setOpen] = useState(false); const regionId = useId(); const fmt = (v: number | null) => - v === null ? "—" : v.toFixed(fractionDigits); + v === null ? "—" : number(v, fractionDigits); const contexts = Object.entries(byContext ?? {}).filter( ([, s]) => s && s.count > 0, diff --git a/src/components/insights/glucose/glucose-clinical-panel.tsx b/src/components/insights/glucose/glucose-clinical-panel.tsx index 48e440497..56b0cd653 100644 --- a/src/components/insights/glucose/glucose-clinical-panel.tsx +++ b/src/components/insights/glucose/glucose-clinical-panel.tsx @@ -82,7 +82,7 @@ export function GlucoseClinicalPanel() { const formatGlucoseValue = (mgdl: number): string => { const v = convertGlucose(mgdl, glucoseUnit); - return isMmol ? v.toFixed(1) : String(Math.round(v)); + return fmt.number(v, isMmol ? 1 : 0); }; // Learning state — calm, never asserting TIR / GMI off thin data. @@ -189,7 +189,7 @@ export function GlucoseClinicalPanel() { icon={