From d758f4c592cbccbfe211ab7b2ff278229ffd5239 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sun, 29 Nov 2026 23:36:43 +0000 Subject: [PATCH] feat(places): one place view for All places and the lists The desktop dialog and the phone sheet of a place show its overview, notes, tours and bookings, photos and files and its history in tabs, with the tags of each list and trip, a markdown notes editor, uploads and the place picture. The rating bar of All places is the rating row the lists show, with its voters, and votes once for every copy. All places filters by a lowest rating and sorts by it, and the edit form changes the first copy the reader may edit, which the server carries to the others. --- client/scripts/feature-pairs.json | 40 +- client/scripts/format-baseline.json | 2 - client/scripts/rtl-disable-baseline.json | 1 - client/scripts/size-baseline.json | 2 +- client/scripts/theme-baseline.json | 1 - client/scripts/theme-disable-baseline.json | 1 - client/src/api/placeTags.ts | 32 - client/src/api/placesLibrary.ts | 30 +- .../components/Collections/CollectionHero.tsx | 6 +- .../components/Collections/CollectionList.tsx | 5 +- .../Collections/CollectionPlaceDetail.tsx | 776 ++++++++++------ .../Collections/CollectionPlaceTags.tsx | 148 --- .../components/Collections/CopyCarryPanel.tsx | 192 ++-- .../Collections/CopyToTripModal.tsx | 10 +- .../components/Collections/EntryTagDots.tsx | 13 +- .../Collections/EntryTagsSection.tsx | 202 ---- .../Collections/LibraryFilterBar.tsx | 40 +- .../Collections/LibraryPlaceDetail.tsx | 420 +++------ .../Collections/OriginNotesSection.tsx | 240 +++-- .../Collections/PlaceActivitiesSection.tsx | 69 +- .../src/components/Collections/PlaceCard.tsx | 41 + .../components/Collections/PlaceEditForm.tsx | 91 ++ .../Collections/PlaceHistorySection.tsx | 77 +- .../Collections/PlaceLocationBadge.tsx | 6 +- .../Collections/PlaceMediaSection.tsx | 140 ++- .../components/Collections/PlaceOrigins.tsx | 177 ++++ .../components/Collections/PlaceRatingRow.tsx | 22 + .../components/Collections/PlaceSheetTabs.tsx | 80 ++ .../components/Collections/PlaceTagsCard.tsx | 169 ++++ .../Collections/PlacesLibraryView.tsx | 36 +- .../Collections/TagFilterDropdown.tsx | 21 +- .../components/Collections/TripListsPill.tsx | 2 +- .../components/Collections/VisitsSection.tsx | 43 +- .../src/components/Collections/detailDock.ts | 27 - .../components/Collections/libraryPairs.ts | 7 +- .../src/components/Collections/mediaAdd.tsx | 39 + .../components/Collections/placeExtrasText.ts | 7 +- .../src/components/Collections/placeSheet.css | 874 ++++++++++++++++++ .../src/components/Collections/ratingLabel.ts | 7 + .../components/Collections/useEntryTags.ts | 112 --- .../components/Collections/useLibraryPlace.ts | 40 + .../components/Collections/useOriginNotes.ts | 56 +- .../components/Collections/usePlaceEdit.ts | 138 +++ .../components/Collections/usePlaceMedia.ts | 107 ++- .../components/Collections/usePlaceRating.ts | 60 ++ .../components/Collections/usePlaceSheet.ts | 88 ++ .../components/Collections/usePlaceTags.ts | 139 +++ .../Collections/usePlacesLibrary.ts | 77 +- .../Collections/useTripCopyPicker.ts | 45 +- .../src/components/Planner/PlaceInspector.tsx | 100 +- .../Planner/PlaceLinkedBookingCard.tsx | 152 +++ client/src/components/shared/StarRating.tsx | 5 + .../screens/collections/MCollPlaceRow.tsx | 10 +- .../screens/collections/MCollPlaceSheet.tsx | 666 +++++++------ .../collections/MCollTripPickerSheet.tsx | 4 +- .../screens/collections/MCollections.tsx | 1 + .../screens/collections/MEntryTagsSection.tsx | 159 ---- .../collections/MLibraryPlaceSheet.tsx | 439 +++------ .../collections/MOriginNotesSection.tsx | 245 +++-- .../collections/MPlaceActivitiesSection.tsx | 184 ++-- .../mobile/screens/collections/MPlaceCard.tsx | 47 + .../screens/collections/MPlaceEditForm.tsx | 69 ++ .../collections/MPlaceHistorySection.tsx | 128 ++- .../collections/MPlaceMediaSection.tsx | 196 ++-- .../screens/collections/MPlaceOrigins.tsx | 183 ++++ .../screens/collections/MPlaceSheetShell.tsx | 98 ++ .../screens/collections/MPlaceSheetTabs.tsx | 88 ++ .../screens/collections/MPlaceTagsCard.tsx | 143 +++ .../screens/collections/MPlacesLibrary.tsx | 83 +- .../screens/collections/MVisitsSection.tsx | 94 +- .../screens/collections/libraryCover.css | 33 + client/src/pages/CollectionsPage.tsx | 8 +- .../src/pages/collections/useCollections.ts | 11 +- client/src/repo/placeTagsRepo.ts | 49 - client/src/repo/placesLibraryRepo.ts | 115 +++ client/src/store/collectionStore.ts | 8 +- client/src/store/placeTagsStore.ts | 90 -- client/src/styles/collections.css | 35 +- 78 files changed, 5604 insertions(+), 2797 deletions(-) delete mode 100644 client/src/api/placeTags.ts delete mode 100644 client/src/components/Collections/CollectionPlaceTags.tsx delete mode 100644 client/src/components/Collections/EntryTagsSection.tsx create mode 100644 client/src/components/Collections/PlaceCard.tsx create mode 100644 client/src/components/Collections/PlaceEditForm.tsx create mode 100644 client/src/components/Collections/PlaceOrigins.tsx create mode 100644 client/src/components/Collections/PlaceRatingRow.tsx create mode 100644 client/src/components/Collections/PlaceSheetTabs.tsx create mode 100644 client/src/components/Collections/PlaceTagsCard.tsx delete mode 100644 client/src/components/Collections/detailDock.ts create mode 100644 client/src/components/Collections/mediaAdd.tsx create mode 100644 client/src/components/Collections/placeSheet.css create mode 100644 client/src/components/Collections/ratingLabel.ts delete mode 100644 client/src/components/Collections/useEntryTags.ts create mode 100644 client/src/components/Collections/useLibraryPlace.ts create mode 100644 client/src/components/Collections/usePlaceEdit.ts create mode 100644 client/src/components/Collections/usePlaceRating.ts create mode 100644 client/src/components/Collections/usePlaceSheet.ts create mode 100644 client/src/components/Collections/usePlaceTags.ts create mode 100644 client/src/components/Planner/PlaceLinkedBookingCard.tsx delete mode 100644 client/src/mobile/screens/collections/MEntryTagsSection.tsx create mode 100644 client/src/mobile/screens/collections/MPlaceCard.tsx create mode 100644 client/src/mobile/screens/collections/MPlaceEditForm.tsx create mode 100644 client/src/mobile/screens/collections/MPlaceOrigins.tsx create mode 100644 client/src/mobile/screens/collections/MPlaceSheetShell.tsx create mode 100644 client/src/mobile/screens/collections/MPlaceSheetTabs.tsx create mode 100644 client/src/mobile/screens/collections/MPlaceTagsCard.tsx delete mode 100644 client/src/repo/placeTagsRepo.ts delete mode 100644 client/src/store/placeTagsStore.ts diff --git a/client/scripts/feature-pairs.json b/client/scripts/feature-pairs.json index 7861ccf9c..ec375a812 100644 --- a/client/scripts/feature-pairs.json +++ b/client/scripts/feature-pairs.json @@ -287,7 +287,13 @@ }, { "feature": "Collection place detail", - "hooks": ["src/components/Collections/useCollectionPlaceForm.ts"], + "hooks": [ + "src/components/Collections/useCollectionPlaceForm.ts", + "src/components/Collections/useLibraryPlace.ts", + "src/components/Collections/usePlaceSheet.ts", + "src/components/Collections/usePlaceTags.ts", + "src/components/Collections/libraryPairs.ts" + ], "desktop": ["src/components/Collections/CollectionPlaceDetail.tsx"], "mobile": ["src/mobile/screens/collections/MCollPlaceSheet.tsx"] }, @@ -305,10 +311,28 @@ }, { "feature": "Places: a place of all places", - "hooks": ["src/components/Collections/libraryDates.ts", "src/components/Collections/libraryPairs.ts"], + "hooks": [ + "src/components/Collections/libraryPairs.ts", + "src/components/Collections/usePlaceSheet.ts", + "src/components/Collections/usePlaceTags.ts", + "src/components/Collections/usePlaceEdit.ts", + "src/components/Collections/usePlaceRating.ts" + ], "desktop": ["src/components/Collections/LibraryPlaceDetail.tsx"], "mobile": ["src/mobile/screens/collections/MLibraryPlaceSheet.tsx"] }, + { + "feature": "Places: where a place is kept", + "hooks": ["src/components/Collections/libraryDates.ts"], + "desktop": ["src/components/Collections/PlaceOrigins.tsx"], + "mobile": ["src/mobile/screens/collections/MPlaceOrigins.tsx"] + }, + { + "feature": "Places: the tabs of a place", + "hooks": ["src/components/Collections/usePlaceSheet.ts"], + "desktop": ["src/components/Collections/PlaceSheetTabs.tsx"], + "mobile": ["src/mobile/screens/collections/MPlaceSheetTabs.tsx"] + }, { "feature": "Places: tours and bookings of a place", "hooks": ["src/components/Collections/usePlaceActivities.ts", "src/components/Collections/placeExtrasText.ts"], @@ -321,12 +345,6 @@ "desktop": ["src/components/Collections/PlaceHistorySection.tsx"], "mobile": ["src/mobile/screens/collections/MPlaceHistorySection.tsx"] }, - { - "feature": "Places: personal tags of a place", - "hooks": ["src/components/Collections/useEntryTags.ts"], - "desktop": ["src/components/Collections/EntryTagsSection.tsx", "src/components/Collections/PlacesLibraryView.tsx"], - "mobile": ["src/mobile/screens/collections/MEntryTagsSection.tsx", "src/mobile/screens/collections/MPlacesLibrary.tsx"] - }, { "feature": "Places: notes of a place", "hooks": ["src/components/Collections/useOriginNotes.ts"], @@ -335,7 +353,7 @@ }, { "feature": "Places: pictures and files of a place", - "hooks": ["src/components/Collections/usePlaceMedia.ts"], + "hooks": ["src/components/Collections/usePlaceMedia.ts", "src/components/Collections/mediaAdd.tsx"], "desktop": ["src/components/Collections/PlaceMediaSection.tsx"], "mobile": ["src/mobile/screens/collections/MPlaceMediaSection.tsx"] }, @@ -1186,6 +1204,10 @@ } ], "mobileOnly": { + "src/mobile/screens/collections/MPlaceCard.tsx": "The frame of a group in the phone's place view; the desktop twin is PlaceCard, plain markup with no logic to share.", + "src/mobile/screens/collections/MPlaceEditForm.tsx": "Markup over the usePlaceEdit state MLibraryPlaceSheet passes in; the hook is in the \"a place of all places\" pair.", + "src/mobile/screens/collections/MPlaceSheetShell.tsx": "The phone's frame of the one place view (cover, body, bottom row); the desktop frame is DialogShell.", + "src/mobile/screens/collections/MPlaceTagsCard.tsx": "Markup over the usePlaceTags state the place sheets pass in; the hook is in their pairs.", "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.", diff --git a/client/scripts/format-baseline.json b/client/scripts/format-baseline.json index 09f4ac76a..ed0572430 100644 --- a/client/scripts/format-baseline.json +++ b/client/scripts/format-baseline.json @@ -233,7 +233,6 @@ "src/components/Collections/CollectionPicker.test.tsx", "src/components/Collections/CollectionPicker.tsx", "src/components/Collections/CollectionPlaceDetail.test.tsx", - "src/components/Collections/CollectionPlaceDetail.tsx", "src/components/Collections/CopyToTripModal.test.tsx", "src/components/Collections/CopyToTripModal.tsx", "src/components/Collections/ImportCollectionModal.test.tsx", @@ -1288,7 +1287,6 @@ "src/mobile/screens/collections/MCollLinksEditor.tsx", "src/mobile/screens/collections/MCollListPickerSheet.tsx", "src/mobile/screens/collections/MCollPlaceRow.tsx", - "src/mobile/screens/collections/MCollPlaceSheet.tsx", "src/mobile/screens/collections/MCollShareSheet.tsx", "src/mobile/screens/collections/MCollSheetKit.tsx", "src/mobile/screens/collections/MCollTripPickerSheet.tsx", diff --git a/client/scripts/rtl-disable-baseline.json b/client/scripts/rtl-disable-baseline.json index d652be81e..225945a30 100644 --- a/client/scripts/rtl-disable-baseline.json +++ b/client/scripts/rtl-disable-baseline.json @@ -1,7 +1,6 @@ { "components/AtlasGlobe/atlasGlobe.css": 1, "components/Collections/CollectionMap.tsx": 1, - "components/Collections/detailDock.ts": 2, "components/Packing/PackingItemDetail.tsx": 1, "components/Studio/LineHandles.tsx": 1, "components/Studio/StudioSelectionChrome.tsx": 2, diff --git a/client/scripts/size-baseline.json b/client/scripts/size-baseline.json index d70f63ce7..74b52252b 100644 --- a/client/scripts/size-baseline.json +++ b/client/scripts/size-baseline.json @@ -12,7 +12,7 @@ "src/components/Planner/DayPlanSidebar.test.tsx": 5349, "src/components/Planner/DayPlanSidebar.tsx": 2908, "src/components/Planner/PlaceFormModal.test.tsx": 2836, - "src/components/Planner/PlaceInspector.tsx": 1128, + "src/components/Planner/PlaceInspector.tsx": 1030, "src/components/Studio/TravelElements.tsx": 1559, "src/components/Studio/countryShapes.ts": 2595, "src/index.css": 1636, diff --git a/client/scripts/theme-baseline.json b/client/scripts/theme-baseline.json index c95da0641..6e48887f1 100644 --- a/client/scripts/theme-baseline.json +++ b/client/scripts/theme-baseline.json @@ -171,7 +171,6 @@ "mobile/screens/collections/MCollLinksEditor.tsx": 2, "mobile/screens/collections/MCollListPickerSheet.tsx": 3, "mobile/screens/collections/MCollPlaceRow.tsx": 3, - "mobile/screens/collections/MCollPlaceSheet.tsx": 10, "mobile/screens/collections/MCollShareSheet.tsx": 14, "mobile/screens/collections/MCollSheetKit.tsx": 5, "mobile/screens/collections/MCollTripPickerSheet.tsx": 4, diff --git a/client/scripts/theme-disable-baseline.json b/client/scripts/theme-disable-baseline.json index 406d5c5aa..beb4b2e9d 100644 --- a/client/scripts/theme-disable-baseline.json +++ b/client/scripts/theme-disable-baseline.json @@ -59,7 +59,6 @@ "mobile/screens/atlas/MAtlasCountryPopup.tsx": 2, "mobile/screens/atlas/hub/MHubTravellers.tsx": 1, "mobile/screens/collections/MCollEditSheet.tsx": 2, - "mobile/screens/collections/MCollPlaceSheet.tsx": 2, "mobile/screens/collections/MCollShareSheet.tsx": 1, "mobile/screens/collections/collectionsMobileModel.ts": 15, "mobile/screens/dashboard/MDashboard.tsx": 3, diff --git a/client/src/api/placeTags.ts b/client/src/api/placeTags.ts deleted file mode 100644 index 25d91e010..000000000 --- a/client/src/api/placeTags.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { - CreateTagRequest, - PlacesLibraryBulkTagsRequest, - PlacesLibraryBulkTagsResponse, - PlacesLibraryEntryTagsRequest, - PlacesLibraryEntryTagsResponse, - Tag, - TagListResponse, - UpdateTagRequest, -} from '@trek/shared'; -import apiClient from './client'; - -const base = '/addons/collections/library/places/tags'; - -/** - * PLC-21: the user's personal tags (the ones /tags keeps) and which entries - * of All places carry them. Everything here is the user's own and private. - */ -export const placeTagsApi = { - list: (): Promise => apiClient.get('/tags').then((r) => r.data), - create: (body: CreateTagRequest): Promise<{ tag: Tag }> => - apiClient.post('/tags', body satisfies CreateTagRequest).then((r) => r.data), - update: (id: number, body: UpdateTagRequest): Promise<{ tag: Tag }> => - apiClient.put(`/tags/${id}`, body satisfies UpdateTagRequest).then((r) => r.data), - remove: (id: number): Promise<{ success: boolean }> => apiClient.delete(`/tags/${id}`).then((r) => r.data), - /** The entry carries exactly these tags from now on. */ - setForEntry: (body: PlacesLibraryEntryTagsRequest): Promise => - apiClient.put(base, body satisfies PlacesLibraryEntryTagsRequest).then((r) => r.data), - /** Puts tags on several entries and takes others off them. */ - bulk: (body: PlacesLibraryBulkTagsRequest): Promise => - apiClient.post(`${base}/bulk`, body satisfies PlacesLibraryBulkTagsRequest).then((r) => r.data), -}; diff --git a/client/src/api/placesLibrary.ts b/client/src/api/placesLibrary.ts index fd7e58775..164de15a7 100644 --- a/client/src/api/placesLibrary.ts +++ b/client/src/api/placesLibrary.ts @@ -1,19 +1,24 @@ -import type { - PlacesLibraryDetailResponse, - PlacesLibraryKind, - PlacesLibraryPageResponse, - PlacesLibraryQueryInput, +import { + joinLibraryTagNames, + type PlacesLibraryDetailResponse, + type PlacesLibraryKind, + type PlacesLibraryPageResponse, + type PlacesLibraryQueryInput, + type PlacesLibraryRateResponse, } from '@trek/shared'; import apiClient from './client'; const base = '/addons/collections/library/places'; -/** The query as the server reads it: a tag filter (PLC-21) as its ids joined by commas, not `tag_ids[]=`. */ +/** + * The query as the server reads it: a tag filter (PLC-21) as its names joined by commas, a comma + * inside a name escaped (`joinLibraryTagNames`), not `tags[]=`. + */ function queryParams(query: PlacesLibraryQueryInput): Record { - const { tag_ids: tagIds, ...rest } = query; - if (tagIds === undefined) return rest; - const joined = Array.isArray(tagIds) ? tagIds.join(',') : tagIds; - return joined === '' ? rest : { ...rest, tag_ids: joined }; + const { tags, ...rest } = query; + if (tags === undefined) return rest; + const joined = Array.isArray(tags) ? joinLibraryTagNames(tags) : tags; + return joined === '' ? rest : { ...rest, tags: joined }; } /** PLC-07/PLC-08 "All places": one page of entries, and one entry by the trip place or saved place it was opened from. */ @@ -22,4 +27,9 @@ export const placesLibraryApi = { apiClient.get(base, { params: queryParams(query), signal }).then((r) => r.data), detail: (kind: PlacesLibraryKind, id: number, signal?: AbortSignal): Promise => apiClient.get(`${base}/${kind}/${id}`, { signal }).then((r) => r.data), + /** The reader's vote on an entry, on every copy of it they may vote on; null takes it back. */ + rate: (key: string, rating: number | null): Promise => + rating === null + ? apiClient.delete(`${base}/rating`, { params: { key } }).then((r) => r.data) + : apiClient.put(`${base}/rating`, { key, rating }).then((r) => r.data), }; diff --git a/client/src/components/Collections/CollectionHero.tsx b/client/src/components/Collections/CollectionHero.tsx index f83139091..97e65a65b 100644 --- a/client/src/components/Collections/CollectionHero.tsx +++ b/client/src/components/Collections/CollectionHero.tsx @@ -18,6 +18,8 @@ interface CollectionHeroProps { /** List colour — drives the gradient wash (or tints the cover image). */ color: string coverImage?: string | null + /** The two views that are not a list wear their own gradient: every place, and everything saved. */ + variant?: 'library' | 'saved' description?: string | null links?: CollectionLink[] /** Accepted members (owner first) — shown as an avatar stack when shared. */ @@ -47,7 +49,7 @@ function linkHost(url: string): string { } export default function CollectionHero({ - eyebrow, title, color, coverImage, description, links, + eyebrow, title, color, coverImage, variant, description, links, members, canShare, isOwner, canEdit, onEdit, shareMemberCount, onShare, onExport, exporting, t, }: CollectionHeroProps): React.ReactElement { const accepted = members.filter(m => m.status === 'accepted' || m.is_owner) @@ -56,7 +58,7 @@ export default function CollectionHero({ const extra = accepted.length - shown.length return ( -
+
{coverImage ? ( <> diff --git a/client/src/components/Collections/CollectionList.tsx b/client/src/components/Collections/CollectionList.tsx index cab7c7d88..e0317079d 100644 --- a/client/src/components/Collections/CollectionList.tsx +++ b/client/src/components/Collections/CollectionList.tsx @@ -4,7 +4,7 @@ import type { CollectionPlace, CollectionStatus, CollectionLabel } from '@trek/s import type { TranslationFn } from '../../types' import PlaceAvatar from '../shared/PlaceAvatar' import StatusBadge from './StatusBadge' -import CollectionPlaceTags from './CollectionPlaceTags' +import EntryTagDots from './EntryTagDots' import { usePlaceReorder } from './usePlaceReorder' import CategoryBadge from './CategoryBadge' @@ -119,7 +119,7 @@ export default function CollectionList({ )}
-
{place.category?.name && }{place.name}
+
{place.category?.name && }{place.name}
{place.address && (
@@ -127,7 +127,6 @@ export default function CollectionList({
)}
-
onStatusChange(place.id, next)} t={t} />
diff --git a/client/src/components/Collections/CollectionPlaceDetail.tsx b/client/src/components/Collections/CollectionPlaceDetail.tsx index f368e56fb..c02d3dea1 100644 --- a/client/src/components/Collections/CollectionPlaceDetail.tsx +++ b/client/src/components/Collections/CollectionPlaceDetail.tsx @@ -1,307 +1,549 @@ -import React, { useRef, useState } from 'react' -import PlaceLocationBadge from './PlaceLocationBadge' -import { dockStyle, type DockRect } from './detailDock' -import Markdown from 'react-markdown' -import remarkGfm from 'remark-gfm' -import remarkBreaks from 'remark-breaks' -import { markdownLinkComponents } from '../shared/markdownLink' -import { X, Pencil, Copy, Trash2, MapPin, Link2, Plus, ExternalLink, Check, Tags, Camera, Loader2, Navigation } from 'lucide-react' -import type { CollectionPlace, CollectionStatus, CollectionLink, CollectionLabel } from '@trek/shared' -import type { Category, TranslationFn } from '../../types' -import MarkdownToolbar from '../Journey/MarkdownToolbar' -import { NumericInput } from '../shared/NumericInput' -import { entityGradient } from '../../utils/gradients' -import { getCategoryIcon } from '../shared/categoryIcons' -import { NavigationMenu } from '../shared/NavigationMenu' -import { navigationTargetLabel, getNavigationTargets, openNavigationTarget } from '../Planner/placeNavigation' -import { STATUS_META, STATUS_ORDER, normalizeLinkUrl } from '../../pages/collections/collectionsModel' -import { Tooltip } from '../shared/Tooltip' -import PlaceRating from '../shared/StarRating' -import { useCollectionPlaceForm } from './useCollectionPlaceForm' -import { CollectionLocationSearch } from './CollectionLocationSearch' -import CategoryTileMenu from './CategoryTileMenu' +import type { CollectionLabel, CollectionLink, CollectionPlace, CollectionStatus } from '@trek/shared'; +import { + Camera, + Check, + Copy, + ExternalLink, + Link2, + Loader2, + MapPin, + Navigation, + Pencil, + Plus, + Trash2, +} from 'lucide-react'; +import React, { useId, useRef, useState } from 'react'; +import Markdown from 'react-markdown'; +import { useNavigate } from 'react-router'; +import remarkBreaks from 'remark-breaks'; +import remarkGfm from 'remark-gfm'; +import { useTranslation } from '../../i18n'; +import { STATUS_META, STATUS_ORDER, normalizeLinkUrl } from '../../pages/collections/collectionsModel'; +import type { Category, TranslationFn } from '../../types'; +import { entityGradient } from '../../utils/gradients'; +import { placesPath } from '../../utils/placesRoutes'; +import MarkdownToolbar from '../Journey/MarkdownToolbar'; +import { getNavigationTargets, navigationTargetLabel, openNavigationTarget } from '../Planner/placeNavigation'; +import { getCategoryIcon } from '../shared/categoryIcons'; +import { DialogShell } from '../shared/DialogShell'; +import { markdownLinkComponents } from '../shared/markdownLink'; +import { NavigationMenu } from '../shared/NavigationMenu'; +import { NumericInput } from '../shared/NumericInput'; +import PlaceRating from '../shared/StarRating'; +import { Tooltip } from '../shared/Tooltip'; +import CategoryTileMenu from './CategoryTileMenu'; +import { CollectionLocationSearch } from './CollectionLocationSearch'; +import { originPairs } from './libraryPairs'; +import PlaceLocationBadge from './PlaceLocationBadge'; +import PlaceOrigins from './PlaceOrigins'; +import './placeSheet.css'; +import PlaceSheetTabs from './PlaceSheetTabs'; +import PlaceTagsCard from './PlaceTagsCard'; +import { useCollectionPlaceForm } from './useCollectionPlaceForm'; +import { useLibraryPlace } from './useLibraryPlace'; +import { usePlaceSheet } from './usePlaceSheet'; +import { usePlaceTags } from './usePlaceTags'; function linkHost(url: string): string { - try { return new URL(url).hostname.replace(/^www\./, '') } catch { return url } + try { + return new URL(url).hostname.replace(/^www\./, ''); + } catch { + return url; + } } +type PlacePatch = { + name?: string; + description?: string | null; + notes?: string | null; + links?: CollectionLink[]; + category_id?: number | null; + label_ids?: number[]; + image_url?: string | null; + lat?: number | null; + lng?: number | null; + address?: string | null; +}; + interface CollectionPlaceDetailProps { - place: CollectionPlace - canEdit: boolean - canDelete: boolean - categories: Category[] - /** The active list's custom labels, for the assign chips. */ - labels: CollectionLabel[] - /** When set, dock the sheet over that column (desktop split) instead of centred. */ - anchorRect?: DockRect | null - onClose: () => void - onSetStatus: (status: CollectionStatus) => void - onSave: (patch: { name?: string; description?: string | null; notes?: string | null; links?: CollectionLink[]; category_id?: number | null; label_ids?: number[]; image_url?: string | null; lat?: number | null; lng?: number | null; address?: string | null }) => Promise + place: CollectionPlace; + canEdit: boolean; + canDelete: boolean; + categories: Category[]; + /** The active list's tags, which the edit form keeps as they are. */ + labels: CollectionLabel[]; + /** True while a dialog opened from here is open: Escape and the backdrop leave this one alone. */ + blocked?: boolean; + onClose: () => void; + onSetStatus: (status: CollectionStatus) => void; + onSave: (patch: PlacePatch) => Promise; /** Upload a custom cover image (#1136); enables the cover change/remove controls. */ - onUploadImage?: (file: File) => Promise - onCopyToTrip: () => void - onRemove: () => void + onUploadImage?: (file: File) => Promise; + onCopyToTrip: () => void; + onRemove: () => void; /** Cast/clear the current user's star vote (#1435); every member may vote. */ - onRate?: (rating: number | null) => Promise | void - t: TranslationFn + onRate?: (rating: number | null) => Promise | void; + t: TranslationFn; } -function StatusSegment({ status, onSet, t }: { status: CollectionStatus; onSet: (s: CollectionStatus) => void; t: TranslationFn }): React.ReactElement { +function StatusSegment({ + status, + onSet, + t, +}: { + status: CollectionStatus; + onSet: (s: CollectionStatus) => void; + t: TranslationFn; +}): React.ReactElement { return (
- {STATUS_ORDER.map(s => { - const Icon = STATUS_META[s].icon - const on = status === s + {STATUS_ORDER.map((s) => { + const Icon = STATUS_META[s].icon; + const on = status === s; return ( - ) + ); })}
- ) + ); } -/** - * Bottom detail sheet for a saved place — an opaque, clearly-sectioned card - * (cover → meta → status → description → links) docked over the list column. - * Read mode renders the description as markdown + link chips; edit mode swaps in - * name / category / markdown description / links, saving via updatePlace. Status - * is an always-live segmented control (auto-saves). - */ -export default function CollectionPlaceDetail({ - place, canEdit, canDelete, categories, labels, anchorRect, onClose, onSetStatus, onSave, onUploadImage, onCopyToTrip, onRemove, onRate, t, -}: CollectionPlaceDetailProps): React.ReactElement { - const coverInputRef = useRef(null) - const [navOpen, setNavOpen] = useState(false) - const navBtnRef = useRef(null) - const navigationTargets = getNavigationTargets(place) - const descRef = useRef(null) - const { - editing, setEditing, name, setName, categoryId, setCategoryId, description, setDescription, notes, setNotes, links, setLinks, setLink, - labelIds, toggleLabel, address, setAddress, lat, setLat, lng, setLng, pickPosition, positionPicked, needsPosition, saving, imgBusy, cover: banner, assignedLabels, - handleImagePick: handleCoverPick, handleImageRemove, cancelEdit: resetForm, save, - } = useCollectionPlaceForm({ place, labels, onSave, onUploadImage, t, normalizeLinkUrl, withCoordinates: true }) - - const coordPaste = (e: React.ClipboardEvent) => { - const text = e.clipboardData.getData('text').trim() - const match = text.match(/^(-?\d+(?:\.\d*)?)(?:\s*[,;]\s*|\s+)(-?\d+(?:\.\d*)?)$/) - if (match) { e.preventDefault(); setLat(match[1]); setLng(match[2]) } - } - - const CatIcon = getCategoryIcon(place.category?.icon) +type Form = ReturnType; +/** The cover: the picture or a gradient, the category, the picture controls, close, and the name. */ +function Cover({ + place, + form, + canEdit, + categories, + labelId, + onUploadImage, + onClose, + t, +}: { + place: CollectionPlace; + form: Form; + canEdit: boolean; + categories: Category[]; + labelId: string; + onUploadImage?: (file: File) => Promise; + onClose: () => void; + t: TranslationFn; +}) { + const coverInputRef = useRef(null); + const CatIcon = getCategoryIcon(place.category?.icon); + const banner = form.cover; return ( -
e.stopPropagation()}> -
- {banner && } -
- {/* Chip and cover controls share the top bar. The controls keep the end and - never shrink, so a long category name ellipsizes instead of sliding under - them, however many buttons there are and whatever size phones give them. */} -
- {place.category?.name && ( - - - {place.category.name} - - )} - {/* The cover controls wear the close button's class, so they get its look, - hover and phone size. */} -
- {canEdit && onUploadImage && ( - <> - - {place.image_url && !imgBusy && ( - - - - )} - +
+ {banner && } +
+
+ {place.category?.name && ( + + + {place.category.name} + + )} +
+ {canEdit && onUploadImage && ( + <> + + {place.image_url && !form.imgBusy && ( + - - )} - -
-
-
- {editing ? ( - // The category rides in front of the name instead of a chip row in the form. -
- {categories.length > 0 && } - setName(e.target.value)} className="col-detail-name-input min-w-0 flex-1" autoFocus aria-label={t('common.name')} /> -
- ) : ( - <> -

{place.name}

- + )} + + + )}
- -
- - {/* Status — live for editors, read-only for viewers */} - {}} t={t} /> - - {/* Collaborative rating (#1435) — every member votes; the average shows. */} - {/* Rating and labels on one line, each on its own ground. - A bare line of stars read as another row of text, and the labels tried the - cover photo first — where a blue chip on a blue sky is simply not there. - Side by side they are two badges answering two questions about the place. */} - {(onRate || assignedLabels.length > 0) && ( -
- {onRate && ( -
- -
+
+ {form.editing ? ( + // The category rides in front of the name instead of a chip row in the form. +
+ {categories.length > 0 && ( + )} - {!editing && assignedLabels.map(l => ( - - {l.name} - - ))} -
- )} - - {editing ? ( -
- {/* A place that has no position yet can be looked up here (#2837). */} - {needsPosition && } - {/* Address (#1870): free text, the coordinates stay separate */} -
-
{t('places.formAddress')}
- setAddress(e.target.value)} placeholder={t('places.formAddressPlaceholder')} className="col-detail-input" /> -
- {/* Coordinates */} -
-
{t('collections.coordinates')}
-
- - -
-
- {/* Labels */} - {labels.length > 0 && ( -
-
{t('collections.labels.title')}
-
- {labels.map(l => { - const on = labelIds.includes(l.id) - return ( - - ) - })} -
-
- )} - {/* Description */} -
-
{t('collections.description')}
- -