mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 09:54:14 +00:00
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:
@@ -7,14 +7,13 @@ import {
|
||||
} from '../../../../components/Atlas/tourActivity/tourActivityParts';
|
||||
import {
|
||||
distanceReading,
|
||||
heightReading,
|
||||
periodLabel,
|
||||
typeIcon,
|
||||
typeLabel,
|
||||
useDistanceUnit,
|
||||
} from '../../../../components/Atlas/tourActivity/tourActivityReading';
|
||||
import { TourActivityStatsDialog } from '../../../../components/Atlas/tourActivity/TourActivityStatsDialog';
|
||||
import { splitMeasure } from '../../../../components/Atlas/tourActivity/tourActivityStatsModel';
|
||||
import { tourHubFigures } from '../../../../components/Atlas/tourActivity/tourHubFigures';
|
||||
import { useTourActivityStats } from '../../../../components/Atlas/tourActivity/useTourActivityStats';
|
||||
import type { AtlasGlobeState } from '../../../../pages/atlas/useAtlasGlobe';
|
||||
import MChip from '../../../components/MChip';
|
||||
@@ -74,13 +73,7 @@ export default function MHubTours({ s }: { s: AtlasGlobeState }): React.ReactEle
|
||||
);
|
||||
}
|
||||
|
||||
const distance = distanceReading(totals, unit);
|
||||
const hero = distance ? splitMeasure(distance.text) : { value: String(totals.count), unit: '' };
|
||||
const ascent = heightReading(totals.ascentM, unit);
|
||||
const descent = heightReading(totals.descentM, unit);
|
||||
const types = summary.types;
|
||||
const maxKm = Math.max(1e-9, ...types.map((x) => x.distanceKm.value ?? 0));
|
||||
const uncounted = stats.data?.uncounted ?? { unassigned: 0, undated: 0 };
|
||||
const { hero, ascent, descent, types, maxKm, uncounted } = tourHubFigures(summary, stats.data, unit);
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { getIntlLanguage } from '@trek/shared';
|
||||
import {
|
||||
CalendarCheck,
|
||||
CalendarClock,
|
||||
@@ -22,7 +21,7 @@ import CountryFlag from '../../../../components/shared/CountryFlag';
|
||||
import { splitWishes, visitedOn, whenLabeller, wishCountry } from '../../../../pages/atlas/atlasHubModel';
|
||||
import type { BucketItem } from '../../../../pages/atlas/atlasModel';
|
||||
import type { AtlasGlobeState } from '../../../../pages/atlas/useAtlasGlobe';
|
||||
import { useGlobePlaceSearch } from '../../../../pages/atlas/useGlobePlaceSearch';
|
||||
import { useWishAddForm } from '../../../../pages/atlas/useWishAddForm';
|
||||
import MIconBtn from '../../../components/MIconBtn';
|
||||
import MProgress from '../../../components/MProgress';
|
||||
import MSheet from '../../../components/MSheet';
|
||||
@@ -189,21 +188,8 @@ function WishRow({ s, item, when }: { s: AtlasGlobeState; item: BucketItem; when
|
||||
|
||||
/** Adding a wish on the phone: where, when and a note, as one sheet with the save at its foot. */
|
||||
function AddWishSheet({ s }: { s: AtlasGlobeState }): React.ReactElement {
|
||||
const b = s.bucketState;
|
||||
const lang = getIntlLanguage(s.language);
|
||||
const [query, setQuery] = React.useState('');
|
||||
const { placeHits, placesLoading } = useGlobePlaceSearch(query, s.placeLang);
|
||||
const picked = !!b.bucketForm.name;
|
||||
const thisYear = new Date().getFullYear();
|
||||
const year = b.bucketPoiYear;
|
||||
const month = b.bucketPoiMonth;
|
||||
const months = Array.from({ length: 12 }, (_, i) => new Date(2000, i).toLocaleString(lang, { month: 'short' }));
|
||||
const takeName = () => {
|
||||
const name = query.trim();
|
||||
if (!name) return;
|
||||
b.setBucketForm({ ...b.bucketForm, name, lat: '', lng: '', address: undefined });
|
||||
setQuery('');
|
||||
};
|
||||
const { b, query, setQuery, placeHits, placesLoading, picked, thisYear, year, month, months, takeName } =
|
||||
useWishAddForm(s);
|
||||
const label = (text: string) => (
|
||||
<div className="px-1 text-caption font-bold uppercase tracking-wide text-m-muted">{text}</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user