mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 02:14:05 +00:00
fix(planner): show rating alongside stop participants
This commit is contained in:
@@ -48,7 +48,7 @@ import LinkedBookingCard from './PlaceLinkedBookingCard'
|
||||
import { usePlaceLanguage } from '../../hooks/usePlaceLanguage'
|
||||
import { participantsWith, participantsWithout, splitParticipants, usePlaceFileUpload } from './usePlaceActions'
|
||||
|
||||
const DETAIL_GRID = 'grid min-w-0 flex-none grid-cols-[repeat(auto-fit,minmax(min(100%,208px),1fr))] items-start gap-3'
|
||||
const DETAIL_GRID = 'grid min-w-0 flex-none grid-cols-[repeat(auto-fit,minmax(min(100%,208px),1fr))] gap-3'
|
||||
const detailsCache = new Map()
|
||||
|
||||
function getSessionCache(key) {
|
||||
@@ -364,6 +364,10 @@ export default function PlaceInspector({
|
||||
const phone = place.phone || googleDetails?.phone
|
||||
const description = place.description || googleDetails?.summary
|
||||
const showRating = (mode === 'trip' && !!onRate) || !!shortReview
|
||||
const showParticipants = mode === 'trip' && !!selectedAssignmentId && tripMembers.length > 1
|
||||
const participantIds = assignmentInDay?.id === selectedAssignmentId
|
||||
? assignmentInDay?.participants?.map(participant => participant.user_id) ?? []
|
||||
: []
|
||||
const mapCard = centredMapCard(leftWidth, rightWidth, { clearPill: clearMapPill })
|
||||
|
||||
return (
|
||||
@@ -391,7 +395,7 @@ export default function PlaceInspector({
|
||||
|
||||
{/* The body scrolls inside the capped card; each block keeps its natural height (#1195). */}
|
||||
<div data-testid="inspector-scroll" className={`trek-desktop-panel trek-place-inspector-body ${collapsed ? 'hidden' : 'flex'} min-h-0 flex-1 flex-col gap-3 overflow-y-auto overscroll-contain bg-surface-card px-4 py-3 empty:hidden`}>
|
||||
{(showRating || roadtripEndDay || roadtripStay) && (
|
||||
{(showRating || showParticipants) && (
|
||||
<div className={DETAIL_GRID}>
|
||||
{showRating && (
|
||||
<DialogSection icon={Star} className={mode === 'trip' && onRate ? undefined : 'hidden md:block'} label={t('places.details.fact.rating')}>
|
||||
@@ -407,7 +411,15 @@ export default function PlaceInspector({
|
||||
</div>
|
||||
</DialogSection>
|
||||
)}
|
||||
{(roadtripEndDay || roadtripStay) && <VisitControls endDay={roadtripEndDay} stay={roadtripStay} />}
|
||||
{showParticipants && (
|
||||
<ParticipantsBox tripMembers={tripMembers} participantIds={participantIds} allJoined={participantIds.length === 0}
|
||||
onSetParticipants={onSetParticipants} selectedAssignmentId={selectedAssignmentId} selectedDayId={selectedDayId} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{(roadtripEndDay || roadtripStay) && (
|
||||
<div className={`${DETAIL_GRID} items-start`}>
|
||||
<VisitControls endDay={roadtripEndDay} stay={roadtripStay} />
|
||||
</div>
|
||||
)}
|
||||
{roadtripActive && place.stop_type === 'charging' && <ChargingInfo placeId={place.id} />}
|
||||
@@ -419,7 +431,7 @@ export default function PlaceInspector({
|
||||
)}
|
||||
|
||||
{(place.notes || assignmentInDay?.notes) && (
|
||||
<div className={DETAIL_GRID}>
|
||||
<div className={`${DETAIL_GRID} items-start`}>
|
||||
{place.notes && (
|
||||
<DialogSection icon={NotebookPen} label={t('places.formNotes')}>
|
||||
<MarkdownBox>{place.notes}</MarkdownBox>
|
||||
@@ -433,11 +445,9 @@ export default function PlaceInspector({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Bookings + participants — trip-only (collections have no days) */}
|
||||
{mode === 'trip' && (
|
||||
<PlaceBookingsAndPeople selectedAssignmentId={selectedAssignmentId} placeId={place.id} reservations={reservations}
|
||||
assignments={assignments} selectedDayId={selectedDayId} tripMembers={tripMembers}
|
||||
timeFormat={timeFormat} onSetParticipants={onSetParticipants}
|
||||
<PlaceBookings selectedAssignmentId={selectedAssignmentId} placeId={place.id} reservations={reservations}
|
||||
timeFormat={timeFormat}
|
||||
onEditTransport={onEditTransport} onEditReservation={onEditReservation} onOpenBooking={onOpenBooking} />
|
||||
)}
|
||||
|
||||
@@ -570,64 +580,32 @@ function MarkdownBox({ children }: { children: string }) {
|
||||
)
|
||||
}
|
||||
|
||||
interface PlaceBookingsAndPeopleProps {
|
||||
interface PlaceBookingsProps {
|
||||
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) {
|
||||
/** The bookings pinned to this stop. */
|
||||
function PlaceBookings({ selectedAssignmentId, placeId, reservations, timeFormat,
|
||||
onEditTransport, onEditReservation, onOpenBooking }: PlaceBookingsProps) {
|
||||
const { t } = useTranslation()
|
||||
const linked = getPlaceBookings<Reservation>(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
|
||||
if (linked.length === 0) return null
|
||||
return (
|
||||
<div className={DETAIL_GRID}>
|
||||
{/* Bookings pinned to this stop; several can share one (#2201) */}
|
||||
{linked.length > 0 && (
|
||||
<DialogSection icon={Ticket} label={t('reservations.title')}>
|
||||
<div className="flex flex-col gap-2">
|
||||
{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 <LinkedBookingCard key={res.id} res={res} timeFormat={timeFormat} open={() => onOpenBooking(res)} opens="detail" />
|
||||
const editor = TRANSPORT_TYPES.has(res.type) ? onEditTransport : onEditReservation
|
||||
return <LinkedBookingCard key={res.id} res={res} timeFormat={timeFormat} open={editor ? () => editor(res) : undefined} />
|
||||
})}
|
||||
</div>
|
||||
</DialogSection>
|
||||
)}
|
||||
|
||||
{showParticipants && (
|
||||
<ParticipantsBox
|
||||
tripMembers={tripMembers}
|
||||
participantIds={participantIds}
|
||||
allJoined={allJoined}
|
||||
onSetParticipants={onSetParticipants}
|
||||
selectedAssignmentId={selectedAssignmentId}
|
||||
selectedDayId={selectedDayId}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<DialogSection icon={Ticket} className="flex-none" label={t('reservations.title')}>
|
||||
<div className="flex flex-col gap-2">
|
||||
{linked.map(res => {
|
||||
if (onOpenBooking) return <LinkedBookingCard key={res.id} res={res} timeFormat={timeFormat} open={() => onOpenBooking(res)} opens="detail" />
|
||||
const editor = TRANSPORT_TYPES.has(res.type) ? onEditTransport : onEditReservation
|
||||
return <LinkedBookingCard key={res.id} res={res} timeFormat={timeFormat} open={editor ? () => editor(res) : undefined} />
|
||||
})}
|
||||
</div>
|
||||
</DialogSection>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -890,7 +868,7 @@ function PlaceExtras({ openingHours, weekdayIndex, hoursExpanded, setHoursExpand
|
||||
const showFiles = placeFiles.length > 0 || !!onFileUpload
|
||||
const trackColor = resolveTrackColor(place)
|
||||
return (
|
||||
<div className={place.route_geometry ? 'grid flex-none gap-3' : `${DETAIL_GRID} empty:hidden`}>
|
||||
<div className={place.route_geometry ? 'grid flex-none gap-3' : `${DETAIL_GRID} items-start empty:hidden`}>
|
||||
{hasHours && (
|
||||
<DialogSection icon={Clock} label={t('inspector.openingHours')}>
|
||||
<div className={`${BOX} relative`}>
|
||||
|
||||
Reference in New Issue
Block a user