mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
Tours: resolve the distance unit once where tour facts are built
This commit is contained in:
@@ -89,7 +89,6 @@
|
||||
"src/components/Todo/todoListModel.ts": 1,
|
||||
"src/components/Tours/planner/TourPlannerPanels.tsx": 2,
|
||||
"src/components/Tours/planner/useTourPlanner.ts": 2,
|
||||
"src/components/Tours/tourParts.tsx": 5,
|
||||
"src/components/Trips/TripFormModal.tsx": 3,
|
||||
"src/components/Trips/TripMembersModal.tsx": 1,
|
||||
"src/components/Vacay/VacayCalendar.tsx": 1,
|
||||
|
||||
@@ -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