import {NextIntlClientProvider} from 'next-intl'
import {getMessages} from 'next-intl/server'
import {notFound} from 'next/navigation'
import {ReactNode} from 'react'

import {routing} from '@/i18n/routing'
import {TIMEZONE} from '@/lib/constants'

export default async function RootLayout({
	children,
	params
}: Readonly<{
	children: ReactNode
	params: Promise<{locale: string}>
}>) {
	const {locale} = await params
	if (!routing.locales.includes(locale as any)) {
		notFound()
	}

	const messages = await getMessages()
	//const queryClient = new QueryClient()

	return (
		<NextIntlClientProvider
			messages={messages}
			timeZone={TIMEZONE}
			now={new Date()}
		>
			{children}
		</NextIntlClientProvider>
	)
}
