feat(places): collaborative place ratings + collections MCP (#1435) (#1644)

Trip members can rate a place 1-5 stars; the place shows the average,
with a who-voted custom tooltip and a star-sort toggle in the places
sidebar. Saved collection places are ratable too (plus a min-rating
filter), and ratings travel with a place copied between a trip and a
collection — carrying only the votes of users who belong to both sides.

Adds a full Collections MCP surface (list/get, CRUD lists + places,
status, rate_collection_place, labels, sharing, copy-to-trip) under a
new collections:read/collections:write scope, plus rate_place for trip
places; rating aggregates flow through the existing place outputs.

Mobile trip + collection place sheets gain the rating row. New UI
strings translated across all 22 locales.
This commit is contained in:
Maurice
2026-07-21 21:00:26 +02:00
committed by GitHub
parent 88cb7f22dd
commit 399e3573c1
86 changed files with 1441 additions and 46 deletions
@@ -11,6 +11,7 @@ import { normalizeImageFile } from '../../../utils/convertHeic'
import { getApiErrorMessage } from '../../../types'
import { normalizeLinkUrl, STATUS_ORDER } from '../../../pages/collections/collectionsModel'
import MSheet from '../../components/MSheet'
import PlaceRating from '../../../components/shared/StarRating'
import MCollCategoryPicker from './MCollCategoryPicker'
import MCollLinksEditor from './MCollLinksEditor'
import { STATUS_SPEC } from './collectionsMobileModel'
@@ -38,6 +39,8 @@ interface MCollPlaceSheetProps {
onUploadImage?: (file: File) => Promise<void>
onCopyToTrip: () => void
onRemove: () => void
/** Cast/clear the current user's star vote (#1435); every member may vote. */
onRate?: (rating: number | null) => Promise<void> | void
t: TranslationFn
}
@@ -48,7 +51,7 @@ interface MCollPlaceSheetProps {
* description / links.
*/
export default function MCollPlaceSheet({
place, canEdit, canDelete, categories, labels, onClose, onSetStatus, onSave, onUploadImage, onCopyToTrip, onRemove, t,
place, canEdit, canDelete, categories, labels, onClose, onSetStatus, onSave, onUploadImage, onCopyToTrip, onRemove, onRate, t,
}: MCollPlaceSheetProps) {
const toast = useToast()
const imageInputRef = useRef<HTMLInputElement | null>(null)
@@ -231,6 +234,13 @@ export default function MCollPlaceSheet({
})}
</div>
{/* Collaborative rating (#1435) — tap a star to cast/clear your vote. */}
{onRate && (
<div className="mt-3">
<PlaceRating ratings={held.ratings ?? []} ratingAvg={held.rating_avg} onRate={onRate} size={18} />
</div>
)}
{editing ? (
<>
<Eyebrow className="mb-[6px] mt-4">{t('common.name').toUpperCase()}</Eyebrow>
@@ -84,13 +84,14 @@ export default function MCollections() {
setLabelDrop(false)
}, [c.activeId])
// The mobile toolbar has no category filter control, but the shared hook
// still applies one set on desktop — keep it cleared so resizing to phone
// doesn't silently filter the list and map.
const { categoryFilter, setCategoryFilter } = c
// The mobile toolbar has no category or rating filter control, but the shared
// hook still applies whatever was set on desktop — keep both cleared so
// resizing to phone doesn't silently filter the list and map (#1435).
const { categoryFilter, setCategoryFilter, ratingFilter, setRatingFilter } = c
useEffect(() => {
if (categoryFilter !== 'all') setCategoryFilter('all')
}, [categoryFilter, setCategoryFilter])
if (ratingFilter !== 'all') setRatingFilter('all')
}, [categoryFilter, setCategoryFilter, ratingFilter, setRatingFilter])
const title = c.isAllSaved ? t('collections.allSaved') : (c.activeCollection?.name ?? t('collections.title'))
const isRealList = !c.isAllSaved && typeof c.activeId === 'number'
@@ -456,6 +457,7 @@ export default function MCollections() {
onUploadImage={file => c.uploadPlaceImage(c.selectedPlace!.id, file)}
onCopyToTrip={c.openCopyForSelectedPlace}
onRemove={c.handleDetailRemove}
onRate={r => c.handleRatePlace(c.selectedPlace!.id, r)}
t={t}
/>
@@ -13,6 +13,7 @@ import { useAddonStore } from '../../../../store/addonStore'
import { useSaveToCollectionStore } from '../../../../store/saveToCollectionStore'
import { collectionTargetFromPlace } from '../lib/collectionTarget'
import { getCategoryIcon } from '../../../../components/shared/categoryIcons'
import PlaceRating from '../../../../components/shared/StarRating'
import { avatarSrc } from '../../../../utils/avatarSrc'
import { openFile } from '../../../../utils/fileDownload'
import { getGoogleMapsUrlForPlace } from '../../../../components/Planner/placeGoogleMaps'
@@ -168,6 +169,16 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) {
openSavePicker(collectionTargetFromPlace(place))
}
// Collaborative rating (#1435): every trip member casts their own star vote.
const handleRate = async (rating: number | null) => {
if (!place) return
try {
await planner.tripActions.ratePlace(planner.tripId, place.id, rating)
} catch (err: unknown) {
planner.toast.error(err instanceof Error ? err.message : t('common.unknownError'))
}
}
const showOnMap = () => {
close()
if (shell.trTab !== 'plan') shell.setTrTab('plan')
@@ -259,6 +270,11 @@ export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) {
</a>
)}
{/* Collaborative rating (#1435) — tap a star to cast/clear your vote. */}
<div className={`mt-[10px] rounded-[14px] px-3 py-[10px] ${INNER_CLS}`}>
<PlaceRating ratings={place.ratings ?? []} ratingAvg={place.rating_avg} onRate={handleRate} size={18} />
</div>
{place.description && (
<div className={`mt-[10px] rounded-[14px] px-3 py-[10px] ${INNER_CLS}`}>
<div className="font-geist text-[0.75rem] leading-[1.5] text-m-muted">{place.description}</div>