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 { useState, useEffect } from 'react'
import { MapPin, Clock, Pencil, Trash2, Plus, PencilLine, RouteOff, X } from 'lucide-react'
import { formatLocationName } from '../../utils/formatters'
import { useTranslation } from '../../i18n'
import { pluginsApi } from '../../api/client'
import { usePluginStore } from '../../store/pluginStore'
import type { JourneyEntry, JourneyPhoto } from '../../store/journeyStore'
import { MOOD_CONFIG, WEATHER_CONFIG } from '../../pages/journeyDetail/JourneyDetailPage.constants'
import { photoUrl } from '../../pages/journeyDetail/JourneyDetailPage.helpers'
import { Tooltip } from '../shared/Tooltip'
import { MoreButton, type MenuEntry } from '../Planner/planParts'
import { PhotoGrid } from './JourneyDetailPagePhotoGrid'
import { MoodChip, WeatherChip } from './JourneyDetailPageChips'
import { ExpandableStory } from './JourneyDetailPageExpandableStory'
import { VerdictSection } from './JourneyDetailPageVerdictSection'
export function EntryCard({ entry, readOnly, onEdit, onDelete, onPhotoClick }: {
entry: JourneyEntry
readOnly?: boolean
onEdit: () => void
onDelete: () => void
onPhotoClick: (photos: JourneyPhoto[], index: number) => void
}) {
const { t } = useTranslation()
const menuItems: MenuEntry[] = [
{ label: t('common.edit'), icon: Pencil, onClick: onEdit },
{ label: t('common.delete'), icon: Trash2, onClick: onDelete, danger: true },
]
// Extra rows contributed by journalEntryProvider plugins — same pattern as the
// PlaceInspector provider details: fetched only when plugins are active at all,
// fail-safe (the server drops slow/failing providers), only ever additive.
const hasPlugins = usePluginStore((s) => s.plugins.length > 0)
const [providerRows, setProviderRows] = useState<Array<{ pluginId: string; items: Array<{ label: string; value?: string; url?: string }> }>>([])
useEffect(() => {
if (!hasPlugins) { setProviderRows([]); return }
let cancelled = false
pluginsApi.journalEntryRows(entry.id)
.then((d) => { if (!cancelled) setProviderRows((d.providers || []).filter((p) => Array.isArray(p.items) && p.items.length > 0)) })
.catch(() => { if (!cancelled) setProviderRows([]) })
return () => { cancelled = true }
}, [entry.id, hasPlugins])
const photos = entry.photos || []
const mood = entry.mood ? MOOD_CONFIG[entry.mood] : null
const weather = entry.weather ? WEATHER_CONFIG[entry.weather] : null
const prosArr = entry.pros_cons?.pros ?? []
const consArr = entry.pros_cons?.cons ?? []
const hasProscons = prosArr.length > 0 || consArr.length > 0
return (
<div className="bg-white dark:bg-zinc-900 rounded-[20px] overflow-hidden transition-[transform,box-shadow] duration-200 ease-[cubic-bezier(0.23,1,0.32,1)] hover:-translate-y-0.5 hover:shadow-md" style={{ border: '1px solid var(--vg-line)' }}>
{/* Hero area: photos with title overlay */}
{photos.length > 0 ? (
<div className="relative">
<PhotoGrid photos={photos} onClick={(idx) => onPhotoClick(photos, idx)} />
{/* Gradient overlay for title */}
<div className="absolute inset-x-0 bottom-0 pointer-events-none" style={{ background: 'linear-gradient(to top, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.2) 50%, transparent 100%)', height: '60%' }} />
{/* Badges top-left */}
<div className="absolute top-3 start-4 end-14 flex items-center gap-1.5 z-[2]">
{entry.location_name && (
<span className="inline-flex items-center gap-1 px-2.5 py-1 bg-black/40 backdrop-blur-sm rounded-full text-[10px] font-semibold text-white tracking-wide max-w-full overflow-hidden">
<MapPin size={10} className="flex-shrink-0" />
<span className="truncate">{formatLocationName(entry.location_name)}</span>
</span>
)}
{entry.entry_time && (
<span className="inline-flex items-center gap-1 px-2.5 py-1 bg-black/40 backdrop-blur-sm rounded-full text-[10px] font-semibold text-white tracking-wide">
<Clock size={10} />
{entry.entry_time}
</span>
)}
{/* Switched off the route (#2064): the day is still in the journal,
the printed map and the distance skip it, and the card says so. */}
{entry.stats_excluded && (
<span className="inline-flex items-center gap-1 px-2.5 py-1 bg-black/40 backdrop-blur-sm rounded-full text-[10px] font-semibold text-white tracking-wide">
<RouteOff size={10} />
{t('journey.entry.offRoute')}
</span>
)}
{/* A draft (#696) is the contributors' own until it is published. */}
{entry.is_draft && (
<span className="inline-flex items-center gap-1 px-2.5 py-1 bg-black/40 backdrop-blur-sm rounded-full text-[10px] font-semibold text-white tracking-wide">
<PencilLine size={10} />
{t('journey.entry.draft')}
</span>
)}
</div>
{/* Menu top-right, raised on the card colour so it reads on any photo */}
{!readOnly && (
<div className="absolute top-2.5 end-3 z-[2]">
<MoreButton label={t('files.menu')} items={menuItems} size={32} alwaysVisible className="bg-surface-card shadow-sm" />
</div>
)}
{/* Title on photo */}
{entry.title && (
<div className="absolute bottom-4 inset-x-5 z-[2] pointer-events-none">
<h3 className="text-[22px] font-bold text-white tracking-[-0.02em] leading-tight drop-shadow-sm">{entry.title}</h3>
</div>
)}
</div>
) : (
/* No photos: simple header */
<div className="flex items-center justify-between px-4 pt-3">
<div className="flex items-center gap-2 min-w-0 flex-1 me-2">
{entry.location_name && (
<span className="inline-flex items-center gap-1 px-2 py-0.5 bg-zinc-100 dark:bg-zinc-800 rounded-full text-[10px] font-semibold text-zinc-500 max-w-full overflow-hidden">
<MapPin size={10} className="flex-shrink-0" /> <span className="truncate">{formatLocationName(entry.location_name)}</span>
</span>
)}
{entry.entry_time && (
<span className="inline-flex items-center gap-1 px-2 py-0.5 bg-zinc-100 dark:bg-zinc-800 rounded-full text-[10px] font-semibold text-zinc-500">
<Clock size={10} /> {entry.entry_time}
</span>
)}
{entry.stats_excluded && (
<span className="inline-flex items-center gap-1 px-2 py-0.5 bg-zinc-100 dark:bg-zinc-800 rounded-full text-[10px] font-semibold text-zinc-500">
<RouteOff size={10} /> {t('journey.entry.offRoute')}
</span>
)}
{entry.is_draft && (
<span className="inline-flex items-center gap-1 px-2 py-0.5 bg-zinc-100 dark:bg-zinc-800 rounded-full text-[10px] font-semibold text-zinc-500">
<PencilLine size={10} /> {t('journey.entry.draft')}
</span>
)}
</div>
{!readOnly && <MoreButton label={t('files.menu')} items={menuItems} size={28} alwaysVisible />}
</div>
)}
<div className="px-5 pt-4 pb-5">
{/* Title (only if no photos — otherwise shown on image) */}
{!photos.length && entry.title && (
<h3 className="text-base font-semibold text-zinc-900 dark:text-white tracking-tight leading-snug mb-1">{entry.title}</h3>
)}
{!photos.length && entry.location_name && !entry.title && (
<div className="mb-2" />
)}
{/* The verdict rides behind the story's fold: it belongs to one entry, and a
feed of open pro/con tables is a spreadsheet rather than a journal. An
entry with no story keeps it in the open, since there is no fold to
put it behind. */}
{entry.story ? (
<ExpandableStory story={entry.story}>
{hasProscons && <VerdictSection pros={prosArr} cons={consArr} />}
</ExpandableStory>
) : (
hasProscons && <VerdictSection pros={prosArr} cons={consArr} />
)}
{(mood || weather || (entry.tags && entry.tags.length > 0)) && (
<div className="flex items-center justify-between pt-3 mt-3 border-t border-zinc-100 dark:border-zinc-800">
<div className="flex items-center gap-1.5">
{mood && <MoodChip mood={entry.mood!} />}
{weather && <WeatherChip weather={entry.weather!} />}
</div>
<div className="flex gap-1">
{entry.tags?.map((tag, i) => (
<span key={i} className="text-[10px] font-medium px-1.5 py-0.5 rounded-full bg-indigo-50 dark:bg-indigo-900/30 text-indigo-600 dark:text-indigo-400">{tag}</span>
))}
</div>
</div>
)}
{/* Plugin provider rows — host-vetted label/value/url, plain text only */}
{providerRows.length > 0 && (
<div className="pt-3 mt-3 border-t border-zinc-100 dark:border-zinc-800 space-y-1.5">
{providerRows.flatMap((p) => p.items.map((it, i) => (
<div key={`${p.pluginId}-${i}`} className="flex items-baseline justify-between gap-2 text-[12px]">
<span className="font-medium text-zinc-500 dark:text-zinc-400 flex-shrink-0">{it.label}</span>
{it.url
? <a href={it.url} target="_blank" rel="noreferrer noopener" className="text-indigo-600 dark:text-indigo-400 truncate text-end">{it.value ?? it.url}</a>
: <span className="text-zinc-600 dark:text-zinc-300 truncate text-end">{it.value}</span>}
</div>
)))}
</div>
)}
</div>
</div>
)
}
/**
* A place the linked trip planned, offered as an entry waiting to be written.
*
* `onDismiss` is the way out of one that will never be written: plans change, and
* a journey used to have no answer to a suggestion for a museum the traveller
* skipped except hiding every suggestion at once (discussion #2299). The row is
* kept server-side so the trip sync does not offer it again, and the journey
* settings sheet brings them all back.
*/
export function SkeletonCard({ entry, onClick, onDismiss }: { entry: JourneyEntry; onClick?: () => void; onDismiss?: () => void }) {
const { t } = useTranslation()
return (
<div
onClick={onClick}
role={onClick ? 'button' : undefined}
tabIndex={onClick ? 0 : undefined}
onKeyDown={onClick ? e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onClick() } } : undefined}
className={`rounded-[18px] px-3.5 py-3 flex items-center gap-3 transition-transform duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] ${onClick ? 'hover:-translate-y-0.5 cursor-pointer' : ''}`}
style={{ border: '1.5px dashed var(--vg-line2)', background: 'var(--vg-surf2)' }}
>
<div className="w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0" style={{ background: 'var(--vg-surf)', border: '1px solid var(--vg-line)', color: 'var(--vg-ink3)' }}>
<MapPin size={15} />
</div>
<div className="flex-1 min-w-0">
<div className="text-[13px] font-semibold truncate" style={{ color: 'var(--vg-ink)' }}>
{entry.title || t('journey.detail.newEntry')}
</div>
<div className="text-[11px] mt-0.5 truncate" style={{ color: 'var(--vg-ink3)' }}>
{formatLocationName(entry.location_name)}{entry.entry_time ? ` · ${entry.entry_time}` : ''}
</div>
</div>
{onClick && (
<span className="inline-flex items-center gap-1 flex-shrink-0 rounded-full px-3 py-1.5 text-[11px] font-semibold" style={{ background: 'var(--vg-ink)', color: 'var(--vg-bg)' }}>
<Plus size={12} strokeWidth={2.6} /> {t('journey.detail.addEntry')}
</span>
)}
{onDismiss && (
<Tooltip label={t('journey.suggestions.dismiss')} placement="top">
<button
type="button"
onClick={e => { e.stopPropagation(); onDismiss() }}
aria-label={t('journey.suggestions.dismiss')}
className="flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center opacity-45 hover:opacity-100 transition-opacity"
style={{ color: 'var(--vg-ink3)' }}
>
<X size={14} strokeWidth={2.4} />
</button>
</Tooltip>
)}
</div>
)
}
export function CheckinCard({ entry, onClick }: { entry: JourneyEntry; onClick?: () => void }) {
return (
<div
onClick={onClick}
role={onClick ? 'button' : undefined}
tabIndex={onClick ? 0 : undefined}
onKeyDown={onClick ? e => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onClick() } } : undefined}
className={`bg-white dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-700 rounded-xl px-3.5 py-2.5 flex items-center gap-2.5 transition-colors duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] ${onClick ? 'hover:border-zinc-400 dark:hover:border-zinc-500 cursor-pointer' : ''}`}
>
<div className="w-7 h-7 rounded-lg bg-indigo-50 dark:bg-indigo-900/30 text-indigo-600 dark:text-indigo-400 flex items-center justify-center flex-shrink-0">
<MapPin size={13} />
</div>
<div className="flex-1 min-w-0">
<div className="text-[13px] font-medium text-zinc-900 dark:text-white flex items-center gap-1.5">
{entry.title}
{entry.location_name && <span className="text-zinc-500 font-normal text-xs">· {entry.location_name}</span>}
</div>
{entry.story && <div className="text-[11px] text-zinc-500 mt-0.5">{entry.story}</div>}
</div>
<div className="flex items-center gap-2.5 flex-shrink-0">
{entry.entry_time && <span className="text-[11px] text-zinc-400 tabular-nums">{entry.entry_time}</span>}
</div>
</div>
)
}