import { redirect } from "next/navigation";
import type { Metadata } from "next";
import { auth } from "@/lib/auth";
import MeContent from "./MeContent";

export const metadata: Metadata = {
  title: "个人中心 · CYBER STAR",
};

export default async function MePage() {
  const session = await auth();

  // 未登录 → 回到首页（登录弹窗由导航 / vote 交互触发，不再使用独立 /login 页）
  if (!session?.user) {
    redirect("/");
  }

  const sessionUser = session.user as { id?: string; name?: string | null };
  return (
    <MeContent
      session={{
        id: sessionUser.id ?? "0",
        nickname: sessionUser.name ?? "粉丝",
      }}
    />
  );
}
