import React from 'react'
import { cookies } from 'next/headers'
import RouteClient from './RouteClient'

async function getMessages() {
  const cookieStore = await cookies()
  const lang = cookieStore.get('NEXT_LOCALE')?.value || 'de'
  const messages = await import(`@/messages/${lang}.json`)
  return messages.default
}

interface PageProps {
  params: Promise<{ id: string }>
}

export default async function RouteDetailPage({ params }: PageProps) {
  const messages = await getMessages()
  const { id } = await params

  return <RouteClient routeId={id} />
} 