import { RootPage, generatePageMetadata } from '@payloadcms/next/views';
import type { Metadata } from 'next';
import config from '../../../../payload.config';
import { importMap } from '../importMap';

export const dynamic = 'force-dynamic';

type Props = {
  params: Promise<{ segments?: string[] }>;
  searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
};

export const generateMetadata = (props: Props): Promise<Metadata> => {
  return generatePageMetadata({
    config,
    params: props.params as Promise<{ [key: string]: string | string[] }>,
    searchParams: props.searchParams as Promise<{ [key: string]: string | string[] }>,
  });
};

export default function Page(props: Props) {
  return RootPage({
    config,
    importMap,
    params: props.params as Promise<{ segments: string[] }>,
    searchParams: props.searchParams as Promise<{ [key: string]: string | string[] }>,
  });
}
