fix(atlas): share the wish form and tour figures, mark the people reads

- lint:dup: the add-a-wish form state and the tour figures of the hub were
  written twice, once per view; they live in useWishAddForm and
  tourHubFigures now, and both views read them.
- lint:tx: AtlasPeopleService.profile only writes through the region cache
  refreshes of the Atlas reads it calls, each complete on its own, so it is
  marked @txStandalone.
This commit is contained in:
Maurice
2026-11-29 00:53:28 +01:00
parent 6068c34c35
commit e6ba039abc
7 changed files with 83 additions and 53 deletions
@@ -0,0 +1,27 @@
import type { TourActivityStatsResponse, TourActivitySummary } from '@trek/shared';
import type { DistanceUnit } from '../../../types';
import { distanceReading, heightReading } from './tourActivityReading';
import { splitMeasure } from './tourActivityStatsModel';
/**
* What the tours page of the Atlas hub shows above its lists, for the desktop
* and the phone view alike: the headline distance (or the tour count when no
* distance is known), the climbs, the types scaled to the longest, and the
* tours left out of the sums.
*/
export function tourHubFigures(
summary: TourActivitySummary,
data: TourActivityStatsResponse | null,
unit: DistanceUnit
) {
const totals = summary.totals;
const distance = distanceReading(totals, unit);
return {
hero: distance ? splitMeasure(distance.text) : { value: String(totals.count), unit: '' },
ascent: heightReading(totals.ascentM, unit),
descent: heightReading(totals.descentM, unit),
types: summary.types,
maxKm: Math.max(1e-9, ...summary.types.map((x) => x.distanceKm.value ?? 0)),
uncounted: data?.uncounted ?? { unassigned: 0, undated: 0 },
};
}