The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
import { useMemo, useRef, useState, type KeyboardEvent } from 'react'
import DawarichIcon from '../../../../components/shared/DawarichIcon'
import {
ArrowLeftRight, Bookmark, ChevronRight, ExternalLink, Map as MapIcon, MapPinOff, Navigation, Paperclip,
Pencil, Phone, Plus, Route, RouteOff, Sparkles, Trash2, Upload, X,
} from 'lucide-react'
import MSheet from '../../../components/MSheet'
import type { MTripSheetsProps } from '../MTripShell'
import { useTranslation, translateApiError } from '../../../../i18n'
import { useAddonStore } from '../../../../store/addonStore'
import { useSaveToCollectionStore } from '../../../../store/saveToCollectionStore'
import { placeToSaveTarget } from '../../../../components/Collections/saveTarget'
import { useAssistantAsk } from '../../../../components/Assistant/useAssistantAsk'
import {
participantsWith, participantsWithout, placeActions, splitParticipants, usePlaceFileUpload,
} from '../../../../components/Planner/usePlaceActions'
import { getCategoryIcon } from '../../../../components/shared/categoryIcons'
import PlaceRating from '../../../../components/shared/StarRating'
import MarkdownText from '../../../../components/shared/MarkdownText'
import TrackColorPicker from '../../../../components/shared/TrackColorPicker'
import { resolveTrackColor, inheritedTrackColor } from '../../../../components/Map/trackColors'
import { avatarSrc } from '../../../../utils/avatarSrc'
import { safeHttpUrl } from '../../../../utils/safeUrl'
import { openFile } from '../../../../utils/fileDownload'
import { filesForPlace } from '../../../../utils/placeFiles'
import { navigationTargetLabel, getNavigationTargets, openNavigationTarget } from '../../../../components/Planner/placeNavigation'
import { addressWithoutCoordinates } from '../../../../components/Planner/placeCoordinates'
import { NavigationMenu } from '../../../../components/shared/NavigationMenu'
import { getPlaceBookings, timedSlot } from '../../../../utils/dayMerge'
import type { Assignment, Day, Reservation, TripMember } from '../../../../types'
import PlacePhotoGallery from '../../../../components/Planner/PlacePhotoGallery'
import { ActionCircle, Eyebrow, INNER_CLS } from './MTripSheetUi'
import { FormSheetBody } from './PlSheetChrome'
import { PlTagChips } from './PlTags'
/**
* Place inspector sheet (glass card), opened by the current place selection —
* timeline taps, map markers and the browse "View details" action all funnel
* through planner.handlePlaceClick/handleMarkerClick. Shows photo + category,
* contact/description/notes, day assignments, per-assignment participants and
* attached files, plus the inspector action row.
*/
export default function MPlaceSheet({ planner, shell }: MTripSheetsProps) {
const { t, language } = useTranslation()
const place = planner.selectedPlace ?? null
// Match the desktop inspector gate: while the Tours facet is loading, wait
// before choosing a surface; once identified as a tour, its purpose-built
// dialog is the only detail surface that should open.
const open = !!place && (!planner.toursEnabled || planner.tourDataReady) && !planner.selectedTour
const canEditPlaces = planner.can('place_edit', planner.trip)
const canEditDays = planner.can('day_edit', planner.trip)
const isTourPlace = place != null && planner.isTourPlace(place.id)
const canManagePlace = canEditPlaces && !isTourPlace
const collectionsEnabled = useAddonStore(s => s.isEnabled('collections'))
const openSavePicker = useSaveToCollectionStore(s => s.open)
const assistant = useAssistantAsk(planner.tripId)
const actions = placeActions({ tripId: planner.tripId, tripActions: planner.tripActions, toast: planner.toast, t })
const {
uploading, filesExpanded, setFilesExpanded, fileInputRef, handleUpload,
} = usePlaceFileUpload(place && !isTourPlace ? place.id : null, fd => planner.tripActions.addFile(planner.tripId, fd), planner.toast)
const [dayPickerOpen, setDayPickerOpen] = useState(false)
// A day of this place picked to move from (#2583): the day list then moves it there instead of adding it.
// Only the ids are kept, so a stop a collaborator moved or removed meanwhile is read as it is now.
const [movingIds, setMovingIds] = useState<{ placeId: number; assignmentId: number } | null>(null)
const [participantPickerOpen, setParticipantPickerOpen] = useState(false)
const [navOpen, setNavOpen] = useState(false)
const navBtnRef = useRef<HTMLButtonElement>(null)
const [colorPickerOpen, setColorPickerOpen] = useState(false)
const close = () => {
planner.setSelectedPlaceId(null)
setFilesExpanded(false)
setDayPickerOpen(false)
setMovingIds(null)
setParticipantPickerOpen(false)
setColorPickerOpen(false)
}
const category = place?.category
?? planner.categories.find(c => c.id === place?.category_id)
?? null
const CatIcon = getCategoryIcon(category?.icon)
// Every day this place is assigned to (the audit's day-assignment gap).
const placeAssignments = useMemo(() => {
if (!place) return [] as { day: Day; assignment: Assignment }[]
const rows: { day: Day; assignment: Assignment }[] = []
for (const day of planner.days) {
for (const a of planner.assignments[String(day.id)] || []) {
if (a.place?.id === place.id) rows.push({ day, assignment: a })
}
}
return rows
}, [place, planner.days, planner.assignments])
const moving = movingIds && movingIds.placeId === place?.id
? placeAssignments.find(r => r.assignment.id === movingIds.assignmentId) ?? null
: null
if (movingIds && !moving) setMovingIds(null)
const unassignedDays = planner.days.filter(d => !placeAssignments.some(r => r.day.id === d.id))
const dayLabel = (d: Day) => d.title || t('planner.dayN', { n: (d.day_number ?? planner.days.indexOf(d) + 1) || '?' })
// Lands where its time belongs on the new day, as a move on the desktop does;
// without a time it goes to the end.
const moveToDay = ({ assignment, day }: { assignment: Assignment; day: Day }, toDayId: number) => {
const slot = timedSlot(planner.storedAssignments[String(toDayId)] || [], planner.tripAccommodations, assignment.place?.place_time) ?? undefined
planner.handleMoveToDay(assignment.id, day.id, toDayId, slot)
.catch((err: unknown) => planner.toast.error(err instanceof Error ? err.message : t('common.unknownError')))
}
// Participants belong to the assignment in the selected day (desktop parity).
const dayAssignments = planner.selectedDayId ? (planner.assignments[String(planner.selectedDayId)] || []) : []
const assignmentInDay = planner.selectedDayId
? ((planner.selectedAssignmentId ? dayAssignments.find(a => a.id === planner.selectedAssignmentId) : null)
?? dayAssignments.find(a => a.place?.id === place?.id))
: null
// The bookings attached to that assignment. The desktop inspector shows this
// strip; the phone sheet never did, so a booking reached from a map marker was
// just as unreachable here, only invisibly so (#2012). All of them, because a
// stop can carry a parking pass next to its tickets (#2201). A hotel also lists
// the stay booked for it, the way back to its booking (#2363).
const linkedReservations = getPlaceBookings(planner.reservations, assignmentInDay?.id, place?.id)
// A ferry or a flight has its own form — the reservation modal cannot hold one.
// Resolved up front so a user without the matching right gets no button at all,
// rather than one that does nothing (#2012).
const canOpenRes = (res: Reservation) => planner.can(
planner.TRANSPORT_TYPES.has(res.type) ? 'day_edit' : 'reservation_edit',
planner.trip,
)
const openRes = (res: Reservation) => {
if (!canOpenRes(res)) return
// This sheet hangs off the place selection, not the sheet stack, so its own
// close() is what dismisses it; the booking's detail sheet then opens alone,
// with its pencil for editing, as on the desktop.
close()
shell.openSheet('transport', { reservationId: res.id })
}
const participants = assignmentInDay?.participants || []
const participantIds = participants.map(p => p.user_id)
const allJoined = participants.length === 0
const members = planner.tripMembers as TripMember[]
const { activeMembers, availableMembers } = splitParticipants(members, participantIds, allJoined)
const setParticipants = async (userIds: number[]) => {
if (!assignmentInDay || !planner.selectedDayId) return
await actions.setParticipants(assignmentInDay.id, planner.selectedDayId, userIds)
}
const removeParticipant = (userId: number) => {
void setParticipants(participantsWithout(members, participantIds, allJoined, userId))
}
const addParticipant = (userId: number) => {
void setParticipants(participantsWith(members, participantIds, userId))
setParticipantPickerOpen(false)
}
// Its own files plus the ones on the bookings that hang on it (#2217).
const placeFiles = filesForPlace(
planner.files,
place?.id,
planner.reservations,
assignmentInDay ? [assignmentInDay.id] : [],
)
const handleTrackColor = async (color: string | null) => {
if (!place || isTourPlace) return
try {
await planner.tripActions.updatePlace(planner.tripId, place.id, { route_color: color })
} catch (err: unknown) {
planner.toast.error(translateApiError(t, err, 'common.unknownError'))
}
}
const saveToCollection = () => {
if (!place) return
openSavePicker(placeToSaveTarget(place))
}
// Collaborative rating (#1435): every trip member casts their own star vote.
const handleRate = async (rating: number | null) => {
if (!place) return
await actions.ratePlace(place.id, rating)
}
const showOnMap = () => {
close()
if (shell.trTab !== 'plan') shell.setTrTab('plan')
if (shell.view !== 'map') shell.toggleView()
planner.setFitKey(k => k + 1)
}
// One app installed-and-offered means no picker: the tap opens it, which is
// what this button has always done. The sheet only appears when there is an
// actual choice to make.
const navTargets = getNavigationTargets(place)
const openDirections = () => {
if (navTargets.length === 1) openNavigationTarget(navTargets[0])
else if (navTargets.length > 1) setNavOpen(true)
}
return (
<MSheet open={open} onClose={close} variant="card" form ariaLabel={place?.name}>
{place && (
<>
<div className="flex-none px-[18px] pt-4">
<div className="flex items-start gap-3">
{/* The picture opens the place's photos; it is changed in the editor.
It stands on the same leading edge as the cards below. */}
<div className="flex-none">
<PlacePhotoGallery place={place} language={language} label={t('places.openPhotos')} className="rounded-[16px]">
{place.image_url ? (
<div
className="h-[52px] w-[52px] rounded-[16px] border-[1.5px] border-[color:var(--m-avbr)] bg-cover bg-center"
style={{ backgroundImage: `url('${place.image_url}')` }}
/>
) : (
<div className="flex h-[52px] w-[52px] items-center justify-center rounded-[16px] border-[1.5px] border-[color:var(--m-avbr)] bg-[color:var(--m-ic)]">
<CatIcon size={20} strokeWidth={1.8} className="text-m-muted" />
</div>
)}
</PlacePhotoGallery>
</div>
<div className="min-w-0 flex-1">
<div className="flex items-start gap-1.5">
{/* The sheet is where a place is read in full, so its name wraps
onto as many lines as it needs, as on the desktop (#3140). */}
<span dir="auto" className="min-w-0 break-words text-[1rem] font-bold leading-snug [overflow-wrap:anywhere]">{place.name}</span>
{/* Accepted out of the traveller's own recordings — the same
mark the desktop inspector carries. */}
{place.source === 'dawarich' && (
<span className="mt-[3px] flex-none overflow-hidden rounded-[5px]">
<DawarichIcon size={15} />
</span>
)}
</div>
{/* A tap on the address opens directions, as the navigation button does:
on the road the address is what the eye lands on. */}
{place.address && (
<div
className={`mt-[2px] font-geist text-[0.6875rem] leading-[1.4] text-m-muted${navTargets.length > 0 ? ' cursor-pointer underline decoration-dotted underline-offset-2' : ''}`}
{...(navTargets.length > 0
? {
role: 'button',
tabIndex: 0,
'aria-label': `${navTargets.length === 1 ? navigationTargetLabel(navTargets[0], t) : t('inspector.navigation')}: ${place.address}`,
onClick: openDirections,
onKeyDown: (e: KeyboardEvent) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault()
openDirections()
}
},
}
: {})}
>
<bdi>{place.address}</bdi>
</div>
)}
{/* A typed address that never got coordinates: no marker, and the sheet says why (#2837). */}
{addressWithoutCoordinates(place) && (
<div className="mt-[3px] flex items-center gap-1 text-caption font-semibold text-[color:var(--m-st-pending)]">
<MapPinOff size={12} strokeWidth={2.2} aria-hidden="true" className="flex-none" />
{t('places.noCoordinates')}
</div>
)}
{/* The category under the name and address, as wide as its name:
squeezed under the photo it was cut to "Shoppi…". */}
{category && (
<span className="mt-[6px] inline-flex max-w-full items-center gap-1 rounded-full border border-[color:var(--m-faint)] px-2 py-[2px] font-geist text-[0.625rem] font-semibold text-m-muted">
<CatIcon size={10} strokeWidth={2} className="flex-none" />
<span dir="auto" className="truncate">{category.name}</span>
</span>
)}
<PlTagChips tags={place.tags} />
</div>
<button
type="button"
onClick={close}
aria-label={t('common.close')}
className="flex h-[34px] w-[34px] flex-none items-center justify-center rounded-full bg-[color:var(--m-ic)]"
>
<X size={15} strokeWidth={2.2} />
</button>
</div>
</div>
<FormSheetBody>
{place.phone && (
<a href={`tel:${place.phone}`} className="mt-3 flex items-center gap-[7px] text-[0.78125rem] font-medium">
<Phone size={13} strokeWidth={2} className="flex-none text-m-muted" />
{place.phone}
</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={isTourPlace ? undefined : handleRate} size={18} />
</div>
{place.description && (
<div className={`mt-[10px] rounded-[14px] px-3 py-[10px] ${INNER_CLS}`}>
<MarkdownText className="font-geist text-[0.75rem] leading-[1.5] text-m-muted [overflow-wrap:anywhere]">{place.description}</MarkdownText>
</div>
)}
{place.notes && (
<>
<Eyebrow className="mb-[6px] mt-3 uppercase">{t('mobileTrip.notes')}</Eyebrow>
<div className={`rounded-[14px] px-3 py-[10px] ${INNER_CLS}`}>
<MarkdownText className="font-geist text-[0.75rem] leading-[1.5] text-m-muted [overflow-wrap:anywhere]">{place.notes}</MarkdownText>
</div>
</>
)}
{/* ── Track colour (#776) ── */}
{place.route_geometry && (
<>
<Eyebrow className="mb-[6px] mt-3 uppercase">{t('inspector.trackColor')}</Eyebrow>
<div className={`rounded-[14px] px-3 py-[10px] ${INNER_CLS}`}>
{isTourPlace ? (
<span aria-label={t('inspector.trackColor')} style={{ display: 'block', width: 24, height: 24, borderRadius: 12, background: resolveTrackColor(place) }} />
) : (
<>
<button
type="button"
onClick={() => setColorPickerOpen(v => !v)}
aria-expanded={colorPickerOpen}
className="flex w-full items-center justify-between gap-3"
>
<span className="flex min-w-0 items-center gap-2">
<Route size={14} className="shrink-0 text-m-muted" />
<span className="truncate font-geist text-[0.75rem] font-medium">
{place.route_color ?? t('inspector.trackColorAuto')}
</span>
</span>
<span
className="h-6 w-6 shrink-0 rounded-full ring-1 ring-inset ring-black/10 dark:ring-white/15"
style={{ background: resolveTrackColor(place) }}
/>
</button>
{colorPickerOpen && (
<div className="mt-[10px] border-t border-[color:var(--m-faint)] pt-[10px]">
<TrackColorPicker
value={place.route_color ?? null}
inheritedColor={inheritedTrackColor(place)}
onChange={handleTrackColor}
/>
</div>
)}
</>
)}
</div>
</>
)}
{/* ── Day assignments ── */}
<Eyebrow className="mb-[6px] mt-3 uppercase">{t('mobileTrip.assignedDays')}</Eyebrow>
<div className="flex flex-wrap items-center gap-[6px]">
{placeAssignments.map(({ day, assignment }) => (
<span
key={assignment.id}
className={`flex items-center gap-1 rounded-full py-1 ps-[10px] text-[0.75rem] font-semibold ${INNER_CLS} ${canEditDays ? 'pe-1' : 'pe-[10px]'}`}
>
{canEditDays && unassignedDays.length > 0 ? (
// The day itself moves the stop to another one, keeping its time
// and notes, where removing and adding it again would lose them.
<button
type="button"
onClick={() => { setDayPickerOpen(false); setMovingIds(moving?.assignment.id === assignment.id ? null : { placeId: place.id, assignmentId: assignment.id }) }}
aria-label={t('mobileTrip.moveToDay')}
aria-expanded={moving?.assignment.id === assignment.id}
className="flex items-center gap-1"
>
{dayLabel(day)}
<ArrowLeftRight size={10} strokeWidth={2.4} aria-hidden="true" className="text-m-muted" />
</button>
) : dayLabel(day)}
{canEditDays && !isTourPlace && place.lat != null && place.lng != null && (
// In or out of that day's route (#2532); the icon says which it is.
<button
type="button"
onClick={() => { planner.tripActions.setAssignmentRouteExcluded(planner.tripId, day.id, assignment.id, !assignment.route_excluded).catch((err: unknown) => planner.toast.error(err instanceof Error ? err.message : t('common.unknownError'))) }}
aria-label={assignment.route_excluded ? t('dayplan.includeInRoute') : t('dayplan.excludeFromRoute')}
aria-pressed={!!assignment.route_excluded}
className={`flex h-[18px] w-[18px] items-center justify-center rounded-full ${assignment.route_excluded ? 'bg-m-act text-m-actfg' : 'bg-[color:var(--m-ic)] text-m-muted'}`}
>
<RouteOff size={10} strokeWidth={2.4} />
</button>
)}
{canEditDays && (
<button
type="button"
onClick={() => planner.handleRemoveAssignment(day.id, assignment.id)}
aria-label={t('inspector.removeFromDay')}
className="flex h-[18px] w-[18px] items-center justify-center rounded-full bg-[color:var(--m-ic)] text-m-muted"
>
<X size={10} strokeWidth={2.4} />
</button>
)}
</span>
))}
{canEditDays && unassignedDays.length > 0 && (
<button
type="button"
onClick={() => { setMovingIds(null); setDayPickerOpen(v => !v) }}
aria-label={t('inspector.addToDay')}
aria-expanded={dayPickerOpen}
className="flex h-[26px] w-[26px] items-center justify-center rounded-full border-[1.5px] border-dashed border-[color:var(--m-faint)] text-m-muted"
>
<Plus size={13} strokeWidth={2.2} />
</button>
)}
</div>
{(dayPickerOpen || moving) && (
<div className="mt-[6px] max-h-[180px] overflow-y-auto rounded-[14px] border border-[color:var(--m-rowbr)] bg-[color:var(--m-sheetop)] p-[6px]">
{moving && <Eyebrow className="px-[10px] pb-1 pt-[6px] uppercase">{t('mobileTrip.moveToDay')}</Eyebrow>}
{unassignedDays.map(d => (
<button
key={d.id}
type="button"
onClick={() => {
if (moving) moveToDay(moving, d.id)
else planner.handleAssignToDay(place.id, d.id)
setDayPickerOpen(false)
setMovingIds(null)
}}
className="flex w-full items-center gap-2 rounded-[10px] px-[10px] py-[9px] text-start text-[0.78125rem] font-semibold"
>
<span className="min-w-0 flex-1 truncate">{dayLabel(d)}</span>
{d.date && (
<span className="flex-none font-geist text-[0.65625rem] text-m-faint">
{new Date(`${d.date.slice(0, 10)}T00:00:00Z`).toLocaleDateString(planner.language, { day: 'numeric', month: 'short', timeZone: 'UTC' })}
</span>
)}
</button>
))}
</div>
)}
{/* ── Day-specific notes on the assignments (#2163) — the day label
only appears when the place sits on more than one day. ── */}
{placeAssignments.some(r => r.assignment.notes) && (
<>
<Eyebrow className="mb-[6px] mt-3 uppercase">{t('mobileTrip.assignmentNotes')}</Eyebrow>
<div className="flex flex-col gap-[6px]">
{placeAssignments.filter(r => r.assignment.notes).map(({ day, assignment }) => (
<div key={assignment.id} className={`rounded-[14px] px-3 py-[10px] ${INNER_CLS}`}>
{placeAssignments.length > 1 && (
<div className="mb-[2px] font-geist text-[0.625rem] font-semibold text-m-faint">
{day.title || t('planner.dayN', { n: (day.day_number ?? planner.days.indexOf(day) + 1) || '?' })}
</div>
)}
<div className="whitespace-pre-wrap [overflow-wrap:anywhere] font-geist text-[0.75rem] leading-[1.5] text-m-muted">{assignment.notes}</div>
</div>
))}
</div>
</>
)}
{/* ── The bookings attached to this stop (#2012, #2201) ── */}
{linkedReservations.length > 0 && (
<>
<Eyebrow className="mb-[6px] mt-3 uppercase">{t('reservations.title')}</Eyebrow>
<div className="flex flex-col gap-[6px]">
{linkedReservations.map(res => (
<button
key={res.id}
type="button"
onClick={() => openRes(res)}
disabled={!canOpenRes(res)}
className={`flex w-full items-center gap-2 rounded-[14px] px-3 py-[10px] text-start ${INNER_CLS}`}
>
<span
className="h-2 w-2 flex-none rounded-full"
style={{ background: res.status === 'confirmed' ? 'var(--m-st-confirmed)' : 'var(--m-st-pending)' }}
/>
<span dir="auto" className="min-w-0 flex-1 truncate text-[0.8125rem] font-semibold">{res.title}</span>
<span className="flex-none font-geist text-[0.65625rem] text-m-muted">
{res.status === 'confirmed' ? t('reservations.confirmed') : t('reservations.pending')}
</span>
{canOpenRes(res) && <ChevronRight size={14} strokeWidth={2} className="flex-none text-m-faint" />}
</button>
))}
</div>
</>
)}
{/* ── Participants of the selected day's assignment ── */}
{!isTourPlace && assignmentInDay && members.length > 1 && (
<>
<Eyebrow className="mb-[6px] mt-3 uppercase">{t('inspector.participants')}</Eyebrow>
<div className="flex flex-wrap items-center gap-[6px]">
{activeMembers.map(m => (
<button
key={m.id}
type="button"
onClick={() => { if (activeMembers.length > 1) removeParticipant(m.id) }}
className={`flex items-center gap-[6px] rounded-full p-1 pe-[11px] ${INNER_CLS}`}
>
<span className="flex h-[22px] w-[22px] flex-none items-center justify-center overflow-hidden rounded-full bg-m-act text-[0.625rem] font-bold text-m-actfg">
{(m.avatar_url || m.avatar)
? <img src={m.avatar_url || avatarSrc(m.avatar)!} alt="" className="h-full w-full object-cover" />
: m.username?.[0]?.toUpperCase()}
</span>
<span className="text-[0.75rem] font-semibold">{m.username}</span>
</button>
))}
{availableMembers.length > 0 && (
<button
type="button"
onClick={() => setParticipantPickerOpen(v => !v)}
aria-label={t('common.add')}
aria-expanded={participantPickerOpen}
className="flex h-[26px] w-[26px] items-center justify-center rounded-full border-[1.5px] border-dashed border-[color:var(--m-faint)] text-m-muted"
>
<Plus size={13} strokeWidth={2.2} />
</button>
)}
</div>
{participantPickerOpen && availableMembers.length > 0 && (
<div className="mt-[6px] max-h-[160px] overflow-y-auto rounded-[14px] border border-[color:var(--m-rowbr)] bg-[color:var(--m-sheetop)] p-[6px]">
{availableMembers.map(m => (
<button
key={m.id}
type="button"
onClick={() => addParticipant(m.id)}
className="flex w-full items-center gap-2 rounded-[10px] px-[10px] py-2 text-start text-[0.78125rem] font-semibold"
>
<span className="flex h-[20px] w-[20px] flex-none items-center justify-center overflow-hidden rounded-full bg-[color:var(--m-ic)] text-[0.5625rem] font-bold text-m-muted">
{(m.avatar_url || m.avatar)
? <img src={m.avatar_url || avatarSrc(m.avatar)!} alt="" className="h-full w-full object-cover" />
: m.username?.[0]?.toUpperCase()}
</span>
<span dir="auto" className="min-w-0 flex-1 truncate">{m.username}</span>
</button>
))}
</div>
)}
</>
)}
{/* ── Files ── */}
<div className={`mt-3 rounded-[13px] px-3 py-[9px] ${INNER_CLS}`}>
<div
// Stays a div: the row carries the upload button, which may not
// nest inside another button.
role="button"
tabIndex={0}
aria-expanded={filesExpanded}
className="flex items-center gap-2"
onClick={() => { if (placeFiles.length > 0) setFilesExpanded(v => !v) }}
onKeyDown={e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); if (placeFiles.length > 0) setFilesExpanded(v => !v) } }}
>
<Paperclip size={14} strokeWidth={2} className="flex-none text-m-muted" />
<span className="min-w-0 flex-1 truncate text-[0.78125rem] font-semibold">
{placeFiles.length > 0 ? t('inspector.filesCount', { count: placeFiles.length }) : t('inspector.files')}
</span>
{planner.canUploadFiles && !isTourPlace && (
<button
type="button"
onClick={e => { e.stopPropagation(); fileInputRef.current?.click() }}
disabled={uploading}
className="flex flex-none items-center gap-[5px] rounded-full bg-m-act px-[11px] py-[5px] text-[0.6875rem] font-semibold text-m-actfg disabled:opacity-40"
>
<Upload size={12} strokeWidth={2.2} />
{t('common.upload')}
</button>
)}
</div>
{filesExpanded && placeFiles.length > 0 && (
<div className="mt-2 flex flex-col gap-1">
{placeFiles.map(f => (
<button
key={f.id}
type="button"
onClick={() => openFile(f.url, f.original_name)}
className="flex w-full items-center gap-2 rounded-[10px] bg-[color:var(--m-ic)] px-[10px] py-[7px] text-start"
>
<span dir="auto" className="min-w-0 flex-1 truncate text-[0.75rem] font-medium">{f.original_name}</span>
<ExternalLink size={11} strokeWidth={2} className="flex-none text-m-faint" />
</button>
))}
</div>
)}
</div>
<input ref={fileInputRef} type="file" multiple className="hidden" onChange={handleUpload} />
{/* ── Action row ── */}
<div className="mt-[14px] flex items-center gap-[7px]">
{assistant.available && (
<ActionCircle onClick={() => { close(); assistant.askAbout(place.id) }} label={t('assistant.context.ask')}>
<Sparkles size={15} strokeWidth={2} />
</ActionCircle>
)}
{collectionsEnabled && !isTourPlace && (
<ActionCircle onClick={saveToCollection} label={t('inspector.saveToCollection')}>
<Bookmark size={15} strokeWidth={2} />
</ActionCircle>
)}
{navTargets.length > 0 && (
<>
<ActionCircle
ref={navBtnRef}
onClick={openDirections}
label={navTargets.length === 1 ? navigationTargetLabel(navTargets[0], t) : t('inspector.navigation')}
>
<Navigation size={15} strokeWidth={2} />
</ActionCircle>
{navOpen && (
<NavigationMenu
targets={navTargets}
anchor={navBtnRef.current}
onClose={() => setNavOpen(false)}
title={t('inspector.openWith')}
/>
)}
</>
)}
{place.lat != null && place.lng != null && (
<ActionCircle onClick={showOnMap} label={t('mobileTrip.showOnMap')}>
<MapIcon size={15} strokeWidth={2} />
</ActionCircle>
)}
{safeHttpUrl(place.website) && (
<ActionCircle
onClick={() => window.open(safeHttpUrl(place.website)!, '_blank', 'noopener,noreferrer')}
label={t('inspector.website')}
>
<ExternalLink size={15} strokeWidth={2} />
</ActionCircle>
)}
{canManagePlace && (
<ActionCircle
onClick={() => { planner.openPlaceEditor(place, assignmentInDay?.id ?? null); close() }}
label={t('common.edit')}
primary
className="ms-auto"
>
<Pencil size={15} strokeWidth={2} />
</ActionCircle>
)}
{canManagePlace && (
<ActionCircle
onClick={() => { planner.handleDeletePlace(place.id); close() }}
label={t('common.delete')}
danger
>
<Trash2 size={15} strokeWidth={2} />
</ActionCircle>
)}
</div>
</FormSheetBody>
</>
)}
</MSheet>
)
}