From c28604b891beed4f0ab4a86e53d79b44a8d93a16 Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 30 Oct 2026 21:42:44 +0100 Subject: [PATCH] planner: the details refresh reads through a repository, and the form drops what moved out The fresh lookup behind New place details goes through placeDetailsRepo (online-only, like the service identity) instead of api/ directly. The form loses the Translate type and the comment that moved with the head band's pills, which takes it under its line limit and out of the size baseline; the maps service suite's test-size entry follows its shorter count. --- client/scripts/size-baseline.json | 1 - client/src/components/Planner/PlaceFormModal.tsx | 3 --- client/src/components/Planner/usePlaceRefresh.ts | 8 ++++---- client/src/repo/placeDetailsRepo.ts | 16 ++++++++++++++++ server/scripts/test-size-baseline.json | 2 +- 5 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 client/src/repo/placeDetailsRepo.ts diff --git a/client/scripts/size-baseline.json b/client/scripts/size-baseline.json index 056c0e3ee..efa4bd4cb 100644 --- a/client/scripts/size-baseline.json +++ b/client/scripts/size-baseline.json @@ -13,7 +13,6 @@ "src/components/Planner/DayPlanSidebar.test.tsx": 5349, "src/components/Planner/DayPlanSidebar.tsx": 2936, "src/components/Planner/PlaceFormModal.test.tsx": 2836, - "src/components/Planner/PlaceFormModal.tsx": 1002, "src/components/Planner/PlaceInspector.tsx": 1290, "src/components/Studio/TravelElements.tsx": 1559, "src/components/Studio/countryShapes.ts": 2595, diff --git a/client/src/components/Planner/PlaceFormModal.tsx b/client/src/components/Planner/PlaceFormModal.tsx index 61feeadfd..556ca8684 100644 --- a/client/src/components/Planner/PlaceFormModal.tsx +++ b/client/src/components/Planner/PlaceFormModal.tsx @@ -486,9 +486,6 @@ const SIDE_BUTTON = 'grid w-[38px] flex-none place-items-center rounded-[10px] t * for them; this gives them the eyebrow every other field here has. */ const SERVICE_STOP_LABELS = '[&_label]:mb-[5px] [&_label]:block [&_label]:font-geist [&_label]:text-[length:calc(9.5px*var(--fs-scale-caption,1))] [&_label]:font-bold [&_label]:uppercase [&_label]:tracking-[.08em] [&_label]:text-content-faint' -/** A round white button in the head band's pill row, as tall as the pills beside it. */ - -type Translate = (key: string, params?: Record) => string export default function PlaceFormModal(props: PlaceFormModalProps) { const S = usePlaceFormModal(props) diff --git a/client/src/components/Planner/usePlaceRefresh.ts b/client/src/components/Planner/usePlaceRefresh.ts index 92e0da002..37a826028 100644 --- a/client/src/components/Planner/usePlaceRefresh.ts +++ b/client/src/components/Planner/usePlaceRefresh.ts @@ -1,6 +1,6 @@ import type { PlaceClientOrigin } from '@trek/shared'; import { useEffect, useMemo, useState } from 'react'; -import { mapsApi } from '../../api/client'; +import { placeDetailsRepo } from '../../repo/placeDetailsRepo'; import type { Place } from '../../types'; import type { PlaceFormData } from './PlaceFormModal.helpers'; import { resultOrigin } from './placeFieldOrigins'; @@ -34,9 +34,9 @@ export function usePlaceRefresh({ useEffect(() => { if (!detailId || !key) return; let live = true; - mapsApi.details(detailId, language).then( - (answer: { place?: Record | null }) => { - if (live && answer?.place) setFresh({ key, details: answer.place }); + placeDetailsRepo.details(detailId, language).then( + (details) => { + if (live && details) setFresh({ key, details }); }, () => undefined ); diff --git a/client/src/repo/placeDetailsRepo.ts b/client/src/repo/placeDetailsRepo.ts new file mode 100644 index 000000000..76fa532b9 --- /dev/null +++ b/client/src/repo/placeDetailsRepo.ts @@ -0,0 +1,16 @@ +import { mapsApi } from '../api/client'; +import { requireOnline } from './onlineOnly'; + +/** + * A provider's details of a place, looked up fresh (Google, the TREK index or + * OpenStreetMap, by the id the place carries). **Online-only, no Dexie table:** + * the point of asking is the current answer, and a cached one would offer the + * same values again as if they were new. + */ +export const placeDetailsRepo = { + async details(placeId: string, lang: string): Promise | null> { + requireOnline(); + const answer = (await mapsApi.details(placeId, lang)) as { place?: Record | null } | null; + return answer?.place ?? null; + }, +}; diff --git a/server/scripts/test-size-baseline.json b/server/scripts/test-size-baseline.json index a461eb9e1..dd0b2b6fe 100644 --- a/server/scripts/test-size-baseline.json +++ b/server/scripts/test-size-baseline.json @@ -3,7 +3,7 @@ "tests/unit/nest/budget.service.db.test.ts": 2220, "tests/unit/nest/doc-sync/doc-sync.service.test.ts": 2511, "tests/unit/nest/journey-domain.service.test.ts": 3876, - "tests/unit/nest/maps.service.test.ts": 3681, + "tests/unit/nest/maps.service.test.ts": 3680, "tests/unit/nest/places.service.test.ts": 2561, "tests/unit/nest/trips.service.test.ts": 2404 }