import { createClient } from "@/utils/supabase/server";
import Link from "next/link";
import { UserMenu } from "./user-menu";
import { Button } from "@/components/ui/button";
import { AUTH_ROUTES } from "@/features/auth/constants";

export async function Header() {
  const supabase = await createClient();
  const {
    data: { user },
  } = await supabase.auth.getUser();

  return (
    <header className="sticky top-0 z-40 flex h-14 w-full items-center justify-between border-b border-zinc-200 bg-white/75 px-6 backdrop-blur-md transition-all dark:border-zinc-800 dark:bg-black/75">
      <div className="flex items-center gap-2">
        <Link href={AUTH_ROUTES.DASHBOARD} className="flex items-center gap-2">
          <div className="h-6 w-6 rounded-md bg-zinc-900 dark:bg-zinc-50" />
          <span className="text-lg font-bold tracking-tight text-zinc-900 dark:text-zinc-50">
            AutoTrade
          </span>
        </Link>
      </div>

      <div className="flex items-center gap-4">
        {user ? (
          <UserMenu user={user} />
        ) : (
          <Button asChild variant="default" size="sm">
            <Link href={AUTH_ROUTES.LOGIN}>로그인</Link>
          </Button>
        )}
      </div>
    </header>
  );
}
