import type { SanitizedConfig } from 'payload/types'

import { DefaultTemplate } from '@payloadcms/ui'
import '@payloadcms/ui/scss/app.scss'
import React from 'react'

import { initPage } from '../../utilities/initPage'

export const metadata = {
  description: 'Generated by Next.js',
  title: 'Next.js',
}

export const AdminLayout = async ({
  children,
  config,
}: {
  children: React.ReactNode
  config: Promise<SanitizedConfig> | SanitizedConfig
}) => {
  const { i18n, permissions, user } = await initPage({ config })

  return (
    <DefaultTemplate config={config} i18n={i18n} permissions={permissions} user={user}>
      {children}
    </DefaultTemplate>
  )
}
