From 704621d0c2c127eef85c92d02de37100d2e28125 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 16 Oct 2026 21:10:33 +0200 Subject: [PATCH] refactor(tours): move the detail view's measures into their own component --- .../src/components/Tours/TourDetailDialog.tsx | 76 ++++++++++++------- 1 file changed, 50 insertions(+), 26 deletions(-) diff --git a/client/src/components/Tours/TourDetailDialog.tsx b/client/src/components/Tours/TourDetailDialog.tsx index c71f2bd3f..bc0335540 100644 --- a/client/src/components/Tours/TourDetailDialog.tsx +++ b/client/src/components/Tours/TourDetailDialog.tsx @@ -29,7 +29,7 @@ import remarkGfm from 'remark-gfm'; import { translateApiError, useTranslation } from '../../i18n'; import { useSettingsStore } from '../../store/settingsStore'; import { useTripStore } from '../../store/tripStore'; -import type { Assignment, AssignmentsMap, Day, Place, TripFile } from '../../types'; +import type { Assignment, AssignmentsMap, Day, DistanceUnit, Place, TripFile } from '../../types'; import { openFile } from '../../utils/fileDownload'; import { filesForPlace } from '../../utils/placeFiles'; import { analyzeRouteGeometry } from '../../utils/routeGeometry'; @@ -114,6 +114,48 @@ function assignmentForSelectedDay( ); } +/** The tour's measures, its times and its profile. Without heights the distance joins the times in one row. */ +function TourDetailMeasures({ + analysis, + unit, + timeFields, + trackColor, + placeId, +}: { + analysis: NonNullable>; + unit: DistanceUnit; + timeFields: TourMetricField[]; + trackColor: string; + placeId: number; +}) { + return ( +
+ {analysis.minEle == null && analysis.gain == null ? ( + + ) : ( + <> + + {timeFields.length > 0 && } + + )} + {analysis.distanceIndexedProfileSamples.length >= 2 && ( +
+ +
+ )} +
+ ); +} + type Translate = (key: string, params?: Record) => string; /** The parts of the time a tour takes, as fields: walking, breaks, the planned total. */ @@ -590,31 +632,13 @@ export default function TourDetailDialog({ {analysis && ( -
- {analysis.minEle == null && analysis.gain == null ? ( - // Without heights the distance is the only measure: it joins the times in one row. - - ) : ( - <> - - {timeFields.length > 0 && } - - )} - {analysis.distanceIndexedProfileSamples.length >= 2 && ( -
- -
- )} -
+ )} {description && (