mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 15:23:29 +00:00
fix(insights): ask the empty-state Coach question in the reader's language
A metric page without data offers to ask the Coach about the metric. 44 of the 49 pages passed that question as an English literal, so a German, French or Korean reader got an English first message; only 5 read it from the catalog. 31 of the 44 were one sentence with the metric's name swapped in. `HealthKitMetricPage` now asks that sentence once, translated, around the page's own title, and the 31 pages drop the prop. The 13 pages with a question of their own (steps, HRV, sleep, mood, workouts, blood pressure and others) read it from the catalog like the 5 did, in all ten languages.
This commit is contained in:
1 parent
b970ea7468
commit
eec52534d5
57 files changed
+395
-189
No files matched your search
@@ -3,6 +3,7 @@
|
||||
import { Flame } from "lucide-react";
|
||||
|
||||
import { HealthKitMetricPage } from "@/components/insights/healthkit-metric-page";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
|
||||
/**
|
||||
* v1.4.32 — `/insights/active-energy`.
|
||||
@@ -14,6 +15,7 @@ import { HealthKitMetricPage } from "@/components/insights/healthkit-metric-page
|
||||
* imports collapse cleanly via the v1.4.30 drain script.
|
||||
*/
|
||||
export default function InsightsActiveEnergyPage() {
|
||||
const { t } = useTranslations();
|
||||
return (
|
||||
<HealthKitMetricPage
|
||||
measurementType="ACTIVE_ENERGY_BURNED"
|
||||
@@ -27,7 +29,7 @@ export default function InsightsActiveEnergyPage() {
|
||||
yAxisUnit="kcal"
|
||||
emptyStateIcon={<Flame className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any active energy yet. What's a reasonable daily target, and how does it compare to total calories?"
|
||||
coachPrefill={t("insights.activeEnergy.coachPrefill")}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,6 @@ export default function InsightsLaermereignissePage() {
|
||||
yAxisUnit=""
|
||||
emptyStateIcon={<Volume2 className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any loud-environment events yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -60,7 +60,6 @@ export default function InsightsBlutzuckerPage() {
|
||||
captureType="BLOOD_GLUCOSE"
|
||||
targetSummarySlug="blood-glucose"
|
||||
afterChart={<GlucoseClinicalPanel />}
|
||||
coachPrefill="I haven't logged any blood glucose yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ export default function InsightsBlutdruckPage() {
|
||||
</Link>
|
||||
</Button>
|
||||
}
|
||||
coachPrefill="I haven't recorded any blood pressure yet. Why does it matter, and what should I know before I start?"
|
||||
coachPrefill={t("insights.emptyState.bloodPressure.coachPrefill")}
|
||||
/>
|
||||
</SubPageShell>
|
||||
);
|
||||
|
||||
@@ -90,7 +90,7 @@ export default function InsightsBmiPage() {
|
||||
</Link>
|
||||
</Button>
|
||||
}
|
||||
coachPrefill="I haven't recorded any weight yet. Why does BMI matter for me, and what should I know before I start tracking it?"
|
||||
coachPrefill={t("insights.emptyState.bmi.coachPrefill")}
|
||||
/>
|
||||
</SubPageShell>
|
||||
);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { Thermometer } from "lucide-react";
|
||||
|
||||
import { HealthKitMetricPage } from "@/components/insights/healthkit-metric-page";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
|
||||
/**
|
||||
* v1.4.32 — `/insights/body-temperature`.
|
||||
@@ -13,6 +14,7 @@ import { HealthKitMetricPage } from "@/components/insights/healthkit-metric-page
|
||||
* them on separate enum values per the v1.4.30 categorisation overlay.
|
||||
*/
|
||||
export default function InsightsBodyTemperaturePage() {
|
||||
const { t } = useTranslations();
|
||||
return (
|
||||
<HealthKitMetricPage
|
||||
measurementType="BODY_TEMPERATURE"
|
||||
@@ -24,7 +26,7 @@ export default function InsightsBodyTemperaturePage() {
|
||||
color="var(--chart-3)"
|
||||
emptyStateIcon={<Thermometer className="size-6" />}
|
||||
emptyStateCtaType="BODY_TEMPERATURE"
|
||||
coachPrefill="I haven't logged any body temperature yet. What's the healthy range, and what should I do if it drifts?"
|
||||
coachPrefill={t("insights.bodyTemperature.coachPrefill")}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -25,7 +25,6 @@ export default function InsightsKoerperwasserPage() {
|
||||
emptyStateIcon={<Droplet className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
captureType="TOTAL_BODY_WATER"
|
||||
coachPrefill="I haven't logged any total body water yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -25,7 +25,6 @@ export default function InsightsKnochenmassePage() {
|
||||
emptyStateIcon={<Bone className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
captureType="BONE_MASS"
|
||||
coachPrefill="I haven't logged any bone mass yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -24,7 +24,6 @@ export default function InsightsBreathingDisturbancesPage() {
|
||||
unitKey="insights.units.breathingEvents"
|
||||
emptyStateIcon={<Wind className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any sleep-breathing-disturbance data yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -27,7 +27,6 @@ export default function InsightsCardioFitnessPage() {
|
||||
statIcon={Gauge}
|
||||
emptyStateIcon={<Gauge className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any cardio-fitness (VO₂ max) data yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,6 @@ export default function InsightsCardioRecoveryPage() {
|
||||
yAxisUnit="bpm"
|
||||
emptyStateIcon={<HeartPulse className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any cardio-recovery data yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,6 @@ export default function InsightsTageslichtPage() {
|
||||
yAxisUnit="min"
|
||||
emptyStateIcon={<Sun className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any time spent in daylight yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,6 @@ export default function InsightsDoppelstandphasePage() {
|
||||
yAxisUnit="%"
|
||||
emptyStateIcon={<Footprints className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any double support time yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,6 @@ export default function InsightsLaermbelastungPage() {
|
||||
yAxisUnit="dBA"
|
||||
emptyStateIcon={<Volume2 className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any environmental sound exposure yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
import { PersonStanding } from "lucide-react";
|
||||
|
||||
import { HealthKitMetricPage } from "@/components/insights/healthkit-metric-page";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
|
||||
/**
|
||||
* v1.10.0 — `/insights/falls`.
|
||||
@@ -11,6 +12,7 @@ import { HealthKitMetricPage } from "@/components/insights/healthkit-metric-page
|
||||
* better. The series arrives from Apple Health sync — no manual-entry CTA.
|
||||
*/
|
||||
export default function InsightsFallsPage() {
|
||||
const { t } = useTranslations();
|
||||
return (
|
||||
<HealthKitMetricPage
|
||||
measurementType="FALL_COUNT"
|
||||
@@ -23,7 +25,7 @@ export default function InsightsFallsPage() {
|
||||
unitKey="insights.units.falls"
|
||||
emptyStateIcon={<PersonStanding className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any fall data yet. What does this metric tell me about my health, and how do I lower my fall risk?"
|
||||
coachPrefill={t("insights.falls.coachPrefill")}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -24,7 +24,6 @@ export default function InsightsFettfreieMassePage() {
|
||||
color="var(--chart-1)"
|
||||
emptyStateIcon={<Scale className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any fat-free mass yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -24,7 +24,6 @@ export default function InsightsFettmassePage() {
|
||||
color="var(--chart-5)"
|
||||
emptyStateIcon={<Droplets className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any fat mass yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -25,7 +25,6 @@ export default function InsightsStockwerkePage() {
|
||||
unitKey="insights.units.flights"
|
||||
emptyStateIcon={<TrendingUp className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any flights climbed yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,6 @@ export default function InsightsKopfhoererpegelPage() {
|
||||
yAxisUnit="dBA"
|
||||
emptyStateIcon={<Headphones className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any headphone audio exposure yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
import { Activity } from "lucide-react";
|
||||
|
||||
import { HealthKitMetricPage } from "@/components/insights/healthkit-metric-page";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { EcgCrossLink } from "@/components/insights/ecg-cross-link";
|
||||
|
||||
/**
|
||||
@@ -20,6 +21,7 @@ import { EcgCrossLink } from "@/components/insights/ecg-cross-link";
|
||||
* own, labelled, because the two are not one measure.
|
||||
*/
|
||||
export default function InsightsHrvPage() {
|
||||
const { t } = useTranslations();
|
||||
return (
|
||||
<HealthKitMetricPage
|
||||
measurementType="HEART_RATE_VARIABILITY"
|
||||
@@ -37,7 +39,7 @@ export default function InsightsHrvPage() {
|
||||
yAxisUnit="ms"
|
||||
emptyStateIcon={<Activity className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any HRV data yet. What does heart-rate variability tell me, and how do I capture it?"
|
||||
coachPrefill={t("insights.hrv.coachPrefill")}
|
||||
// S10 / H1 — device-attributed pointer into the ECG viewer, in the
|
||||
// HRV / heart context. Self-gates to nothing without recordings.
|
||||
afterAssessment={<EcgCrossLink />}
|
||||
|
||||
@@ -24,7 +24,6 @@ export default function InsightsMagermassePage() {
|
||||
color="var(--chart-1)"
|
||||
emptyStateIcon={<Scale className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any lean body mass yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -132,7 +132,7 @@ export default function InsightsMoodPageClient() {
|
||||
<Link href="/mood">{t("insights.emptyState.mood.cta")}</Link>
|
||||
</Button>
|
||||
}
|
||||
coachPrefill="I haven't logged any mood entries yet. Why does mood tracking matter, and how should I start?"
|
||||
coachPrefill={t("insights.emptyState.mood.coachPrefill")}
|
||||
/>
|
||||
</SubPageShell>
|
||||
);
|
||||
|
||||
@@ -24,7 +24,6 @@ export default function InsightsMuskelmassePage() {
|
||||
color="var(--chart-1)"
|
||||
emptyStateIcon={<Dumbbell className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any muscle mass yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import { describe, expect, it, vi } from "vitest";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { queryKeys } from "@/lib/query-keys";
|
||||
import type { ValueBand } from "@/lib/analytics/value-bands";
|
||||
|
||||
@@ -37,7 +38,9 @@ function bandsRendered(thresholds: unknown): ValueBand[] {
|
||||
}
|
||||
const html = renderToStaticMarkup(
|
||||
<QueryClientProvider client={client}>
|
||||
<InsightsOxygenSaturationPage />
|
||||
<I18nProvider initialLocale="en">
|
||||
<InsightsOxygenSaturationPage />
|
||||
</I18nProvider>
|
||||
</QueryClientProvider>,
|
||||
);
|
||||
const match = /<pre[^>]*>([^<]*)<\/pre>/.exec(html);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { Wind } from "lucide-react";
|
||||
|
||||
import { HealthKitMetricPage } from "@/components/insights/healthkit-metric-page";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { buildOxygenSaturationBands } from "@/lib/analytics/value-bands";
|
||||
import { useOwnTargetRange } from "@/lib/queries/use-own-target-range";
|
||||
|
||||
@@ -20,6 +21,7 @@ import { useOwnTargetRange } from "@/lib/queries/use-own-target-range";
|
||||
* `/targets`, and the clinical bands otherwise.
|
||||
*/
|
||||
export default function InsightsOxygenSaturationPage() {
|
||||
const { t } = useTranslations();
|
||||
const ownRange = useOwnTargetRange("OXYGEN_SATURATION");
|
||||
return (
|
||||
<HealthKitMetricPage
|
||||
@@ -38,7 +40,7 @@ export default function InsightsOxygenSaturationPage() {
|
||||
emptyStateIcon={<Wind className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
captureType="OXYGEN_SATURATION"
|
||||
coachPrefill="I haven't logged any oxygen-saturation data yet. What does SpO₂ tell me, and what range should I aim for?"
|
||||
coachPrefill={t("insights.oxygenSaturation.coachPrefill")}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,6 @@ export default function InsightsPulswellengeschwindigkeitPage() {
|
||||
yAxisUnit="m/s"
|
||||
emptyStateIcon={<Activity className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any pulse wave velocity yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -115,7 +115,7 @@ export default function InsightsPulsPage() {
|
||||
</Link>
|
||||
</Button>
|
||||
}
|
||||
coachPrefill="I haven't recorded any resting pulse yet. Why does it matter, and what should I know before I start?"
|
||||
coachPrefill={t("insights.emptyState.pulse.coachPrefill")}
|
||||
/>
|
||||
</SubPageShell>
|
||||
);
|
||||
|
||||
@@ -25,7 +25,6 @@ export default function InsightsAtemfrequenzPage() {
|
||||
unitKey="insights.units.respiratoryRate"
|
||||
emptyStateIcon={<Wind className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any respiratory rate yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -25,7 +25,6 @@ export default function InsightsSixMinuteWalkPage() {
|
||||
yAxisUnit="m"
|
||||
emptyStateIcon={<Footprints className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any six-minute-walk data yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -32,7 +32,6 @@ export default function InsightsHauttemperaturPage() {
|
||||
color="var(--chart-5)"
|
||||
emptyStateIcon={<Thermometer className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any skin temperature yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
afterChart={
|
||||
<ConnectedDeviceScoreTile
|
||||
type="BODY_TEMPERATURE_DEVIATION"
|
||||
|
||||
@@ -70,7 +70,7 @@ export default function InsightsSchlafPage() {
|
||||
</Link>
|
||||
</Button>
|
||||
}
|
||||
coachPrefill="I don't have any sleep data yet. Why does sleep tracking matter, and what should I know before I connect a source?"
|
||||
coachPrefill={t("insights.emptyState.sleep.coachPrefill")}
|
||||
/>
|
||||
</SubPageShell>
|
||||
);
|
||||
|
||||
@@ -25,7 +25,6 @@ export default function InsightsStairAscentSpeedPage() {
|
||||
yAxisUnit="m/s"
|
||||
emptyStateIcon={<Gauge className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any stair-ascent-speed data yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -25,7 +25,6 @@ export default function InsightsStairDescentSpeedPage() {
|
||||
yAxisUnit="m/s"
|
||||
emptyStateIcon={<Gauge className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any stair-descent-speed data yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,6 @@ export default function InsightsSchrittlaengePage() {
|
||||
yAxisUnit="m"
|
||||
emptyStateIcon={<Footprints className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any walking step length yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ export default function InsightsStepsPage() {
|
||||
emptyStateIcon={<Footprints className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
captureType="ACTIVITY_STEPS"
|
||||
coachPrefill="I haven't logged any steps yet. What's a reasonable daily step target, and how does walking more help my health?"
|
||||
coachPrefill={t("insights.steps.coachPrefill")}
|
||||
afterChart={
|
||||
calendarVisible ? (
|
||||
<CrossLinkCard
|
||||
|
||||
@@ -25,7 +25,6 @@ export default function InsightsGefaessalterPage() {
|
||||
unitKey="insights.units.years"
|
||||
emptyStateIcon={<HeartPulse className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any vascular age yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,6 @@ export default function InsightsViszeralfettPage() {
|
||||
yAxisUnit=""
|
||||
emptyStateIcon={<Droplets className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any visceral fat yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,6 @@ export default function InsightsGangasymmetriePage() {
|
||||
yAxisUnit="%"
|
||||
emptyStateIcon={<Footprints className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any walking asymmetry yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -24,7 +24,6 @@ export default function InsightsGehstreckePage() {
|
||||
color="var(--chart-2)"
|
||||
emptyStateIcon={<Footprints className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any walking and running distance yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,6 @@ export default function InsightsGehpulsPage() {
|
||||
yAxisUnit="bpm"
|
||||
emptyStateIcon={<HeartPulse className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any walking heart rate average yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -24,7 +24,6 @@ export default function InsightsGehgeschwindigkeitPage() {
|
||||
color="var(--chart-2)"
|
||||
emptyStateIcon={<Gauge className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any walking speed yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -26,7 +26,6 @@ export default function InsightsGangstabilitaetPage() {
|
||||
yAxisUnit="%"
|
||||
emptyStateIcon={<Gauge className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any walking steadiness yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ export default function InsightsGewichtPage() {
|
||||
</Link>
|
||||
</Button>
|
||||
}
|
||||
coachPrefill="I haven't recorded any weight yet. Why does it matter, and what should I know before I start tracking?"
|
||||
coachPrefill={t("insights.emptyState.weight.coachPrefill")}
|
||||
/>
|
||||
</SubPageShell>
|
||||
);
|
||||
|
||||
@@ -142,7 +142,7 @@ export default function InsightsWorkoutsPageClient() {
|
||||
</Button>
|
||||
) : null
|
||||
}
|
||||
coachPrefill="I haven't logged any workouts yet. Why does tracking them matter, and what should I focus on first?"
|
||||
coachPrefill={t("insights.workouts.emptyState.coachPrefill")}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
|
||||
@@ -24,7 +24,6 @@ export default function InsightsWristTemperaturePage() {
|
||||
color="var(--chart-5)"
|
||||
emptyStateIcon={<Thermometer className="size-6" />}
|
||||
emptyStateCtaType={null}
|
||||
coachPrefill="I haven't logged any wrist-temperature data yet. What does this metric tell me about my health, and how do I improve it?"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
|
||||
import { I18nProvider } from "@/lib/i18n/context";
|
||||
import { primeMessages } from "@/lib/i18n/load-locale";
|
||||
import deMessages from "../../../../messages/de.json";
|
||||
|
||||
primeMessages("de", deMessages);
|
||||
|
||||
/**
|
||||
* A metric page with no data offers the Coach a question in the reader's
|
||||
* language. The pages used to pass their own English sentence, and most of
|
||||
* them were one sentence with the metric's name swapped in; the page now asks
|
||||
* that one, translated, with its own title, and a metric with a question of
|
||||
* its own reads it from the catalog too.
|
||||
*/
|
||||
|
||||
const prefills: Array<string | null | undefined> = [];
|
||||
vi.mock("@/components/insights/metric-empty-state", () => ({
|
||||
MetricEmptyState: ({ coachPrefill }: { coachPrefill?: string | null }) => {
|
||||
prefills.push(coachPrefill);
|
||||
return null;
|
||||
},
|
||||
}));
|
||||
vi.mock("@/hooks/use-ai-capability", () => ({
|
||||
useAiCapability: () => ({ available: true, reason: null }),
|
||||
}));
|
||||
vi.mock("next/dynamic", () => ({ default: () => () => null }));
|
||||
vi.mock("next/navigation", () => ({
|
||||
usePathname: () => "/insights/visceral-fat",
|
||||
}));
|
||||
vi.mock("@/hooks/use-auth", () => ({
|
||||
useAuth: () => ({
|
||||
user: { timezone: "UTC", dateOfBirth: null, gender: null },
|
||||
isAuthenticated: true,
|
||||
}),
|
||||
}));
|
||||
vi.mock("@/hooks/use-insights-layout-prefs", () => ({
|
||||
useInsightsLayoutPrefs: () => ({ layout: null, compareBaseline: false }),
|
||||
}));
|
||||
vi.mock("@/hooks/use-insights-analytics", () => ({
|
||||
useInsightsAnalytics: () => ({ data: { summaries: {} }, isEmpty: true }),
|
||||
}));
|
||||
|
||||
import InsightsViszeralfettPage from "@/app/insights/visceral-fat/page";
|
||||
import InsightsStepsPage from "@/app/insights/steps/page";
|
||||
|
||||
function emptyStatePrefill(node: React.ReactNode, locale: "en" | "de") {
|
||||
prefills.length = 0;
|
||||
renderToStaticMarkup(
|
||||
<QueryClientProvider client={new QueryClient()}>
|
||||
<I18nProvider initialLocale={locale}>{node}</I18nProvider>
|
||||
</QueryClientProvider>,
|
||||
);
|
||||
return prefills.at(-1);
|
||||
}
|
||||
|
||||
describe("the empty metric page's Coach question", () => {
|
||||
it("is the shared sentence with the page's title, in the reader's language", () => {
|
||||
expect(emptyStatePrefill(<InsightsViszeralfettPage />, "de")).toBe(
|
||||
"Viszeralfett: Ich habe hier noch nichts erfasst. Was sagt dieser Wert über meine Gesundheit aus, und wie verbessere ich ihn?",
|
||||
);
|
||||
expect(emptyStatePrefill(<InsightsViszeralfettPage />, "en")).toBe(
|
||||
"Visceral Fat: I haven't logged anything here yet. What does this metric tell me about my health, and how do I improve it?",
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps a metric's own question, translated", () => {
|
||||
expect(emptyStatePrefill(<InsightsStepsPage />, "de")).toBe(
|
||||
"Ich habe noch keine Schritte erfasst. Was ist ein sinnvolles tägliches Schrittziel, und wie hilft mehr Gehen meiner Gesundheit?",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -148,9 +148,8 @@ export interface HealthKitMetricPageProps {
|
||||
*/
|
||||
statIcon?: ComponentType<{ className?: string }>;
|
||||
/**
|
||||
* Optional Coach prefill for the empty-state launch. Falls back to a
|
||||
* generic onboarding prompt threaded through `<CoachLaunchButton>`'s
|
||||
* default.
|
||||
* The empty state's Coach question, for a metric that asks its own. Without
|
||||
* it the page asks the shared, translated one with its own title.
|
||||
*/
|
||||
coachPrefill?: string;
|
||||
/**
|
||||
@@ -223,6 +222,17 @@ export interface HealthKitMetricPageProps {
|
||||
afterAssessment?: ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* The empty state's Coach question for a metric that asks none of its own:
|
||||
* one translated sentence around the page's title.
|
||||
*/
|
||||
function sharedCoachPrefill(
|
||||
t: ReturnType<typeof useTranslations>["t"],
|
||||
metric: string,
|
||||
): string {
|
||||
return t("insights.subPage.emptyCoachPrefill", { metric });
|
||||
}
|
||||
|
||||
export function HealthKitMetricPage({
|
||||
measurementType,
|
||||
fallbackMeasurementType,
|
||||
@@ -424,7 +434,7 @@ export function HealthKitMetricPage({
|
||||
title={t(`${i18nPrefix}.emptyState.title`)}
|
||||
description={t(`${i18nPrefix}.emptyState.description`)}
|
||||
cta={ctaNode}
|
||||
coachPrefill={coachPrefill ?? null}
|
||||
coachPrefill={coachPrefill ?? sharedCoachPrefill(t, title)}
|
||||
/>
|
||||
</SubPageShell>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user