'use client';
import { useParams } from 'next/navigation';
import NotFound from '../pages/404';
import { resolvePageType } from '@/lib/resolvePageType';

import CategoryPage from '@/components/Product/Category';
import ProductDetailPage from '@/components/Product/ProductDetail';
import ArticlePage from '@/components/Article';

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

  const pageType = resolvePageType(fullSlug);

  switch (pageType) {
    case 'category':
      return <CategoryPage slug={fullSlug} />;
    case 'product-detail':
      return <ProductDetailPage slug={fullSlug} />;
    case 'article-home':
      return <ArticlePage />;
    default:
      return <NotFound />;
  }
}
