// app/auth/sign-up/page.tsx
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import SignUp from "./sign-up";

export default async function SignUpPage({
    searchParams,
}: {
    searchParams?: Record<string, string | string[] | undefined>;
}) {
    const at = (await cookies()).get("ma_at")?.value;
    if (at) {
        redirect("/portal");
    }

    const nextParam = toStr(searchParams?.next) || "/portal";
    return <SignUp nextPath={nextParam} />;
}

function toStr(v: string | string[] | undefined): string | undefined {
    if (!v) return undefined;
    return Array.isArray(v) ? v[0] : v;
}
