mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 05:26:47 +00:00
Tours: resolve the distance unit once where tour facts are built
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user