"use client"; import { useState } from "react"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { compareUrl } from "@/lib/compareScore"; import { mergeDestinationsIntoTrip } from "@/lib/tripActions"; import { useToast } from "@/lib/toast"; import { useI18n } from "@/lib/i18n"; import { meetupCityHref } from "@/lib/meetupLinks"; import type { Destination } from "@/lib/types"; interface Props { destinations: Destination[] } export default function WorldMap({ destinations }: Props) { const { t } = useI18n(); const { toast } = useToast(); const router = useRouter(); const [selected, setSelected] = useState(null); const addToPlan = () => { if (!selected) return; const { added } = mergeDestinationsIntoTrip([selected], 1); toast( added ? `${selected.emoji} ${selected.name} ${t.plan.addedToPlan}` : t.common.alreadyInPlan, added ? "success" : "info", { href: "/plan", label: t.strip.openPlan } ); if (added) router.push("/plan"); }; return (
{t.home.mapTag}

{t.home.mapTitle}

{t.home.mapSubtitle}

{destinations.map((d) => ( setSelected(d)} style={{ cursor: "pointer" }} role="button" tabIndex={0} aria-label={d.name} onKeyDown={(e) => { if (e.key === "Enter") setSelected(d); }} > {d.emoji} ))}
{selected ? (
{selected.emoji}

{selected.name}, {selected.country}

{selected.tag}

{selected.description}

¥{selected.cost.toLocaleString()}{t.home.mapCost}
{selected.speed}Mbps{t.home.mapSpeed}
{selected.temperature}°C{t.home.mapTemp}
⭐ {selected.rating}{t.home.mapRating}
{t.common.detail} {t.common.cityMeetups} ⚖️ {t.nav.compare} 🧭 {t.nav.nextStop}
) : (
👆

{t.home.mapPick}

{t.home.mapPickHint}

{t.home.mapBrowse} {t.home.mapMembers}
)}
); }