mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
fix(tours): list a kept tour with its type's marks, pace and stages
The collection copy keeps the winter, run, ski, bike and stage columns, but its list item only carried the older fields, so a kept ski track lost its discipline mark, a snowshoe hike its winter mark, a run its pace and a multi-day tour its stage count. The item now carries them, and a kept tour's card shows the pace and the stages beside its measures.
This commit is contained in:
@@ -6,13 +6,29 @@ import { parseRouteGeometry, thinnedLine } from './tours.helpers';
|
||||
import {
|
||||
COLLECTION_TOUR_PREVIEW_POINTS,
|
||||
walkStationFacts,
|
||||
type BikeProfile,
|
||||
type CollectionTourItem,
|
||||
type CollectionTourPoint,
|
||||
type RunProfile,
|
||||
type SkiDiscipline,
|
||||
type SkiTechnique,
|
||||
type TourOrigin,
|
||||
type TourTypeKey,
|
||||
type WinterActivity,
|
||||
} from '@trek/shared';
|
||||
|
||||
/** LIB-03: a kept tour as the collection lists it, its measures as they were saved, null staying null. */
|
||||
/** MDT-01: a kept multi-day tour's stages, one more than the stops that end one, as the trip's list counts them. */
|
||||
function keptStageCount(row: Pick<CollectionTourRow, 'waypoints'>): number | null {
|
||||
const ends = row.waypoints.filter((point) => point.stage_end === true).length;
|
||||
return ends > 0 ? ends + 1 : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* LIB-03: a kept tour as the collection lists it, its measures as they were
|
||||
* saved, null staying null, with what the trip's list shows of its type (the
|
||||
* winter label, the ski discipline, the run's pace, the bike profile, the
|
||||
* stages), so a kept tour looks as it did in the trip it came from.
|
||||
*/
|
||||
export function keptTourItem(row: CollectionTourRow): CollectionTourItem {
|
||||
return {
|
||||
id: row.id,
|
||||
@@ -28,6 +44,13 @@ export function keptTourItem(row: CollectionTourRow): CollectionTourItem {
|
||||
break_additional_minutes: row.break_additional_minutes,
|
||||
max_hiking_difficulty: row.max_hiking_difficulty,
|
||||
wanderer_ref: row.wanderer_ref,
|
||||
bike_profile: row.bike_profile as BikeProfile | null,
|
||||
winter_activity: row.winter_activity as WinterActivity | null,
|
||||
run_profile: row.run_profile as RunProfile | null,
|
||||
run_pace_seconds_per_km: row.run_pace_seconds_per_km,
|
||||
ski_discipline: row.ski_discipline as SkiDiscipline | null,
|
||||
ski_technique: row.ski_technique as SkiTechnique | null,
|
||||
stage_count: keptStageCount(row),
|
||||
origin: row.origin as TourOrigin,
|
||||
has_line: row.route_geometry !== null,
|
||||
waypoint_count: row.waypoints.length,
|
||||
|
||||
Reference in New Issue
Block a user