diff --git a/app/park/[id]/page.tsx b/app/park/[id]/page.tsx index ce9a635..94d6e8e 100644 --- a/app/park/[id]/page.tsx +++ b/app/park/[id]/page.tsx @@ -1,4 +1,5 @@ import Link from "next/link"; +import { BackToCalendarLink } from "@/components/BackToCalendarLink"; import { notFound } from "next/navigation"; import { PARK_MAP } from "@/lib/parks"; import { openDb, getParkMonthData, getApiId } from "@/lib/db"; @@ -93,19 +94,7 @@ export default async function ParkPage({ params, searchParams }: PageProps) { alignItems: "center", gap: 16, }}> - - ← Calendar - +
{park.name} diff --git a/components/BackToCalendarLink.tsx b/components/BackToCalendarLink.tsx new file mode 100644 index 0000000..5fe3d03 --- /dev/null +++ b/components/BackToCalendarLink.tsx @@ -0,0 +1,31 @@ +"use client"; + +import { useState, useEffect } from "react"; +import Link from "next/link"; + +export function BackToCalendarLink() { + const [href, setHref] = useState("/"); + + useEffect(() => { + const saved = localStorage.getItem("lastWeek"); + if (saved) setHref(`/?week=${saved}`); + }, []); + + return ( + + ← Calendar + + ); +} diff --git a/components/HomePageClient.tsx b/components/HomePageClient.tsx index 848e960..ed47f57 100644 --- a/components/HomePageClient.tsx +++ b/components/HomePageClient.tsx @@ -41,6 +41,11 @@ export function HomePageClient({ setCoastersOnly(localStorage.getItem(COASTER_MODE_KEY) === "true"); }, []); + // Remember the current week so the park page back button returns here. + useEffect(() => { + localStorage.setItem("lastWeek", weekStart); + }, [weekStart]); + const toggle = () => { const next = !coastersOnly; setCoastersOnly(next);