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

import Desktop from "@/components/Current/Header/LanguageSwitcher/Desktop"
import Mobile from "@/components/Current/Header/LanguageSwitcher/Mobile"

import styles from "./page.module.css"

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

export default async function LanguageSwitcher({
  params,
  searchParams,
}: PageArgs<LangParams, UriParams & UIDParams>) {
  if (!searchParams.uid) {
    return null
  }

  const { urls } = await serverClient().contentstack.config.languageSwitcher()

  return (
    <>
      <section className={styles.desktop}>
        <Desktop currentLanguage={params.lang} urls={urls} />
      </section>
      <section className={styles.mobile}>
        <Mobile currentLanguage={params.lang} urls={urls} />
      </section>
    </>
  )
}
