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

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

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

export default async function LanguageSwitcherRoute({
  params,
}: PageArgs<LangParams>) {
  setLang(params.lang)

  const data = await serverClient().contentstack.languageSwitcher.get()
  if (!data) {
    return null
  }
  return <LanguageSwitcher urls={data.urls} />
}
