'use client';
import { useParams } from 'next/navigation';
import CategoryPage from '@/components/product/Category';
import ProductDetailPage from '@/components/product/ProductDetail';

import { resolvePageType } from '@/lib/resolvePageType';

export default function DynamicPage() {
  const { slug } = useParams();
  const fullSlug = '/' + slug;

  const pageType = resolvePageType(fullSlug);

  switch (pageType) {
    case 'category':
      return <CategoryPage slug={fullSlug} />;
    case 'product':
      return <ProductDetailPage slug={fullSlug} />;
    default:
      return <div>404 Không tìm thấy</div>;
  }
}
