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

import { auth } from "@/auth"
import { isValidSession } from "@/utils/session"

import MobileMenu from "../MobileMenu"

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

  if (!header) {
    return null
  }

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