Files
SixFlagsSuperCalendar/components/BackToCalendarLink.tsx
Josh Wright 090f4d876d
All checks were successful
Build and Deploy / Build & Push (push) Successful in 1m3s
fix: "← Calendar" returns to the previously viewed week
HomePageClient writes the current weekStart to localStorage("lastWeek")
whenever it changes. BackToCalendarLink (new client component) reads
that value on mount and builds the href — falling back to "/" if nothing
is stored (e.g. direct link to a park page).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 08:59:14 -04:00

32 lines
651 B
TypeScript

"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 (
<Link
href={href}
className="park-name-link"
style={{
display: "flex",
alignItems: "center",
gap: 6,
fontSize: "0.8rem",
color: "var(--color-text-muted)",
textDecoration: "none",
transition: "color 120ms ease",
}}
>
Calendar
</Link>
);
}