// Categories/page.tsx
import CategoriesComp from '@/components/categories/CategoriesComp'
import { getCategoryData, getPrimeAccessData } from './action'

export default async function Categories({
  params,
  searchParams,
}: {
  params: Promise<{ slug: string }>
  searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}) {
  const initialLangId = (await searchParams)?.lang
  const initialCatId = (await searchParams)?.cat

  const categoryData = await getCategoryData(
    Number(initialLangId),
    Number(initialCatId),
    1,
  )

  const primeAccessData = await getPrimeAccessData(Number(initialLangId))

  return (
    <CategoriesComp
      initialCategoryData={categoryData.data}
      primeAccessData={primeAccessData.data}
    />
  )
}
