import type { Metadata } from "next";
import { headers } from "next/headers";
import { auth } from "@/lib/auth/server";
import { SettingsForm } from "@/components/settings/settings-form";

export const metadata: Metadata = { title: "Profile – Settings" };

export default async function SettingsPage() {
  const session = await auth.api.getSession({ headers: await headers() });
  if (!session) return null;

  return (
    <SettingsForm
      user={{
        name: session.user.name,
        email: session.user.email,
        image: session.user.image ?? null,
        locale: (session.user as { locale?: string }).locale ?? "en",
      }}
    />
  );
}
