/**
 * Signup Page
 *
 * RSC composition pattern:
 * 1. PageQuery executes to get ViewData
 * 2. Client component renders with ViewData
 */

import { SignupPageQuery } from '@/lib/page-queries/auth/SignupPageQuery';
import { SignupClient } from './SignupClient';
import { AuthError } from '@/ui/AuthError';

export default async function SignupPage({
  searchParams,
}: {
  searchParams: Promise<URLSearchParams>;
}) {
  // Execute PageQuery
  const params = await searchParams;
  const queryResult = await SignupPageQuery.execute(params);

  if (queryResult.isErr()) {
    return <AuthError action="signup" />;
  }

  const viewData = queryResult.unwrap();

  // Render client component with ViewData
  return <SignupClient viewData={viewData} />;
}