import { Toaster } from '@medusajs/ui';

import { retrieveCustomer } from '~/medusa/lib/data';
import { AccountLayout } from '~/medusa/modules/account/templates';

export default async function AccountPageLayout({
  dashboard,
  login,
}: {
  dashboard?: React.ReactNode;
  login?: React.ReactNode;
}) {
  const customer = await retrieveCustomer().catch(() => null);

  return (
    <AccountLayout customer={customer}>
      {customer ? dashboard : login}
      <Toaster />
    </AccountLayout>
  );
}
