feat(places): notes, visits, tours, history, tags and location in the place sheet, saved lists on the trip map

Both the desktop sheet and the phone sheet of All places show the place's
location as a badge, its notes per list, its visits from trips (hidden without
any), linked tours and bookings, its change history and the reader's own tags
with a tag filter. A trip map can show the places of linked lists and add one
to the trip. All places reloads after a list is added or removed.
This commit is contained in:
Maurice
2026-11-29 21:16:38 +01:00
parent 9abd16b907
commit d008331e5f
84 changed files with 3874 additions and 288 deletions
@@ -10,6 +10,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { OnlineOnlyError } from '../../repo/onlineOnly';
import { placesLibraryRepo } from '../../repo/placesLibraryRepo';
import { useSaveToCollectionStore } from '../../store/saveToCollectionStore';
import type { TranslationFn } from '../../types';
import { getApiErrorMessage } from '../../utils/apiError';
@@ -83,6 +84,12 @@ function useLibraryFilters() {
const [categoryId, setCategoryId] = useState<number | 'all'>('all');
const [sort, setSort] = useState<PlacesLibrarySort>('name');
const [status, setStatus] = useState<CollectionStatus | 'all'>('all');
// PLC-21: the reader's own tags, any of which an entry must carry.
const [tagIds, setTagIds] = useState<number[]>([]);
const toggleTag = useCallback(
(id: number) => setTagIds((ids) => (ids.includes(id) ? ids.filter((x) => x !== id) : [...ids, id])),
[]
);
// Typing settles before it asks.
useEffect(() => {
@@ -96,18 +103,20 @@ function useLibraryFilters() {
...(kind !== 'all' ? { kind } : {}),
...(categoryId !== 'all' ? { category_id: categoryId } : {}),
...(status !== 'all' ? { status } : {}),
...(tagIds.length > 0 ? { tag_ids: tagIds } : {}),
sort,
limit: PAGE,
}),
[query, kind, categoryId, status, sort]
[query, kind, categoryId, status, tagIds, sort]
);
const filtered = query !== '' || kind !== 'all' || categoryId !== 'all' || status !== 'all';
const filtered = query !== '' || kind !== 'all' || categoryId !== 'all' || status !== 'all' || tagIds.length > 0;
const resetFilters = useCallback(() => {
setSearch('');
setQuery('');
setKind('all');
setCategoryId('all');
setStatus('all');
setTagIds([]);
}, []);
return {
@@ -123,6 +132,8 @@ function useLibraryFilters() {
setSort,
status,
setStatus,
tagIds,
toggleTag,
filtered,
resetFilters,
},
@@ -283,7 +294,10 @@ function useLibraryCover(detail: PlacesLibraryDetailResponse | null): string | n
* each of its origins keeps.
*/
export function usePlacesLibrary({ active, t }: { active: boolean; t: TranslationFn }) {
const [reloadSeq, setReloadSeq] = useState(0);
const [ownSeq, setReloadSeq] = useState(0);
// A place saved to a list from here or anywhere else adds an origin: read again then too.
const savedVersion = useSaveToCollectionStore((st) => st.version);
const reloadSeq = ownSeq + savedVersion;
const [detailError, setDetailError] = useState<{ error: string | null; offline: boolean } | null>(null);
const pages = useLibraryPages(active, reloadSeq, t);
const onDetailError = useCallback((err: unknown) => setDetailError(failureOf(err, t)), [t]);