import Desktop from "../LanguageSwitcher/Desktop"

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

import type { TopMenuProps } from "@/types/components/current/header/topMenu"

export default function TopMenu({ currentLanguage, frontpageLinkText, homeHref, links, urls }: TopMenuProps) {
  return (
    <div className={styles.topMenu}>
      <div className={styles.container}>
        <a
          className={styles.homeLink}
          href={homeHref}
        >
          {frontpageLinkText}
        </a>

        <ul className={styles.list}>
          {urls ? (
            <li className="nav-secondary__item hidden-xxsmall hidden-xsmall hidden-small">
              <Desktop currentLanguage={currentLanguage} urls={urls} />
            </li>
          ) : null}

          {links.map(({ link }) => (
            <li key={link.href}>
              <a
                className={styles.link}
                href={link.href}
              >
                {link.title}
              </a>
            </li>
          ))}
        </ul>
      </div>
    </div>
  )
}
