import { Suspense } from "react"

import { serverClient } from "@/lib/trpc/server"

import LanguageSwitcher from "@/components/LanguageSwitcher"
import { setLang } from "@/i18n/serverContext"

import { LangParams, PageArgs } from "@/types/params"

export default async function HeaderPage({ params }: PageArgs<LangParams>) {
  setLang(params.lang)
  const languages = await serverClient().contentstack.languageSwitcher.get()
  if (!languages) {
    return null
  }
  return (
    <Suspense>
      <LanguageSwitcher type="desktopHeader" urls={languages.urls} />
    </Suspense>
  )
}
