diff --git a/client/scripts/feature-pairs.json b/client/scripts/feature-pairs.json
index d5a6c160e..19fe7a7f7 100644
--- a/client/scripts/feature-pairs.json
+++ b/client/scripts/feature-pairs.json
@@ -303,6 +303,18 @@
"desktop": ["src/components/Collections/CollectionLocationSearch.tsx"],
"mobile": ["src/mobile/screens/collections/MCollLocationSearch.tsx"]
},
+ {
+ "feature": "Places: a place of all places",
+ "hooks": ["src/components/Collections/libraryDates.ts"],
+ "desktop": ["src/components/Collections/LibraryPlaceDetail.tsx"],
+ "mobile": ["src/mobile/screens/collections/MLibraryPlaceSheet.tsx"]
+ },
+ {
+ "feature": "Places: all places",
+ "hooks": ["src/components/Collections/usePlacesLibrary.ts"],
+ "desktop": ["src/components/Collections/PlacesLibraryView.tsx"],
+ "mobile": ["src/mobile/screens/collections/MPlacesLibrary.tsx"]
+ },
{
"feature": "Collection sharing",
"hooks": ["src/components/Collections/useCollectionSharing.ts"],
@@ -1132,6 +1144,7 @@
}
],
"mobileOnly": {
+ "src/mobile/screens/collections/MCollFilterKit.tsx": "Markup only: the filter chips, dropdown rows and empty note the phone's lists and all-places screens share; the desktop draws its own filter row (FilterDropdown).",
"src/mobile/screens/trip/sheets/MReviewNotice.tsx": "The transport sheet's row asking for a look at an imported booking; the desktop dialog folds the same \"looks right\" action into its review pill (ReviewPill in bookingParts.tsx), so there is no separate twin.",
"src/mobile/screens/mail/MMailInboxHost.tsx": "Mounts the phone shell's one inbox sheet and reads the person's import settings; the desktop mounts its dialog from the Navbar, so there is no twin.",
"src/mobile/screens/admin/MAdminOidcCard.tsx": "Markup only; the OIDC card of MAdminSettingsSection, with the form state from useAdmin and the save from its useAdminSettingsActions handed in through props.",
diff --git a/client/scripts/rtl-baseline.json b/client/scripts/rtl-baseline.json
index 62b7815b6..c32868824 100644
--- a/client/scripts/rtl-baseline.json
+++ b/client/scripts/rtl-baseline.json
@@ -24,8 +24,8 @@
"components/Map/DawarichTrailPill.tsx": 1,
"components/Map/LocationButton.tsx": 1,
"components/Map/MapTogglePill.tsx": 1,
- "components/Map/MapView.tsx": 5,
- "components/Map/MapViewGL.tsx": 7,
+ "components/Map/MapView.tsx": 4,
+ "components/Map/MapViewGL.tsx": 6,
"components/Map/NightPauseTooltip.tsx": 1,
"components/Map/PlaceHoverCard.tsx": 1,
"components/Map/PoiCategoryPill.tsx": 1,
diff --git a/client/src/App.tsx b/client/src/App.tsx
index d7f64da73..f4f474b23 100644
--- a/client/src/App.tsx
+++ b/client/src/App.tsx
@@ -1,5 +1,6 @@
import React, { useEffect, useLayoutEffect, useState, useRef, ReactNode, Suspense } from 'react'
import { Routes, Route, Navigate, useLocation, useNavigationType } from 'react-router'
+import LegacyCollectionsRedirect from './components/Collections/LegacyCollectionsRedirect'
import { useAuthStore } from './store/authStore'
import { useSettingsStore } from './store/settingsStore'
import { applyAppearance } from './theme/applyAppearance'
@@ -637,22 +638,20 @@ export default function App() {
journey, not navigated away to. */}
} />
-
-
-
- }
- />
-
-
-
- }
- />
+ {['/places', '/places/saved', '/places/:id'].map(path => (
+
+
+
+ }
+ />
+ ))}
+ {/* Collections became Places (PLC-07); the old links keep working. */}
+ } />
+ } />
{
folders: ['Views'],
skipped: [{ name: 'Tram 28', folder: null, reason: 'line' }],
}
- let upload: File | null = null
+ let contentType: string | null = null
server.use(
- http.post(`${BASE}/map/read`, async ({ request }) => {
- upload = (await request.formData()).get('file') as File | null
+ // jsdom cannot read a multipart body back, so the header says what was sent.
+ http.post(`${BASE}/map/read`, ({ request }) => {
+ contentType = request.headers.get('content-type')
return HttpResponse.json(read)
}),
)
const res = await collectionsApi.readMap(new File([''], 'lisbon.kml'))
- expect(upload).not.toBeNull()
- expect((upload as unknown as File).name).toBe('lisbon.kml')
+ expect(contentType).toMatch(/^multipart\/form-data/)
expect(res).toEqual(read)
})
})
diff --git a/client/src/components/Assistant/AssistantAskButton.test.tsx b/client/src/components/Assistant/AssistantAskButton.test.tsx
index b094e2365..862f4deae 100644
--- a/client/src/components/Assistant/AssistantAskButton.test.tsx
+++ b/client/src/components/Assistant/AssistantAskButton.test.tsx
@@ -50,7 +50,7 @@ describe('AssistantAskButton', () => {
expect(screen.queryByRole('button')).not.toBeInTheDocument();
unmount();
- renderAt('/collections/3');
+ renderAt('/places/3');
expect(screen.queryByRole('button')).not.toBeInTheDocument();
});
});
diff --git a/client/src/components/Assistant/cards/collection/CollectionCardBlocks.test.tsx b/client/src/components/Assistant/cards/collection/CollectionCardBlocks.test.tsx
index 0188a6a32..7140a1c40 100644
--- a/client/src/components/Assistant/cards/collection/CollectionCardBlocks.test.tsx
+++ b/client/src/components/Assistant/cards/collection/CollectionCardBlocks.test.tsx
@@ -54,7 +54,7 @@ describe('collection answer cards', () => {
expect(within(card).getByText('Idea')).toBeInTheDocument();
expect(within(card).getByText('3')).toBeInTheDocument();
fireEvent.click(within(card).getByRole('button', { name: /Open list/ }));
- expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/collections/12' });
+ expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/places/12' });
});
it('FE-AI-COLL-040: the places to revisit have a pill of their own in the head, in the visited tone (#2567)', () => {
@@ -86,7 +86,7 @@ describe('collection answer cards', () => {
expect(screen.getByText('Spot 4')).toBeInTheDocument();
expect(screen.queryByText('Spot 5')).toBeNull();
fireEvent.click(screen.getByRole('button', { name: '7 more in this list' }));
- expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/collections/12' });
+ expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/places/12' });
});
it('FE-AI-COLL-013: a roomy chat shows eight rows', () => {
@@ -144,7 +144,7 @@ describe('collection answer cards', () => {
expect(screen.queryByText('Paris food')).toBeNull();
expect(screen.getByText('Invite from Maya')).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: /Rome/ }));
- expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/collections/40' });
+ expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/places/40' });
});
it('FE-AI-COLL-018: where a place is saved reads as its lists with its status in each', () => {
diff --git a/client/src/components/Assistant/cards/collection/CollectionChangeSlots.test.tsx b/client/src/components/Assistant/cards/collection/CollectionChangeSlots.test.tsx
index aa83c4d2b..c42d21630 100644
--- a/client/src/components/Assistant/cards/collection/CollectionChangeSlots.test.tsx
+++ b/client/src/components/Assistant/cards/collection/CollectionChangeSlots.test.tsx
@@ -94,7 +94,7 @@ describe('collection change cards', () => {
const view = draw([applied(pending('save_place_to_collection', 'Septime', card), 'collection_place', [77])]);
expect(screen.queryByRole('button', { name: 'Show on map' })).toBeNull();
fireEvent.click(screen.getByRole('button', { name: 'Open in Collections' }));
- expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/collections/12?place=77' });
+ expect(view.onOpen).toHaveBeenCalledWith({ kind: 'page', path: '/places/12?place=77' });
});
it('FE-AI-COLL-023: a save the place matched already says where it is saved', () => {
diff --git a/client/src/components/Assistant/cards/collection/collectionCardModel.ts b/client/src/components/Assistant/cards/collection/collectionCardModel.ts
index 1f02961da..e0ede3662 100644
--- a/client/src/components/Assistant/cards/collection/collectionCardModel.ts
+++ b/client/src/components/Assistant/cards/collection/collectionCardModel.ts
@@ -8,6 +8,7 @@ import type {
TrekCard,
} from '@trek/shared';
+import { placesPath } from '../../../../utils/placesRoutes';
import type { EntityTarget } from '../cardTypes';
/**
@@ -26,12 +27,12 @@ export const MAX_FACTS = 4;
/** Where a list opens in Collections. */
export function listTarget(listId: number | null): EntityTarget {
- return { kind: 'page', path: listId === null ? '/collections' : `/collections/${listId}` };
+ return { kind: 'page', path: placesPath(listId === null ? 'saved' : listId) };
}
/** Where a saved place opens: its list, with the place selected. */
function placeTarget(listId: number, placeId: number | null): EntityTarget {
- const path = `/collections/${listId}`;
+ const path = placesPath(listId);
return { kind: 'page', path: placeId === null ? path : `${path}?place=${placeId}` };
}
diff --git a/client/src/components/Assistant/cards/collection/collectionLook.test.ts b/client/src/components/Assistant/cards/collection/collectionLook.test.ts
index b0fe99c63..3d2e43260 100644
--- a/client/src/components/Assistant/cards/collection/collectionLook.test.ts
+++ b/client/src/components/Assistant/cards/collection/collectionLook.test.ts
@@ -62,9 +62,9 @@ describe('collection look', () => {
it('FE-AI-COLL-002: an applied list opens in Collections, unless the change deleted it or declined its invite', () => {
const look = ENTITY_LOOK.collection;
expect(look.openLabelKey).toBe('assistant.card.collection.openList');
- expect(look.open?.(applied('collection', [12]), null)).toEqual({ kind: 'page', path: '/collections/12' });
+ expect(look.open?.(applied('collection', [12]), null)).toEqual({ kind: 'page', path: '/places/12' });
const card = listsCard({ lists: [listRow({ id: 13 })] });
- expect(look.open?.(applied('collection', []), card)).toEqual({ kind: 'page', path: '/collections/13' });
+ expect(look.open?.(applied('collection', []), card)).toEqual({ kind: 'page', path: '/places/13' });
for (const change of ['remove', 'decline'] as const) {
expect(look.open?.(applied('collection', [12]), listsCard({ lists: [listRow({ change })] }))).toBeNull();
}
@@ -76,10 +76,10 @@ describe('collection look', () => {
const card = placesCard();
expect(look.open?.(applied('collection_place', [34]), card)).toEqual({
kind: 'page',
- path: '/collections/12?place=34',
+ path: '/places/12?place=34',
});
const removed = placesCard({ places: [savedPlace({ delta: emptyDelta({ removed: true }) })] });
- expect(look.open?.(applied('collection_place', [34]), removed)).toEqual({ kind: 'page', path: '/collections/12' });
+ expect(look.open?.(applied('collection_place', [34]), removed)).toEqual({ kind: 'page', path: '/places/12' });
expect(look.open?.(applied('collection_place', [34]), null)).toBeNull();
});
diff --git a/client/src/components/Collections/AddPlaceToCollectionModal.test.tsx b/client/src/components/Collections/AddPlaceToCollectionModal.test.tsx
index 161521f80..ea2bf3370 100644
--- a/client/src/components/Collections/AddPlaceToCollectionModal.test.tsx
+++ b/client/src/components/Collections/AddPlaceToCollectionModal.test.tsx
@@ -308,13 +308,17 @@ describe('AddPlaceToCollectionModal', () => {
it('FE-COMP-ADDPLACECOL-018: a category can be picked and cleared again', async () => {
setup()
typeName('Manual spot')
- fireEvent.click(screen.getByRole('button', { name: /Food/ }))
- fireEvent.click(screen.getByRole('button', { name: /Museum/ }))
+ // The category is the tile in front of the name; it opens the list to pick from.
+ fireEvent.click(screen.getByRole('button', { name: 'Category: No category' }))
+ fireEvent.click(screen.getByRole('option', { name: 'Food' }))
+ fireEvent.click(screen.getByRole('button', { name: 'Category: Food' }))
+ fireEvent.click(screen.getByRole('option', { name: 'Museum' }))
fireEvent.click(screen.getByRole('button', { name: /Add$/ }))
await waitFor(() => expect(savedBodies).toHaveLength(1))
expect(savedBodies[0]).toMatchObject({ category_id: 4 })
- fireEvent.click(screen.getByRole('button', { name: 'No category' }))
+ fireEvent.click(screen.getByRole('button', { name: /^Category: / }))
+ fireEvent.click(screen.getByRole('option', { name: 'No category' }))
typeName('Second spot')
fireEvent.click(screen.getByRole('button', { name: /Add$/ }))
await waitFor(() => expect(savedBodies).toHaveLength(2))
@@ -323,8 +327,7 @@ describe('AddPlaceToCollectionModal', () => {
it('FE-COMP-ADDPLACECOL-019: without categories the category row is not rendered', () => {
setup({ categories: [] })
- expect(screen.queryByText('Category')).not.toBeInTheDocument()
- expect(screen.queryByRole('button', { name: 'No category' })).not.toBeInTheDocument()
+ expect(screen.queryByRole('button', { name: /^Category: / })).not.toBeInTheDocument()
})
it('FE-COMP-ADDPLACECOL-020: links are normalised and blank rows dropped', async () => {
diff --git a/client/src/components/Collections/AddPlaceToCollectionModal.tsx b/client/src/components/Collections/AddPlaceToCollectionModal.tsx
index 661489cb5..562c5689c 100644
--- a/client/src/components/Collections/AddPlaceToCollectionModal.tsx
+++ b/client/src/components/Collections/AddPlaceToCollectionModal.tsx
@@ -7,13 +7,13 @@ import { DialogButton, DialogFooter, DialogHeader, DialogSection, DialogShell, D
import { AddRowButton, EditorField, INPUT, Segmented, TEXTAREA } from '../shared/dialogParts'
import NoteFormatToolbar from '../shared/NoteFormatToolbar'
import { Tooltip } from '../shared/Tooltip'
-import { getCategoryIcon } from '../shared/categoryIcons'
import { normalizeLinkUrl, STATUS_META, STATUS_ORDER } from '../../pages/collections/collectionsModel'
import type { Category, TranslationFn } from '../../types'
import type { CollectionStatus } from '@trek/shared'
import { str } from './addPlaceModel'
import { useAddPlaceToCollection } from './useAddPlaceToCollection'
import { PlaceFormLocation } from '../Planner/PlaceFormLocation'
+import CategoryTileMenu from './CategoryTileMenu'
/**
* The search row, pinned to the top of the scrolling body. The dialog stays open
@@ -22,10 +22,6 @@ import { PlaceFormLocation } from '../Planner/PlaceFormLocation'
* margins let its background cover the body's padding while it is stuck.
*/
const STICKY_SEARCH = 'sticky top-0 z-20 -mx-6 -mt-5 bg-surface-card px-6 pb-4 pt-5'
-/** A chip of the category row; the picked one wears the category's own colour. */
-const CHIP = 'inline-flex items-center gap-1.5 rounded-full border px-3 py-1 font-semibold'
-const CHIP_OFF = 'border-edge-faint bg-surface-card text-content-muted hover:text-content'
-const CHIP_NONE_ON = 'border-content bg-surface-card text-content'
const ROW_ACTION = 'grid h-8 w-8 flex-none place-items-center rounded-[9px] text-content-faint hover:bg-surface-secondary'
interface AddPlaceToCollectionModalProps {
@@ -65,7 +61,10 @@ export default function AddPlaceToCollectionModal({ isOpen, collectionId, collec
const header = (
}
+ // The category is the tile in front of the name: one tap picks it, no chip row below.
+ tile={categories.length > 0
+ ?
+ : }
tint={NEUTRAL_TINT}
labelId={labelId}
onClose={onClose}
@@ -178,39 +177,6 @@ export default function AddPlaceToCollectionModal({ isOpen, collectionId, collec
/>
- {categories.length > 0 && (
-
-
-
- {categories.map(cat => {
- const Icon = getCategoryIcon(cat.icon ?? undefined)
- const on = categoryId === cat.id
- const col = cat.color || '#6366f1' // theme-lint-disable: the category's own colour, and the default one without a colour is drawn in
- return (
-
- )
- })}
-
-
- )}
-
{t('collections.description')}}
action={}
diff --git a/client/src/components/Collections/CategoryBadge.tsx b/client/src/components/Collections/CategoryBadge.tsx
new file mode 100644
index 000000000..386daca09
--- /dev/null
+++ b/client/src/components/Collections/CategoryBadge.tsx
@@ -0,0 +1,24 @@
+import React from 'react';
+import { getCategoryIcon } from '../shared/categoryIcons';
+import { Tooltip } from '../shared/Tooltip';
+
+/** A place's category as its icon in its colour, in front of the name; the tooltip names it. */
+export default function CategoryBadge({
+ category,
+}: {
+ category: { name?: string | null; color?: string | null; icon?: string | null };
+}): React.ReactElement {
+ const Icon = getCategoryIcon(category.icon ?? undefined);
+ return (
+
+
+
+
+
+ );
+}
diff --git a/client/src/components/Collections/CategoryTileMenu.test.tsx b/client/src/components/Collections/CategoryTileMenu.test.tsx
new file mode 100644
index 000000000..7c7010096
--- /dev/null
+++ b/client/src/components/Collections/CategoryTileMenu.test.tsx
@@ -0,0 +1,102 @@
+// FE-COMP-CATTILEMENU-001 to FE-COMP-CATTILEMENU-007
+import userEvent from '@testing-library/user-event';
+import React from 'react';
+
+import { fireEvent, render, screen, within } from '../../../tests/helpers/render';
+import { useTranslation } from '../../i18n/TranslationContext';
+import type { Category } from '../../types';
+import CategoryTileMenu from './CategoryTileMenu';
+
+const CATEGORIES = [
+ { id: 3, name: 'Restaurant', color: '#E8843D', icon: 'Utensils' },
+ { id: 5, name: 'Museum', color: null, icon: null },
+] as unknown as Category[];
+
+type Props = Omit, 't' | 'categories' | 'onChange'>;
+
+function Harness(props: Props & { onChange: (id: number | null) => void }): React.ReactElement {
+ const { t } = useTranslation();
+ return ;
+}
+
+function setup(props: Partial = {}) {
+ const onChange = vi.fn<(id: number | null) => void>();
+ render();
+ return { onChange };
+}
+
+describe('CategoryTileMenu', () => {
+ it('FE-COMP-CATTILEMENU-001: without a category the tile says so and is closed', () => {
+ setup();
+ const tile = screen.getByRole('button', { name: 'Category: No category' });
+ expect(tile).toHaveAttribute('aria-expanded', 'false');
+ expect(tile).toHaveAttribute('title', 'Category: No category');
+ expect(tile).toHaveStyle({ width: '46px', height: '46px' });
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
+ });
+
+ it('FE-COMP-CATTILEMENU-002: a category names itself on the tile in the size asked for', () => {
+ setup({ value: 3, size: 40 });
+ const tile = screen.getByRole('button', { name: 'Category: Restaurant' });
+ expect(tile).toHaveStyle({ width: '40px', height: '40px' });
+ expect(tile).not.toHaveClass('bg-surface-card');
+ });
+
+ it('FE-COMP-CATTILEMENU-003: a value with no category behind it reads as none', () => {
+ setup({ value: 99 });
+ expect(screen.getByRole('button', { name: 'Category: No category' })).toHaveClass('bg-surface-card');
+ });
+
+ it('FE-COMP-CATTILEMENU-004: the list offers "No category" and every category, the current one selected', async () => {
+ const user = userEvent.setup();
+ setup({ value: 5 });
+ await user.click(screen.getByRole('button', { name: 'Category: Museum' }));
+ const list = screen.getByRole('listbox', { name: 'Category' });
+ const options = within(list).getAllByRole('option');
+ expect(options.map((o) => o.textContent)).toEqual(['No category', 'Restaurant', 'Museum']);
+ expect(options[2]).toHaveAttribute('aria-selected', 'true');
+ expect(options[0]).toHaveAttribute('aria-selected', 'false');
+ });
+
+ it('FE-COMP-CATTILEMENU-005: picking a category or none reports it and closes the list', async () => {
+ const user = userEvent.setup();
+ const { onChange } = setup({ value: 3 });
+ const tile = screen.getByRole('button', { name: 'Category: Restaurant' });
+
+ await user.click(tile);
+ await user.click(screen.getByRole('option', { name: 'Museum' }));
+ expect(onChange).toHaveBeenLastCalledWith(5);
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
+
+ await user.click(tile);
+ await user.click(screen.getByRole('option', { name: 'No category' }));
+ expect(onChange).toHaveBeenLastCalledWith(null);
+ });
+
+ it('FE-COMP-CATTILEMENU-006: Escape closes the list and goes no further, so the dialog around it stays', async () => {
+ const user = userEvent.setup();
+ setup();
+ await user.click(screen.getByRole('button', { name: 'Category: No category' }));
+ const outer = vi.fn();
+ document.body.addEventListener('keydown', outer);
+
+ fireEvent.keyDown(screen.getByRole('listbox'), { key: 'Escape' });
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
+ expect(outer).not.toHaveBeenCalled();
+ document.body.removeEventListener('keydown', outer);
+ });
+
+ it('FE-COMP-CATTILEMENU-007: a press outside closes it, a press inside and other keys do not', async () => {
+ const user = userEvent.setup();
+ setup();
+ const tile = screen.getByRole('button', { name: 'Category: No category' });
+ await user.click(tile);
+ fireEvent.mouseDown(screen.getByRole('listbox'));
+ fireEvent.keyDown(document, { key: 'ArrowDown' });
+ expect(screen.getByRole('listbox')).toBeInTheDocument();
+
+ fireEvent.mouseDown(document.body);
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
+ expect(tile).toHaveAttribute('aria-expanded', 'false');
+ });
+});
diff --git a/client/src/components/Collections/CategoryTileMenu.tsx b/client/src/components/Collections/CategoryTileMenu.tsx
new file mode 100644
index 000000000..3734ed5d1
--- /dev/null
+++ b/client/src/components/Collections/CategoryTileMenu.tsx
@@ -0,0 +1,103 @@
+import { Check, Shapes } from 'lucide-react';
+import React, { useEffect, useRef, useState } from 'react';
+import type { Category, TranslationFn } from '../../types';
+import { getCategoryIcon } from '../shared/categoryIcons';
+
+interface CategoryTileMenuProps {
+ categories: Category[];
+ value: number | null;
+ onChange: (id: number | null) => void;
+ /** The tile's side in pixels: 46 in a dialog's head band, 40 beside the sheet's name field. */
+ size?: number;
+ t: TranslationFn;
+}
+
+/**
+ * The place's category as the tile in front of its name: its icon in its colour,
+ * and a tap opens the list to pick another. It replaces the row of category chips
+ * the forms had, so the category reads as part of the place and the form loses a row.
+ */
+export default function CategoryTileMenu({
+ categories,
+ value,
+ onChange,
+ size = 46,
+ t,
+}: CategoryTileMenuProps): React.ReactElement {
+ const [open, setOpen] = useState(false);
+ const ref = useRef(null);
+ useEffect(() => {
+ if (!open) return;
+ const onDoc = (e: MouseEvent) => {
+ if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false);
+ };
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key === 'Escape') {
+ e.stopPropagation();
+ setOpen(false);
+ }
+ };
+ document.addEventListener('mousedown', onDoc);
+ document.addEventListener('keydown', onKey, true);
+ return () => {
+ document.removeEventListener('mousedown', onDoc);
+ document.removeEventListener('keydown', onKey, true);
+ };
+ }, [open]);
+
+ const current = value != null ? (categories.find((c) => c.id === value) ?? null) : null;
+ const Icon = current ? getCategoryIcon(current.icon ?? undefined) : Shapes;
+ const tone = current?.color || null;
+ const label = `${t('collections.category')}: ${current?.name ?? t('collections.noCategory')}`;
+
+ return (
+
- )
-}
+import FilterDropdown, { type FilterOption as Opt } from './FilterDropdown'
interface CollectionFilterBarProps {
statusFilter: StatusFilter
@@ -146,12 +91,12 @@ export default function CollectionFilterBar({
)}
- onStatusFilter(k as StatusFilter)} lead={} />
+ onStatusFilter(k as StatusFilter)} lead={} />
{categoryOptions.length > 0 && (
- onCategoryFilter(k as number | 'all')} lead={} />
+ onCategoryFilter(k as number | 'all')} lead={} />
)}
- onRatingFilter(k as number | 'all')} lead={} />
- onSortMode(k as CollectionSortMode)} lead={} />
+ onRatingFilter(k as number | 'all')} lead={} />
+ onSortMode(k as CollectionSortMode)} lead={} />
{showSelect && (
)}
- {t('collections.category').toUpperCase()}
- {t('mobileCollections.status').toUpperCase()}
{/* Two by two on a phone, so every status label keeps its room */}
diff --git a/client/src/mobile/screens/collections/MCollCategoryPicker.tsx b/client/src/mobile/screens/collections/MCollCategoryPicker.tsx
index f36c500e1..3804383c0 100644
--- a/client/src/mobile/screens/collections/MCollCategoryPicker.tsx
+++ b/client/src/mobile/screens/collections/MCollCategoryPicker.tsx
@@ -1,4 +1,4 @@
-import { useState } from 'react'
+import { useState, type ReactNode } from 'react'
import { Check, ChevronDown, ChevronUp } from 'lucide-react'
import type { Category, TranslationFn } from '../../../types'
import { categoryMeta, NO_CATEGORY_META, tint } from './collectionsMobileModel'
@@ -7,6 +7,13 @@ interface MCollCategoryPickerProps {
categories: Category[]
value: number | null
onChange: (id: number | null) => void
+ /**
+ * `tile` puts the category in front of the place's name as a tinted tile, with the
+ * name field (the children) beside it: the category belongs to the place, and the
+ * form loses a whole row. `row` is the full-width trigger.
+ */
+ variant?: 'row' | 'tile'
+ children?: ReactNode
t: TranslationFn
}
@@ -14,7 +21,7 @@ interface MCollCategoryPickerProps {
* Category dropdown of the add/edit-place sheets: a trigger row with the tinted
* 26px icon chip and an overlay list of "No category" + the admin categories.
*/
-export default function MCollCategoryPicker({ categories, value, onChange, t }: MCollCategoryPickerProps) {
+export default function MCollCategoryPicker({ categories, value, onChange, variant = 'row', children, t }: MCollCategoryPickerProps) {
const [open, setOpen] = useState(false)
const selected = value != null ? categories.find(c => c.id === value) ?? null : null
@@ -27,8 +34,18 @@ export default function MCollCategoryPicker({ categories, value, onChange, t }:
...categories.map(c => ({ id: c.id, name: c.name })),
]
- return (
-