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
@@ -7,6 +7,7 @@ import remarkBreaks from 'remark-breaks'
import { X, Clock, MapPin, ExternalLink, Phone, Banknote, Edit2, Trash2, Plus, Minus, ChevronDown, ChevronUp, FileText, Upload, File, FileImage, Star, Navigation, Map as MapIcon, Users, Mountain, TrendingUp, Bookmark, BookmarkCheck, Copy } from 'lucide-react'
import PlaceAvatar from '../shared/PlaceAvatar'
import PlaceAvatarUpload from '../shared/PlaceAvatarUpload'
import PlaceRating from '../shared/StarRating'
import GuestBadge from '../shared/GuestBadge'
import StatusBadge from '../Collections/StatusBadge'
import { mapsApi, pluginsApi } from '../../api/client'
@@ -131,6 +132,8 @@ interface PlaceInspectorProps {
onUpdatePlace?: (placeId: number, data: Partial<Place>) => void
/** Upload a custom thumbnail (#1136); enables the click-to-change avatar in trip mode. */
onUploadImage?: (placeId: number, file: File) => Promise<void>
/** Cast/clear the current user's star vote (#1435); enables the rating row. */
onRate?: (placeId: number, rating: number | null) => Promise<void> | void
leftWidth?: number
rightWidth?: number
// ── Collection-mode props ──
@@ -144,7 +147,7 @@ export default function PlaceInspector({
place, categories, mode = 'trip', days = [], selectedDayId = null, selectedAssignmentId = null,
assignments = {}, reservations = [],
onClose, onEdit, onDelete, onAssignToDay, onRemoveAssignment,
files = [], onFileUpload, tripMembers = [], onSetParticipants, onUpdatePlace, onUploadImage,
files = [], onFileUpload, tripMembers = [], onSetParticipants, onUpdatePlace, onUploadImage, onRate,
leftWidth = 0, rightWidth = 0,
collectionStatus, onCopyToTrip, onSetStatus, onRemoveFromList,
}: PlaceInspectorProps) {
@@ -341,6 +344,17 @@ export default function PlaceInspector({
)}
</div>
{/* Collaborative rating (#1435) — every member's own vote, shown as the average. */}
{mode === 'trip' && onRate && (
<div className="bg-surface-hover" style={{ borderRadius: 10, padding: '8px 12px' }}>
<PlaceRating
ratings={place.ratings ?? []}
ratingAvg={place.rating_avg}
onRate={rating => onRate(place.id, rating)}
/>
</div>
)}
{/* Telefon */}
{(place.phone || googleDetails?.phone) && (
<div style={{ display: 'flex', gap: 12 }}>
@@ -1,4 +1,4 @@
import { Search, Plus, X, Upload, ChevronDown, Check, MapPin } from 'lucide-react'
import { Search, Plus, X, Upload, ChevronDown, Check, MapPin, Star } from 'lucide-react'
import { getCategoryIcon } from '../shared/categoryIcons'
import Tooltip from '../shared/Tooltip'
import type { SidebarState } from './usePlacesSidebar'
@@ -25,6 +25,7 @@ export function PlacesHeader(S: SidebarState) {
places, categories, categoryFilters, search, setSearch, plannedIds, hasTracks,
filter, setFilter, setSelectedIds, selectMode, setSelectMode,
catDropOpen, setCatDropOpen, toggleCategoryFilter, setCategoryFilters,
ratingSort, setRatingSort,
} = S
return (
<div className="border-b border-edge-faint" style={{ padding: '14px 16px 10px', flexShrink: 0 }}>
@@ -165,6 +166,25 @@ export function PlacesHeader(S: SidebarState) {
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{label}</span>
<ChevronDown size={12} className="text-content-faint" style={{ flexShrink: 0, transform: catDropOpen ? 'rotate(180deg)' : 'none', transition: 'transform 0.15s' }} />
</button>
{/* Star sort (#1435): order the list by average rating, best first. */}
<Tooltip label={t('places.sortByRating')} placement="bottom">
<button
onClick={() => setRatingSort(v => !v)}
aria-label={t('places.sortByRating')}
aria-pressed={ratingSort}
className={ratingSort ? 'text-accent' : 'text-content-faint'}
style={{
width: 30, flexShrink: 0, borderRadius: 8,
border: `1px solid ${ratingSort ? 'var(--accent)' : 'var(--border-primary)'}`,
background: ratingSort ? 'color-mix(in srgb, var(--accent) 14%, transparent)' : 'var(--bg-card)',
cursor: 'pointer', fontFamily: 'inherit', padding: 0,
display: 'flex', alignItems: 'center', justifyContent: 'center',
transition: 'background 0.18s, color 0.18s, border-color 0.18s',
}}
>
<Star size={13} strokeWidth={2.2} fill={ratingSort ? 'currentColor' : 'none'} />
</button>
</Tooltip>
{canEditPlaces && (
<Tooltip label={t('common.select')} placement="bottom">
<button
@@ -1,5 +1,5 @@
import React from 'react'
import { Plus, Check, Route } from 'lucide-react'
import { Plus, Check, Route, Star } from 'lucide-react'
import PlaceAvatar from '../shared/PlaceAvatar'
import { getCategoryIcon } from '../shared/categoryIcons'
import type { Place, Category } from '../../types'
@@ -89,6 +89,13 @@ export const MemoPlaceRow = React.memo(function MemoPlaceRow({
<span className="text-content" style={{ fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontWeight: 500, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', lineHeight: 1.2 }}>
{place.name}
</span>
{/* Average member rating (#1435). */}
{(place.rating_count ?? 0) > 0 && place.rating_avg != null && (
<span style={{ display: 'inline-flex', alignItems: 'center', gap: 2, flexShrink: 0, fontSize: 'calc(10px * var(--fs-scale-caption, 1))', fontWeight: 600, color: 'var(--text-secondary)', fontVariantNumeric: 'tabular-nums' }}>
<Star size={9} color="#facc15" fill="#facc15" />
{(Math.round(place.rating_avg * 10) / 10).toLocaleString()}
</span>
)}
</div>
{(place.description || place.address || cat?.name) && (
<div style={{ marginTop: 2 }}>
@@ -155,6 +155,8 @@ export function usePlacesSidebar(props: PlacesSidebarProps) {
const categoryFilters = useTripStore((s) => s.placesCategoryFilter)
const setCategoryFilters = useTripStore((s) => s.setPlacesCategoryFilter)
const [selectMode, setSelectMode] = useState(false)
// Star sort (#1435): list-only toggle, so it stays local (the map keeps its order).
const [ratingSort, setRatingSort] = useState(false)
const [selectedIds, setSelectedIds] = useState<Set<number>>(new Set())
const [pendingDeleteIds, setPendingDeleteIds] = useState<number[] | null>(null)
const [categoryPickerOpen, setCategoryPickerOpen] = useState(false)
@@ -196,18 +198,26 @@ export function usePlacesSidebar(props: PlacesSidebarProps) {
Object.values(assignments).flatMap(da => da.map(a => a.place?.id).filter(Boolean))
), [assignments])
const filtered = useMemo(() => places.filter(p => {
if (filter === 'unplanned' && plannedIds.has(p.id)) return false
if (filter === 'tracks' && !p.route_geometry) return false
if (categoryFilters.size > 0) {
if (p.category_id == null) {
if (!categoryFilters.has('uncategorized')) return false
} else if (!categoryFilters.has(String(p.category_id))) return false
const filtered = useMemo(() => {
const list = places.filter(p => {
if (filter === 'unplanned' && plannedIds.has(p.id)) return false
if (filter === 'tracks' && !p.route_geometry) return false
if (categoryFilters.size > 0) {
if (p.category_id == null) {
if (!categoryFilters.has('uncategorized')) return false
} else if (!categoryFilters.has(String(p.category_id))) return false
}
if (search && !p.name.toLowerCase().includes(search.toLowerCase()) &&
!(p.address || '').toLowerCase().includes(search.toLowerCase())) return false
return true
})
// Star sort (#1435): highest average first, unrated places at the end;
// ties keep the list's original order (stable sort).
if (ratingSort) {
return [...list].sort((a, b) => (b.rating_avg ?? -1) - (a.rating_avg ?? -1))
}
if (search && !p.name.toLowerCase().includes(search.toLowerCase()) &&
!(p.address || '').toLowerCase().includes(search.toLowerCase())) return false
return true
}), [places, filter, categoryFilters, search, plannedIds])
return list
}, [places, filter, categoryFilters, search, plannedIds, ratingSort])
const registerPlaceRow = useCallback((placeId: number, element: HTMLDivElement | null) => {
if (element) {
@@ -267,6 +277,7 @@ export function usePlacesSidebar(props: PlacesSidebarProps) {
listImportEnrich, setListImportEnrich, canEnrichImport,
availableListImportProviders, hasMultipleListImportProviders, handleListImport,
search, setSearch, filter, setFilter, categoryFilters, setCategoryFilters,
ratingSort, setRatingSort,
selectMode, setSelectMode, selectedIds, setSelectedIds, pendingDeleteIds, setPendingDeleteIds,
categoryPickerOpen, setCategoryPickerOpen,
saveToListOpen, setSaveToListOpen, collectionsEnabled, tripId,