"use client";

import { useAuth } from "@/components/auth/AuthContext";
import { ArrowLink } from "@/components/ArrowLink";

export function BookletLink({ slug }: { slug: string }) {
  const { isAuthenticated, isLoading } = useAuth();

  if (isLoading) return null;

  if (!isAuthenticated) {
    return (
      <ArrowLink href={`/account/login?redirect=/release/${slug}`}>Log in to download</ArrowLink>
    );
  }

  return (
    <ArrowLink
      href={`/release/${slug}/booklet`}
      target="_blank"
      rel="nofollow noopener"
    >
      Download PDF
    </ArrowLink>
  );
}
