import AuthPageClient from './AuthPage.client.js';
import {
  registerAction,
  loginAction,
  logoutAction,
  forgotPasswordAction,
  resetPasswordAction,
  verifyEmailAction,
  setupAccountAction,
  setSessionCookie,
  getSession,
} from './actions.js';

export default async function AuthPage({ params, searchParams }) {
  const session = await getSession();

  return (
    <div className="min-h-screen flex flex-col items-center justify-start sm:justify-center px-4 py-10 sm:py-8 md:p-8 bg-neutral-50 dark:bg-black">
      <div className="max-w-md w-full">
        <AuthPageClient
          params={params}
          searchParams={searchParams}
          registerAction={registerAction}
          loginAction={loginAction}
          logoutAction={logoutAction}
          forgotPasswordAction={forgotPasswordAction}
          resetPasswordAction={resetPasswordAction}
          verifyEmailAction={verifyEmailAction}
          setupAccountAction={setupAccountAction}
          setSessionCookieAction={setSessionCookie}
          redirectAfterLogin={process.env.ZEN_AUTH_REDIRECT_AFTER_LOGIN || '/'}
          currentUser={session?.user || null}
        />
      </div>
    </div>
  );
}
