import React from "react"
import { dehydrate, HydrationBoundary, QueryClient } from "@tanstack/react-query"
import { createKeys } from "@/lib/query-keys"
import { createService } from "@/services/create"

export default async function MainLayout({
  children,
}: {
  children: React.ReactNode
}) {
  const queryClient = new QueryClient()

  await queryClient.prefetchQuery({
    queryKey: createKeys.dict(),
    queryFn: () => createService.dict(),
  })

  return (
    <HydrationBoundary state={dehydrate(queryClient)}>
      {children}
    </HydrationBoundary>
  )
}