"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>
  );
}
