import { useState, useRef } from 'react' import { createPortal } from 'react-dom' import { MapPin, Clock, MoreHorizontal, Pencil, Trash2 } from 'lucide-react' import { formatLocationName } from '../../utils/formatters' import { useTranslation } from '../../i18n' 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 { 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 [menuOpen, setMenuOpen] = useState(false) const menuBtnRef = useRef(null) 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 (
{/* Hero area: photos with title overlay */} {photos.length > 0 ? (
onPhotoClick(photos, idx)} /> {/* Gradient overlay for title */}
{/* Badges top-left */}
{entry.location_name && ( {formatLocationName(entry.location_name)} )} {entry.entry_time && ( {entry.entry_time} )}
{/* Menu top-right */} {!readOnly && (
{menuOpen && createPortal( <>
setMenuOpen(false)} />
, document.body, )}
)} {/* Title on photo */} {entry.title && (

{entry.title}

)}
) : ( /* No photos: simple header */
{entry.location_name && ( {formatLocationName(entry.location_name)} )} {entry.entry_time && ( {entry.entry_time} )}
{!readOnly && (
{menuOpen && createPortal( <>
setMenuOpen(false)} />
, document.body, )}
)}
)}
{/* Title (only if no photos — otherwise shown on image) */} {!photos.length && entry.title && (

{entry.title}

)} {!photos.length && entry.location_name && !entry.title && (
)} {entry.story && ( )} {/* Pros & Cons — "Pros & Cons" style */} {hasProscons && ( )} {(mood || weather || (entry.tags && entry.tags.length > 0)) && (
{mood && } {weather && }
{entry.tags?.map((tag, i) => ( {tag} ))}
)}
) } export function SkeletonCard({ entry, onClick }: { entry: JourneyEntry; onClick?: () => void }) { const { t } = useTranslation() return (
{entry.title || t('journey.detail.newEntry')}
{formatLocationName(entry.location_name)}{entry.entry_time ? ` · ${entry.entry_time}` : ''}
{t('journey.detail.addEntry')} →
) } export function CheckinCard({ entry, onClick }: { entry: JourneyEntry; onClick?: () => void }) { return (
{entry.title} {entry.location_name && · {entry.location_name}}
{entry.story &&
{entry.story}
}
{entry.entry_time && {entry.entry_time}}
) }