From bbe3da77228823367f4d94f16680577c950166a6 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 8 Oct 2026 21:02:46 +0000 Subject: [PATCH] refactor(places): share the places pool filters and selection between desktop and phone usePlacesPool holds the category filter, the search, the multi select and the bulk mark visited of the places pool, for usePlacesSidebar and for MPlacesBrowser with its filter controls and sheet. When selected places are deleted, the desktop leaves select mode once none of them is left and the phone drops only the missing ids. The hook keeps both. --- .../Planner/PlacesSidebarHeader.tsx | 24 +- .../components/Planner/usePlacesPool.test.ts | 290 ++++++++++++++++++ .../src/components/Planner/usePlacesPool.ts | 192 ++++++++++++ .../components/Planner/usePlacesSidebar.ts | 87 +----- .../screens/trip/places/MPlacesBrowser.tsx | 85 ++--- .../trip/places/MPlacesFilterControls.tsx | 10 +- .../trip/places/MPlacesFilterSheet.tsx | 8 +- 7 files changed, 519 insertions(+), 177 deletions(-) create mode 100644 client/src/components/Planner/usePlacesPool.test.ts create mode 100644 client/src/components/Planner/usePlacesPool.ts diff --git a/client/src/components/Planner/PlacesSidebarHeader.tsx b/client/src/components/Planner/PlacesSidebarHeader.tsx index 7f3a66542..a3c0c3317 100644 --- a/client/src/components/Planner/PlacesSidebarHeader.tsx +++ b/client/src/components/Planner/PlacesSidebarHeader.tsx @@ -7,7 +7,8 @@ import { useElementSize } from '../../hooks/useElementSize' import { Eyebrow } from './bookings/bookingParts' import { tintOf } from './planParts' import { CategoryTile } from './PlacesBulkCategoryModal' -import type { PlacesFilter, SidebarState } from './usePlacesSidebar' +import type { SidebarState } from './usePlacesSidebar' +import { placesFilterTabs } from './usePlacesPool' import { PLACES_SORTS, type PlacesSort } from './placesSort' import { RATING_FLOORS, UNCATEGORIZED } from '../../utils/placesFilter' @@ -69,7 +70,7 @@ export function PlacesDropOverlay({ t }: SidebarState) { * says so. */ export function PlacesHeader(S: SidebarState) { - const { canEditPlaces, t, selectMode, setSelectMode, setSelectedIds } = S + const { canEditPlaces, t, selectMode, toggleSelectMode } = S return (
{canEditPlaces && } @@ -80,7 +81,7 @@ export function PlacesHeader(S: SidebarState) { label={t('common.select')} on={selectMode} ariaPressed={selectMode} - onClick={() => { setSelectMode(v => !v); setSelectedIds(new Set()) }} + onClick={toggleSelectMode} > {selectMode ? : } @@ -98,14 +99,14 @@ export function PlacesHeader(S: SidebarState) { ) } -function SearchField({ t, search, setSearch, selectMode, setSelectedIds }: SidebarState) { +function SearchField({ t, search, setSearch, updateSearch }: SidebarState) { return (