import { redirect } from "next/navigation";
import { getServerSession } from "next-auth";
import { authOptions } from "@/lib/auth";
import { UploadForm } from "@/components/UploadForm";
import { SignOutButton } from "@/components/SignOutButton";

export default async function DashboardPage() {
  const session = await getServerSession(authOptions);
  if (!session) redirect("/");

  return (
    <main className="min-h-screen">
      <header className="border-b border-gray-800 bg-surface">
        <div className="mx-auto flex max-w-4xl items-center justify-between px-6 py-4">
          <div>
            <a href="/" className="text-xl font-bold text-white">
              s2yt
            </a>
            {session.user.channelTitle && (
              <p className="text-xs text-gray-500">Channel: {session.user.channelTitle}</p>
            )}
          </div>
          <SignOutButton />
        </div>
      </header>

      <div className="mx-auto max-w-4xl px-6 py-8">
        <h1 className="mb-6 text-2xl font-bold text-white">Create Videos</h1>
        <UploadForm />
      </div>
    </main>
  );
}
