2025-12-24 17:05:16 +07:00
|
|
|
'use client';
|
|
|
|
|
import { useParams } from 'next/navigation';
|
2025-12-29 23:46:30 +07:00
|
|
|
import NotFound from '../pages/404';
|
|
|
|
|
import { resolvePageType } from '@/lib/resolvePageType';
|
|
|
|
|
|
2025-12-27 12:01:54 +07:00
|
|
|
import CategoryPage from '@/components/Product/Category';
|
|
|
|
|
import ProductDetailPage from '@/components/Product/ProductDetail';
|
2025-12-29 23:46:30 +07:00
|
|
|
import ArticlePage from '@/components/Article';
|
2025-12-24 17:05:16 +07:00
|
|
|
|
|
|
|
|
export default function DynamicPage() {
|
2025-12-26 10:27:02 +07:00
|
|
|
const { slug } = useParams();
|
|
|
|
|
const fullSlug = '/' + slug;
|
2025-12-24 17:05:16 +07:00
|
|
|
|
2025-12-26 10:27:02 +07:00
|
|
|
const pageType = resolvePageType(fullSlug);
|
2025-12-24 17:05:16 +07:00
|
|
|
|
2025-12-26 10:27:02 +07:00
|
|
|
switch (pageType) {
|
|
|
|
|
case 'category':
|
|
|
|
|
return <CategoryPage slug={fullSlug} />;
|
2025-12-27 12:01:54 +07:00
|
|
|
case 'product-detail':
|
2025-12-26 10:27:02 +07:00
|
|
|
return <ProductDetailPage slug={fullSlug} />;
|
2025-12-29 23:46:30 +07:00
|
|
|
case 'article-home':
|
|
|
|
|
return <ArticlePage />;
|
2025-12-26 10:27:02 +07:00
|
|
|
default:
|
2025-12-29 23:46:30 +07:00
|
|
|
return <NotFound />;
|
2025-12-26 10:27:02 +07:00
|
|
|
}
|
2025-12-24 17:05:16 +07:00
|
|
|
}
|