import { getHeader } from "@/lib/trpc/memoizedRequests"

import { isLoggedInUser } from "@/utils/isLoggedInUser"

import MobileMenu from "../MobileMenu"

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

  if (!header) {
    return null
  }

  const isLoggedIn = await isLoggedInUser()

  return (
    <MobileMenu topLink={header.data.topLink} isLoggedIn={isLoggedIn}>
      {children}
    </MobileMenu>
  )
}
