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 TransitJourneyModal from '../../../../components/Planner/TransitJourneyModal'
import BookingImportModal from '../../../../components/Planner/BookingImportModal'
import AirTrailImportModal from '../../../../components/Planner/AirTrailImportModal'
import TourDetailDialog from '../../../../components/Tours/TourDetailDialog'
import { useBookingExpenseEditor } from '../../../../pages/tripPlanner/useBookingExpenseEditor'
import { applyTripCoverUpdate } from '../../../../pages/tripPlanner/tripCover'
import { latestReservation } from '../../../../pages/tripPlanner/transportEditorOpeners'
import { useTourDetailActions } from '../../../../pages/tripPlanner/useTourDetailActions'
import { useIsWide } from '../../../../hooks/sizeClass'
import MConfirmSheet from '../../settings/MConfirmSheet'
import MDayImpactList from '../../../components/MDayImpactList'
import MDaySheet from './MDaySheet'
import MDaysSheet from './MDaysSheet'
import MAccommodationSheet from './MAccommodationSheet'
import MPlaceSheet from './MPlaceSheet'
import MPlaceEditSheet from './MPlaceEditSheet'
import MReservationSheet from './MReservationSheet'
import MTransportFormSheet from './MTransportFormSheet'
import MCostSheet from './MCostSheet'
import MTransportSheet from './MTransportSheet'
import MBrowseActionsSheet from './MBrowseActionsSheet'
import MTourDayChoiceSheet from './MTourDayChoiceSheet'
import MNoteSheet, { type MNoteSheetPayload } from './MNoteSheet'
import MImportSheet from './MImportSheet'
import MExportSheet from './MExportSheet'
import MMehrSheet from './MMehrSheet'
import MTripSettingsSheet from './MTripSettingsSheet'
import MNewTripSheet from '../../dashboard/MNewTripSheet'
import MAssistantScreen from '../assistant/MAssistantScreen'
import MRtStopSheet from '../roadtrip/MRtStopSheet'
import MRtStaySheet from '../roadtrip/MRtStaySheet'
import MRtKindSheet from '../roadtrip/MRtKindSheet'
import MRtInfoSheet from '../roadtrip/MRtInfoSheet'
import MRtTrackSheet from '../roadtrip/MRtTrackSheet'
import MRtCorridorSheet from '../roadtrip/MRtCorridorSheet'
import MRtDraftSheet from '../roadtrip/MRtDraftSheet'
import type { MTripSheetsProps } from '../MTripShell'
import MTourDetailShell from './MTourDetailShell'
import { TourSheetOpen } from './tourSheetOpen'
import { useLastOpen } from '../../../../components/shared/usePresence'
/**
* The one global mobile tour-detail owner, independent of which surface
* selected it. The tour shows in a sheet like every other detail
* (MTourDetailShell); it keeps the tour it showed last while it slides away.
*
* On the phone it reads, and plans the tour onto a day. On an iPad or an
* unfolded Duo it edits what the desktop's tour card edits, through the same
* useTourDetailActions: the name and colour, a copy saved as a new tour, the
* recorded tracks, the packing list it points at and its files.
*/
export function MSelectedTourDetail({ planner }: Pick<MTripSheetsProps, 'planner'>) {
const open = !!(planner.selectedTour && planner.selectedPlace)
const tour = useLastOpen(planner.selectedTour, open)
const place = useLastOpen(planner.selectedPlace, open)
const actions = useTourDetailActions(planner)
const canEdit = useIsWide() && planner.can('place_edit', planner.trip)
if (!tour || !place) return null
return (
<TourSheetOpen.Provider value={{ open, label: place.name }}>
<TourDetailDialog
shell={MTourDetailShell}
tour={tour}
place={place}
days={planner.days}
selectedDayId={planner.selectedDayId}
selectedAssignmentId={planner.selectedAssignmentId}
assignments={planner.assignments}
files={planner.files}
{...(canEdit ? actions : {})}
readOnly={!canEdit}
canEdit={canEdit}
canAssign={planner.can('day_edit', planner.trip)}
onFileUpload={canEdit && planner.canUploadFiles ? (fd: FormData) => planner.tripActions.addFile(planner.tripId, fd) : undefined}
onClose={() => planner.setSelectedPlaceId(null)}
onAssignToDay={planner.handleAssignToDay}
onRemoveAssignment={planner.handleRemoveAssignment}
/>
</TourSheetOpen.Provider>
)
}
/**
* Sheet host of the mobile trip screen — always mounted below the shell. Two
* families live here: the mobile sheets routed via shell.sheet (day, days,
* transport, bract, note, import, export, mehr — the place inspector keys off
* the planner's place selection instead), and the planner-flag editors that
* every entry point (?create=, import review, timeline, map long-press) opens
* through useTripPlanner state. The transport/booking/transit/import
* editors reuse the shared desktop modals until they get mobile counterparts;
* they carry the full behaviour (undo, WS sync, review flow) unchanged. Trip edit and
* the trip settings have phone sheets of their own.
*/
export default function MTripSheets({ planner, shell }: MTripSheetsProps) {
const { t, toast, tripId, trip, tripActions } = planner
const sheet = shell.sheet
// Booking-linked expense editor (save-then-open from the booking modals) —
// same page-level wiring as the desktop planner.
const { meId, costsBase, openBookingExpense, expenseEditor, onExpenseSaved } = useBookingExpenseEditor({
tripId, tripCurrency: trip?.currency, receiptExpense: planner.receiptExpense, clearReceiptExpense: planner.clearReceiptExpense,
})
return (
<>
{/* ── Mobile sheets (shell.sheet routing + the place selection) ── */}
<MPlaceSheet planner={planner} shell={shell} />
<MSelectedTourDetail planner={planner} />
<MDaySheet planner={planner} shell={shell} />
<MDaysSheet planner={planner} shell={shell} />
<MAccommodationSheet planner={planner} shell={shell} />
<MTransportSheet planner={planner} shell={shell} />
<MBrowseActionsSheet planner={planner} shell={shell} />
<MMehrSheet planner={planner} shell={shell} />
{/* The assistant's full-screen chat, mounted with the trip so it keeps going while the map is up. */}
<MAssistantScreen planner={planner} shell={shell} />
{/* The stage's own sheets. Each one checks shell.sheet?.id itself, the draft
sheet hangs off planner.stopDraft the way the place editor hangs off its flag. */}
<MRtStopSheet planner={planner} shell={shell} />
<MRtStaySheet planner={planner} shell={shell} />
<MRtKindSheet planner={planner} shell={shell} />
<MRtInfoSheet planner={planner} shell={shell} />
<MRtTrackSheet planner={planner} shell={shell} />
{/* Before the draft sheet, not after: both sit at the same z, so the one mounted
later paints on top, and taking a hit onto the trip opens the draft OVER the
search it came from. */}
<MRtCorridorSheet planner={planner} shell={shell} />
<MRtDraftSheet planner={planner} />
<MExportSheet planner={planner} shell={shell} />
<MNoteSheet
planner={planner}
open={sheet?.id === 'note'}
payload={sheet?.id === 'note' ? (sheet.payload as MNoteSheetPayload) : undefined}
onClose={shell.closeSheet}
/>
<MImportSheet planner={planner} open={sheet?.id === 'import'} onClose={shell.closeSheet} />
{/* ── Planner-flag editors (also serve ?create= and the import review) ── */}
<MPlaceEditSheet planner={planner} onOpenExpense={openBookingExpense} />
<MReservationSheet planner={planner} onOpenExpense={openBookingExpense} />
<MTransportFormSheet planner={planner} onOpenExpense={openBookingExpense} />
{/* Journey view for a saved public-transit entry (#1065) */}
{planner.transitJourney && (
<TransitJourneyModal
reservation={planner.reservations.find(r => r.id === planner.transitJourney!.id) ?? planner.transitJourney}
canEdit={planner.can('day_edit', trip)}
onClose={() => planner.setTransitJourney(null)}
onSave={async (fields) => {
await tripActions.updateReservation(tripId, planner.transitJourney!.id, fields)
planner.setTransitJourney(null)
}}
onDelete={async () => {
await planner.handleDeleteReservation(planner.transitJourney!.id)
planner.setTransitJourney(null)
}}
// Re-enter the transit search seeded with this journey's route; the
// existing reservation is replaced on save.
onChangeRoute={() => planner.changeTransitRoute(planner.transitJourney!)}
// Hand off to the full transport editor for the booking fields, the same
// target as the transports tab's pencil (#2148). The store copy may be newer.
onEditDetails={() => planner.openTransportEditor(latestReservation(planner.reservations, planner.transitJourney!))}
/>
)}
{expenseEditor && (
<MCostSheet
key={expenseEditor.key}
tripId={tripId}
base={costsBase}
people={planner.tripMembers}
me={meId}
editing={expenseEditor.editing}
prefill={expenseEditor.prefill}
onClose={expenseEditor.close}
onSaved={onExpenseSaved}
/>
)}
<BookingImportModal isOpen={planner.showBookingImport} onClose={() => planner.setShowBookingImport(false)} tripId={tripId} kind={planner.bookingImportKind} />
<AirTrailImportModal isOpen={planner.showAirTrailImport} onClose={() => planner.setShowAirTrailImport(false)} tripId={tripId} pushUndo={planner.pushUndo} />
{/* Trip edit + share/members, opened from the Mehr sheet. */}
<MNewTripSheet
open={sheet?.id === 'tripedit'}
trip={trip}
onClose={shell.closeSheet}
onSave={async (data) => {
await tripActions.updateTrip(tripId, data)
toast.success(t('trip.toast.tripUpdated'))
}}
onCoverUpdate={applyTripCoverUpdate}
/>
<MTripSettingsSheet
open={sheet?.id === 'members'}
onClose={shell.closeSheet}
tripId={tripId}
tripTitle={trip?.title}
onMembersChanged={planner.refreshMembers}
/>
{/* Delete-place confirm behind handleDeletePlace (the place edit sheet
arms the same flag for its own two-tap delete — skip it there).
A night booked at the place goes down with it, and with the night
the booking and its expense: the planner adds that as a second
sentence, the same one the desktop question carries. */}
<MConfirmSheet
open={planner.deletePlaceId != null && !planner.showPlaceForm}
onClose={() => planner.setDeletePlaceId(null)}
title={t('common.delete')}
message={planner.deletePlaceId != null && planner.isTourPlace(planner.deletePlaceId) ? (
<>
<span className="block">{t('tours.delete.confirmBody')}</span>
{planner.deletePlaceNote && <span className="mt-1 block">{planner.deletePlaceNote}</span>}
</>
) : planner.deletePlaceNote ? (
<>
<span className="block">{t('trip.confirm.deletePlace')}</span>
<span className="mt-1 block">{planner.deletePlaceNote}</span>
</>
) : t('trip.confirm.deletePlace')}
confirmLabel={planner.deletePlaceId != null && planner.isTourPlace(planner.deletePlaceId)
? t('tours.delete.confirmAction') : t('common.delete')}
cancelLabel={t('common.cancel')}
danger
onConfirm={() => {
void planner.confirmDeletePlace()
planner.setDeletePlaceId(null)
}}
/>
{/* Clear-day confirm behind the day sheet's "Clear day" (#2470). */}
<MConfirmSheet
open={planner.clearDayId != null}
onClose={planner.cancelClearDay}
title={planner.clearDayTitle}
message={t('dayplan.clearDayBody')}
confirmLabel={t('dayplan.clearDay')}
cancelLabel={t('common.cancel')}
danger
onConfirm={() => { void planner.confirmClearDay() }}
/>
{/* Delete-day confirm behind the days sheet's delete buttons. Mounted
last, so it opens over that sheet; the list of what goes with the day
comes ready made from the planner, the same one the desktop shows. */}
<MConfirmSheet
open={planner.deleteDayId != null}
onClose={() => planner.setDeleteDayId(null)}
title={planner.deleteDayTitle}
message={t('dayplan.deleteDayBody')}
confirmLabel={t('dayplan.deleteDay')}
cancelLabel={t('common.cancel')}
danger
onConfirm={() => { void planner.confirmDeleteDay() }}
>
<MDayImpactList lines={planner.deleteDayLines} label={planner.deleteDayTitle} />
</MConfirmSheet>
{/* A multi-day tour put on a day: whole, or a stage a day from it on (MDT-02). Over the sheet it came from. */}
<MTourDayChoiceSheet question={planner.tourDayQuestion} onAnswer={planner.answerTourDay} />
</>
)
}