{/* Collaborative rating (#1435): every member's own vote, shown as the
average, and the first review worth quoting. */}
{showRating && (
// The review alone is a desktop extra, as it always was; without the vote row the block goes with it below md.
{mode === 'trip' && onRate && (
onRate(place.id, rating)} />
)}
{shortReview && (
„{shortReview.text}"
)}
)}
{roadtripActive && place.stop_type === 'charging' && }
{(roadtripEndDay || roadtripStay) && }
{description && (
{description}
)}
{place.notes && (
{place.notes}
)}
{/* Day-specific assignment note (#2163) — written via MCP/API or the
edit form; distinct from the pool-wide place.notes above, so its
label says which day-scope it belongs to. */}
{assignmentInDay?.notes && (
{assignmentInDay.notes}
)}
{/* Bookings + participants — trip-only (collections have no days) */}
{mode === 'trip' && (
)}
{/* Extra native rows from placeDetailProvider plugins (#1429). */}
{mode === 'trip' && providerDetails.length > 0 && (
{placeDetailPlugins.map((p) => {
const tid = (place as { trip_id?: number | string }).trip_id
return (
)
})}
)}
{/* Footer: the day action and the ways out on the left, delete and edit on the right. */}
)
}
/** Markdown in a framed box; it wraps long words instead of pushing the card wider. */
function MarkdownBox({ children }: { children: string }) {
return (
{children}
)
}
interface InspectorHeadProps {
place: Place
category: Category | undefined
openNow: boolean | null
phone: string | null | undefined
/** Typed in by hand (#2472); there is no looked-up one. */
email?: string | null
rating: number | null
ratingCount: number | null
price: string | null
time: string | null
editingName: boolean
nameInputRef: React.RefObject
nameValue: string
setNameValue: (value: string) => void
commitNameEdit: () => void
handleNameKeyDown: (e: React.KeyboardEvent) => void
startNameEdit: () => void
onUpdatePlace?: (placeId: number, data: Partial) => void
onUploadImage?: (placeId: number, file: File) => Promise
attachedImages: TripFile[]
onImageFromFile?: (placeId: number, fileId: number) => Promise
onClose: () => void
}
/**
* The head band: the avatar with its open/closed ring and photo credit, the
* name (a double-click renames it), the address, and the facts as pills.
*/
function InspectorHead({ place, category, openNow, phone, email, rating, ratingCount, price, time, editingName, nameInputRef,
nameValue, setNameValue, commitNameEdit, handleNameKeyDown, startNameEdit, onUpdatePlace, onUploadImage, attachedImages, onImageFromFile, onClose }: InspectorHeadProps) {
const { t, locale } = useTranslation()
const ring = openNow === true ? 'bg-success' : openNow === false ? 'bg-danger' : 'bg-surface-card shadow-sm'
const hasCoords = !!(place.lat && place.lng)
const hasPills = openNow !== null || !!category || !!time || rating != null || !!price || place.source === 'dawarich' || !!phone || !!email || hasCoords
return (
)}
{place.address && (
// One line, whatever its length; the whole address is in the tooltip.
{place.address}
)}
{hasPills && (
{openNow !== null && (
}>
{openNow ? t('inspector.opened') : t('inspector.closed')}
)}
{category && (
{category.name}
)}
{time && {time}}
{rating != null && rating > 0 && (
{rating.toFixed(1)}
{ratingCount ? ({ratingCount.toLocaleString(locale)}) : null}
)}
{price && (
{price}
)}
{/* Where the place came from, when it did not come from somebody
typing it: a stay accepted out of their own recordings. The mark
alone — the name beside it is already the place's name, and a
word here would only repeat the tooltip. */}
{place.source === 'dawarich' && (
)}
{phone && (
{phone}
)}
{email && (
{email}
)}
{hasCoords && (
{Number(place.lat).toFixed(6)}, {Number(place.lng).toFixed(6)}
)}
)}
)
}
interface PlaceBookingsAndPeopleProps {
selectedAssignmentId: number | null
placeId: number
reservations: Reservation[]
assignments: AssignmentsMap
selectedDayId: number | null
tripMembers: TripMember[]
timeFormat: string
onSetParticipants?: (assignmentId: number, dayId: number, participantIds: number[]) => void
onEditTransport?: (reservation: Reservation) => void
onEditReservation?: (reservation: Reservation) => void
onOpenBooking?: (reservation: Reservation) => void
}
/** The bookings pinned to this stop and who joins it, side by side from sm up. */
function PlaceBookingsAndPeople({ selectedAssignmentId, placeId, reservations, assignments, selectedDayId,
tripMembers, timeFormat, onSetParticipants, onEditTransport, onEditReservation, onOpenBooking }: PlaceBookingsAndPeopleProps) {
const { t } = useTranslation()
const linked = getPlaceBookings(reservations, selectedAssignmentId, placeId)
const assignment = selectedAssignmentId ? (assignments[String(selectedDayId)] || []).find(a => a.id === selectedAssignmentId) : null
const currentParticipants = assignment?.participants || []
const participantIds = currentParticipants.map(p => p.user_id)
const allJoined = currentParticipants.length === 0
const showParticipants = !!selectedAssignmentId && tripMembers.length > 1
if (linked.length === 0 && !showParticipants) return null
return (
0 && showParticipants ? 'grid-cols-1 sm:grid-cols-2' : 'grid-cols-1'}`}>
{/* Bookings pinned to this stop; several can share one (#2201) */}
{linked.length > 0 && (
{linked.map(res => {
// The strip summarised the booking but went nowhere, so its
// attachments and fields had no route from the map (#2012).
// A transport has its own form; picking by type is what the day
// sidebar does, and an absent handler means this user may not
// open this one, so the strip stays inert rather than lying.
// With a detail to show, the card is the booking itself and opens it;
// the editor is one Edit further, under the same rights as before.
if (onOpenBooking) return onOpenBooking(res)} opens="detail" />
const editor = TRANSPORT_TYPES.has(res.type) ? onEditTransport : onEditReservation
return editor(res) : undefined} />
})}
)}
{showParticipants && (
)}
)
}
/** The facts of a booking's metadata that the card has no field for, one pill each. */
function bookingMetaParts(res: Reservation, t: (key: string) => string): string[] {
const meta = parseMeta(res)
const parts: string[] = []
if (meta.airline && meta.flight_number) parts.push(`${meta.airline} ${meta.flight_number}`)
else if (meta.flight_number) parts.push(meta.flight_number)
if (meta.departure_airport && meta.arrival_airport) parts.push(`${meta.departure_airport} → ${meta.arrival_airport}`)
if (meta.train_number) parts.push(meta.train_number)
if (meta.platform) parts.push(`${t('reservations.meta.platform')} ${meta.platform}`)
if (meta.check_in_time) parts.push(`${t('reservations.meta.checkIn')} ${meta.check_in_time}`)
if (meta.check_out_time) parts.push(`${t('reservations.meta.checkOut')} ${meta.check_out_time}`)
return parts
}
/**
* A booking on this stop as a small booking card: the head band tinted by its
* status, then its date, time and code as fields. With `open` it opens the
* booking's detail or its editor (`opens`) on a click, Enter or Space; without
* it the card is a read-only summary.
*/
function LinkedBookingCard({ res, timeFormat, open, opens = 'editor' }: { res: Reservation; timeFormat: string; open?: () => void; opens?: 'detail' | 'editor' }) {
const { t, locale } = useTranslation()
const openLabel = t(opens === 'detail' ? 'roadtrip.ride.open' : 'inspector.editRes')
// A stop can carry several bookings (#2201), so a card that opens its booking is
// named by it; the editor's card keeps its old name.
const cardName = opens === 'detail' ? `${openLabel}: ${res.title}` : openLabel
const OpenGlyph = opens === 'detail' ? ChevronRight : Pencil
const confirmed = res.status === 'confirmed'
const { date, time: startTime } = splitReservationDateTime(res.reservation_time)
const { time: endTime } = splitReservationDateTime(res.reservation_end_time)
const metaParts = bookingMetaParts(res, t)
const hasFields = !!(date || startTime || endTime || res.confirmation_number)
const card = (
)
}
/**
* Track colour (#776) — only for places that carry GPX geometry. Sits next
* to the stats block rather than inside it: that block bails out on unparsable
* geometry, and the colour control has no business disappearing with it.
*/
function TrackColorRow({ place, trackColor, onUpdatePlace }: { place: Place; trackColor: string; onUpdatePlace?: (placeId: number, data: Partial) => void }) {
const { t } = useTranslation()
const [open, setOpen] = useState(false)
return (
{open && (
onUpdatePlace?.(place.id, { route_color: color })}
/>
)}
)
}
interface TrackStats {
distKm: number
hasEle: boolean
minEle: number
maxEle: number
totalUp: number
totalDown: number
/** The elevation profile as an SVG path in a CHART_W × CHART_H box, empty without elevations. */
pathD: string
}
const CHART_W = 280
const CHART_H = 60
/** Distance, elevation extremes, climb and descent of a GPX track, or null when it cannot be read. */
function computeTrackStats(routeGeometry: string): TrackStats | null {
try {
const pts: number[][] = JSON.parse(routeGeometry)
if (!pts || pts.length < 2) return null
const hasEle = pts[0].length >= 3
// Haversine distance
const toRad = (d: number) => d * Math.PI / 180
let totalDist = 0
for (let i = 1; i < pts.length; i++) {
const [lat1, lng1] = pts[i - 1], [lat2, lng2] = pts[i]
const dLat = toRad(lat2 - lat1), dLng = toRad(lng2 - lng1)
const a = Math.sin(dLat / 2) ** 2 + Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) * Math.sin(dLng / 2) ** 2
totalDist += 6371000 * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
}
// Elevation stats
let minEle = Infinity, maxEle = -Infinity, totalUp = 0, totalDown = 0
if (hasEle) {
for (let i = 0; i < pts.length; i++) {
const e = pts[i][2]
if (e < minEle) minEle = e
if (e > maxEle) maxEle = e
if (i > 0) {
const diff = e - pts[i - 1][2]
if (diff > 0) totalUp += diff; else totalDown += Math.abs(diff)
}
}
}
// Elevation profile
const elevations = hasEle ? pts.map(p => p[2]) : []
let pathD = ''
if (elevations.length > 1) {
const step = Math.max(1, Math.floor(elevations.length / CHART_W))
const sampled = elevations.filter((_, i) => i % step === 0)
const eMin = Math.min(...sampled), eMax = Math.max(...sampled)
const range = eMax - eMin || 1
pathD = sampled.map((e, i) => {
const x = (i / (sampled.length - 1)) * CHART_W
const y = CHART_H - ((e - eMin) / range) * (CHART_H - 4) - 2
return `${i === 0 ? 'M' : 'L'}${x.toFixed(1)},${y.toFixed(1)}`
}).join(' ')
}
return { distKm: totalDist / 1000, hasEle, minEle, maxEle, totalUp, totalDown, pathD }
} catch { return null }
}
function TrackStatsSection({ place, trackColor, distanceUnit }: { place: Place; trackColor: string; distanceUnit: DistanceUnit }) {
const { t } = useTranslation()
const stats = computeTrackStats(place.route_geometry)
if (!stats) return null
return (