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 { Download, FileText, type LucideIcon, Pencil, Trash2 } from 'lucide-react';
import type { useReservationCard } from '../../../../components/Planner/bookings/useReservationCard';
import type { useTranslation } from '../../../../i18n';
import type { Reservation } from '../../../../types';
import type { filesFor } from '../../../../utils/reservationFiles';
import MConfirmSheet from '../../settings/MConfirmSheet';
import { ConfirmationCode, Field } from './tabChrome';
/**
* Pieces of the phone reservation card that the transports and bookings tabs
* draw the same way. Each tab keeps its own card and decides what a tap does
* (the transports tab opens the detail sheet, the bookings tab the edit modal);
* these only paint the shared markup.
*/
type T = ReturnType<typeof useTranslation>['t'];
type CardState = ReturnType<typeof useReservationCard>;
/**
* Header button: title, type pill and the needs-review badge. The title takes
* the line first and may run to a second one; where it and the pills do not
* fit side by side, the pills move under it rather than squeezing the title
* down to a few letters ("Hotel The Celestine Kyot…"). On a wide window they
* always stand under it, so the cards side by side in a row keep headers of
* one height and their date rows on one line.
*/
export function CardTitleButton({
res,
TypeIcon,
typeColor,
onOpen,
t,
}: {
res: Reservation;
TypeIcon: LucideIcon;
typeColor: string;
onOpen: () => void;
t: T;
}) {
return (
<button
type="button"
onClick={onOpen}
className="flex min-w-0 flex-1 flex-wrap items-center gap-x-[7px] gap-y-1 text-start"
>
<span
dir="auto"
className="line-clamp-2 min-w-0 flex-[1_1_auto] break-words text-[0.78125rem] font-bold text-m-ink wide:basis-full"
>
{res.title}
</span>
<span className="inline-flex flex-none items-center gap-1 rounded-full border border-[color:var(--m-rowbr)] bg-m-card px-2 py-[2px] font-geist text-[0.5625rem] font-bold uppercase tracking-[.06em] text-m-muted">
<TypeIcon size={10} strokeWidth={2.2} style={{ color: typeColor }} />
{t(`reservations.type.${res.type}`)}
</span>
{!!res.needs_review && (
<span className="flex-none rounded-full bg-[rgba(232,161,58,.16)] px-2 py-[2px] font-geist text-[0.5rem] font-bold uppercase tracking-[.03em] text-[color:var(--m-st-pending)]">
{t('reservations.needsReview')}
</span>
)}
</button>
);
}
/** Round edit and delete buttons at the end of the header. */
export function CardActions({ onEdit, onDelete, t }: { onEdit: () => void; onDelete: () => void; t: T }) {
return (
<>
<button
type="button"
onClick={onEdit}
aria-label={t('common.edit')}
className="flex h-[26px] w-[26px] flex-none items-center justify-center rounded-full bg-[color:var(--m-ic)] text-m-muted"
>
<Pencil size={12} strokeWidth={2} />
</button>
<button
type="button"
onClick={onDelete}
aria-label={t('common.delete')}
className="flex h-[26px] w-[26px] flex-none items-center justify-center rounded-full bg-[color:var(--m-ic)] text-m-muted"
>
<Trash2 size={12} strokeWidth={2} />
</button>
</>
);
}
/**
* Date and time row, followed by the booking code. The code sits outside the
* row button so its reveal can be its own control. The calendar date never
* shrinks; a long day title is cut instead, and a day range takes the full
* width with the time under it.
*/
export function CardWhenAndCode({
dayValue,
dayDate = null,
dayRange = false,
timeValue,
code,
card,
onOpen,
t,
}: {
dayValue: string;
dayDate?: string | null;
dayRange?: boolean;
timeValue: string;
code: string | null | undefined;
card: CardState;
onOpen: () => void;
t: T;
}) {
return (
<>
<button type="button" onClick={onOpen} className="block w-full text-start">
<div className={`flex gap-2 ${dayRange ? 'flex-col' : ''}`}>
<Field label={t('reservations.date')} className="flex-[1.4]">
{dayDate ? (
<span className="flex min-w-0 items-center justify-center gap-1.5">
<span dir="auto" className="min-w-0 truncate">
{dayValue}
</span>
<span className="flex-none font-medium text-m-faint">{dayDate}</span>
</span>
) : (
dayValue
)}
</Field>
{/* The time is never cut: a range keeps its end (the date gives way first). */}
<Field label={t('reservations.time')} className="flex-1" tabular fit>
{timeValue}
</Field>
</div>
</button>
{code && (
<ConfirmationCode
code={code}
label={t('reservations.confirmationCode')}
blurred={card.codeBlurred}
onToggle={card.toggleCode}
/>
)}
</>
);
}
/**
* The booking's notes, inside the card body button. A transport card on the phone
* never showed them, so notes typed into a flight were nowhere to be read
* (reported on Discord, 15.10.2026); both cards now take them from here.
*/
export function CardNotes({ notes }: { notes: string | null | undefined }) {
if (!notes?.trim()) return null;
return (
<div className="mt-2 rounded-[10px] border border-[color:var(--m-rowbr)] bg-m-card px-[10px] py-2">
<p className="whitespace-pre-wrap font-geist text-caption leading-[1.5] text-m-muted [overflow-wrap:anywhere]">
{notes}
</p>
</div>
);
}
/**
* Attached files, under the card body button rather than inside it, so each row
* can hold two real buttons: the name opens the file, the icon at the end saves
* it (a PDF ticket that only opens in a viewer cannot be kept otherwise).
*/
export function CardFiles({
files,
card,
t,
}: {
files: ReturnType<typeof filesFor>;
card: Pick<CardState, 'openFile' | 'downloadFile'>;
t: T;
}) {
if (files.length === 0) return null;
return (
<div className="mt-2">
<div className="mb-[3px] font-geist text-[0.5625rem] font-bold uppercase tracking-[.08em] text-m-faint">
{t('files.title')}
</div>
<div className="flex flex-col gap-1">
{files.map((f) => (
<div
key={f.id}
className="flex items-stretch overflow-hidden rounded-[10px] border border-[color:var(--m-rowbr)] bg-m-card"
>
<button
type="button"
onClick={() => card.openFile(f)}
className="flex min-w-0 flex-1 items-center gap-[6px] py-[7px] pe-1 ps-[10px] text-start"
>
<FileText size={12} strokeWidth={2} className="flex-none text-m-muted" />
<span dir="auto" className="truncate font-geist text-[0.65625rem] font-semibold text-m-muted">
{f.original_name}
</span>
</button>
<button
type="button"
onClick={() => card.downloadFile(f)}
aria-label={`${t('files.download')}: ${f.original_name}`}
className="grid w-9 flex-none place-items-center text-m-muted"
>
<Download size={13} strokeWidth={2} />
</button>
</div>
))}
</div>
</div>
);
}
/** Confirmation sheet behind the delete button. */
export function CardDeleteSheet({ title, card, t }: { title: string; card: CardState; t: T }) {
return (
<MConfirmSheet
open={card.confirmingDelete}
onClose={card.cancelDelete}
title={t('reservations.confirm.deleteTitle')}
message={t(
card.deleteTakesExpense ? 'reservations.confirm.deleteBodyWithExpense' : 'reservations.confirm.deleteBody',
{ name: title }
)}
confirmLabel={t('common.delete')}
cancelLabel={t('common.cancel')}
danger
onConfirm={card.confirmDelete}
/>
);
}