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

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

export default async function ResetPasswordPage({
  searchParams,
}: {
  searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
}) {
  // Execute PageQuery
  const params = await searchParams;
  const queryResult = await ResetPasswordPageQuery.execute(params);

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

  const viewData = queryResult.unwrap();

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