import Link from "next/link";
import { User } from "@supabase/supabase-js";
import { AUTH_ROUTES } from "@/features/auth/constants";
import { UserMenu } from "@/features/layout/components/user-menu";
import { Button } from "@/components/ui/button";

interface HeaderProps {
  user: User | null;
  showDashboardLink?: boolean;
}

export function Header({ user, showDashboardLink = false }: HeaderProps) {
  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.HOME} 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 ? (
          <>
            {showDashboardLink && (
              <Button asChild variant="ghost" size="sm">
                <Link href={AUTH_ROUTES.DASHBOARD}>대시보드</Link>
              </Button>
            )}
            <UserMenu user={user} />
          </>
        ) : (
          <>
            <Button asChild variant="ghost" size="sm">
              <Link href={AUTH_ROUTES.LOGIN}>로그인</Link>
            </Button>
            <Button asChild size="sm">
              <Link href={AUTH_ROUTES.SIGNUP}>무료로 시작하기</Link>
            </Button>
          </>
        )}
      </div>
    </header>
  );
}
