import PreferenceWrapper from '@/components/wrapper/PreferenceWrapper'
import React from 'react'
import type { Metadata, Viewport } from 'next'

type LayoutParams = { name: string }

export async function generateMetadata ({
  params
}: {
  params: Promise<LayoutParams>
}): Promise<Metadata> {
  const { name } = await params
  return {
    title: `${name} Dashboard`,
    description: `PWA dashboard for ${name}`,
    manifest: `/manifests/${name}/manifest.json`
  }
}

export async function generateViewport (): Promise<Viewport> {
  return {
    themeColor: '#F4F5F9'
  }
}

export default function Layout ({
  children
}: {
  children: React.ReactNode
  params: Promise<LayoutParams>
}): React.ReactNode {
  return <PreferenceWrapper>{children}</PreferenceWrapper>
}
