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

import MainMenu from "./MainMenu"
import TopMenu from "./TopMenu"

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

export default async function Header() {
  const languages = await serverClient().contentstack.languageSwitcher.get()
  const headerData = await serverClient().contentstack.base.header()

  if (!languages || !headerData) {
    return null
  }

  return (
    <header className={styles.header}>
      <TopMenu languageUrls={languages.urls} topLink={headerData.topLink} />
      <MainMenu
        languageUrls={languages.urls}
        menuItems={headerData.menuItems}
        topLink={headerData.topLink}
      />
    </header>
  )
}
