import { Metadata } from 'next';

import { notFound } from 'next/navigation';

import { retrieveCustomer } from '~/medusa/lib/data/customer';
import { listOrders } from '~/medusa/lib/data/orders';
import Overview from '~/medusa/modules/account/components/overview';

export const metadata: Metadata = {
  title: 'Account',
  description: 'Overview of your account activity.',
};

export default async function OverviewTemplate() {
  const customer = await retrieveCustomer().catch(() => null);
  const orders = (await listOrders().catch(() => null)) || null;

  if (!customer) {
    notFound();
  }

  return <Overview customer={customer} orders={orders} />;
}
