import type { Metadata } from 'next'
import { getTranslations, setRequestLocale } from 'next-intl/server'
import Hero from '@/components/sections/Hero'
import TrustBar from '@/components/sections/TrustBar'
import ServicesOverview from '@/components/sections/ServicesOverview'
import Process from '@/components/sections/Process'
import SelectedWorks from '@/components/sections/SelectedWorks'
import Philosophy from '@/components/sections/Philosophy'
import Configurator from '@/components/sections/Configurator'
import Discovery from '@/components/sections/Discovery'
import CTABanner from '@/components/sections/CTABanner'

const BASE_URL = 'https://letsbe.biz'

type Props = {
  params: Promise<{ locale: string }>
}

export async function generateMetadata({ params }: Props): Promise<Metadata> {
  const { locale } = await params
  const t = await getTranslations({ locale, namespace: 'meta.home' })

  const path = locale === 'en' ? '' : `/${locale}`

  return {
    title: t('title'),
    description: t('description'),
    alternates: {
      canonical: `${BASE_URL}${path}`,
      languages: {
        'en': BASE_URL,
        'fr': `${BASE_URL}/fr`,
        'it': `${BASE_URL}/it`,
        'es': `${BASE_URL}/es`,
        'x-default': BASE_URL,
      },
    },
  }
}

export default async function HomePage({ params }: Props) {
  const { locale } = await params
  setRequestLocale(locale)

  const websiteJsonLd = {
    '@context': 'https://schema.org',
    '@type': 'WebSite',
    name: 'LetsBe.',
    url: BASE_URL,
    inLanguage: locale,
  }

  return (
    <main>
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(websiteJsonLd) }}
      />
      <Hero />
      <TrustBar />
      <ServicesOverview />
      <Configurator />
      <Process />
      <Discovery />
      <SelectedWorks />
      <Philosophy />
      <CTABanner />
    </main>
  )
}
