import Link from "next/link";
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth-options";

export async function SiteHeader() {
  const session = await getServerSession(authOptions);
  const isAdmin = session?.user?.role === "ADMIN";

  return (
    <header className="site-header">
      <div className="container header-inner">
        <Link href="/" className="logo">
          Fahrlässig <span>Motorrad Akademie</span>
        </Link>
        <nav className="nav">
          <Link href="/">Startseite</Link>
          <Link href="/kurse">Kurse</Link>
          {session ? (
            <>
              <Link href="/portal">Mitgliederbereich</Link>
              {isAdmin ? (
                <Link href="/admin" className="badge badge-admin" style={{ padding: "0.45rem 0.75rem" }}>
                  Admin
                </Link>
              ) : null}
              <a href="/api/auth/signout?callbackUrl=/" className="btn btn-ghost">
                Abmelden
              </a>
            </>
          ) : (
            <Link href="/login" className="btn btn-primary">
              Login
            </Link>
          )}
        </nav>
      </div>
    </header>
  );
}
