import AccountBackButton from '@theme/views/account/back-button';
import AccountMenu from '@theme/views/account/account-menu';
import ThemePlaceholder from '@akinon/pz-theme/src/theme-placeholder';
import { auth } from 'auth';
import { ROUTES } from 'routes';
import { redirect } from '@akinon/next/utils/redirect';

export default async function AccountLayout({
  children
}: {
  children: React.ReactNode;
}) {
  const session = await auth();

  if (!session?.user) {
    return redirect(ROUTES.AUTH);
  }

  return (
    <div className="container flex py-10 px-4 xl:px-0">
      <AccountMenu />
      <div className="w-full flex-1">
        <AccountBackButton />
        <ThemePlaceholder slug="account-page-body" />
        {children}
      </div>
    </div>
  );
}
