import { imgUrl } from '../../api.js'; import { BY_CODE, countryName, fmtRange } from './laender.js'; // Zeitleiste "Wann war ich wo?": alle Besuche, neueste zuerst, nach Jahren gruppiert export default function Timeline({ visits, cities, onSelectCity, onEdit, onPhoto }) { if (!visits.length) { return

Noch keine Besuche. Klick auf eine Stadt und dann auf „+ Besuch eintragen“.

; } const byId = new Map(cities.map((c) => [c.id, c])); const years = []; for (const v of visits) { const year = v.dateFrom.slice(0, 4); if (years.at(-1)?.year !== year) years.push({ year, visits: [] }); years.at(-1).visits.push(v); } return (
{years.map((y) => (

{y.year}

    {y.visits.map((v) => { const city = byId.get(v.cityId); if (!city) return null; return (
  1. {fmtRange(v.dateFrom, v.dateTo)}
    {v.companions && mit {v.companions}} {v.notes &&

    {v.notes}

    } {v.photos.length > 0 && (
      {v.photos.map((p) => (
    • ))}
    )}
  2. ); })}
))}
); }