import {
  getHeader,
  getLanguageSwitcher,
  getName,
} from "@/lib/trpc/memoizedRequests"

import MobileMenu from "../MobileMenu"

export default async function MobileMenuWrapper({
  children,
}: React.PropsWithChildren) {
  // preloaded
  const languages = await getLanguageSwitcher()
  const header = await getHeader()
  const user = await getName()

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

  return (
    <MobileMenu
      languageUrls={languages.urls}
      topLink={header.data.topLink}
      isLoggedIn={!!user}
    >
      {children}
    </MobileMenu>
  )
}
