Tours: resolve the distance unit once where tour facts are built

This commit is contained in:
Maurice
2026-10-15 17:51:19 +02:00
parent 782e613506
commit f690065de8
2 changed files with 3 additions and 2 deletions
+3 -1
View File
@@ -6,10 +6,12 @@ import type { TourMetricField } from './tourParts';
/** A line's measures as label and value: distance, the extras, lowest and highest point, ascent, descent. */
export function tourMetricFacts(
analysis: Pick<RouteGeometryAnalysis, 'distanceKm' | 'minEle' | 'maxEle' | 'gain' | 'loss'> | null,
unit: DistanceUnit | undefined,
unitSetting: DistanceUnit | undefined,
t: (key: string, params?: Record<string, unknown>) => string,
extra: readonly TourMetricField[] = []
): TourMetricField[] {
// The setting is unset until the user picks one; metric is what the app shows then.
const unit = unitSetting ?? 'metric';
const fields: TourMetricField[] = [
{ label: t('tours.detail.distance'), value: analysis ? formatDistance(analysis.distanceKm, unit) : '-' },
...extra,