import { redirect } from "next/navigation";

import { SignupForm1 } from "./components/signup-form-1";
import { getCurrentUser } from "@/lib/appwrite/server";

export default async function SignUpPage({
  searchParams,
}: {
  searchParams: Promise<{ invite?: string; email?: string }>;
}) {
  const { invite, email } = await searchParams;
  const user = await getCurrentUser();
  if (user) redirect(invite ? `/d/${invite}` : "/dashboard");

  return (
    <div className="bg-muted flex min-h-svh flex-col items-center justify-center p-6 md:p-10">
      <div className="w-full max-w-sm md:max-w-4xl">
        <SignupForm1 inviteCode={invite} prefilledEmail={email} />
      </div>
    </div>
  );
}
