import type { TripSummary } from "../lib/types"; function formatDate(d: string) { const date = new Date(d + "T12:00:00"); return date.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" }); } function TripCard({ trip, onSelect }: { trip: TripSummary; onSelect: () => void }) { const dateRange = trip.dates.length === 1 ? formatDate(trip.dates[0]) : `${formatDate(trip.dates[0])} — ${formatDate(trip.dates[trip.dates.length - 1])}`; return (
{trip.title}
{trip.subtitle}
{dateRange} {trip.travelers.length > 0 && <> {trip.travelers.join(", ")} }
{trip.notes &&
{trip.notes}
}
); } export function TripIndex({ trips, onSelect }: { trips: TripSummary[]; onSelect: (id: string) => void; }) { return (

Trips

{trips.length === 0 && (
No trips yet.
)}
{trips.map(t => ( onSelect(t.id)} /> ))}
); }