Files
nguyencongpc_nextjs/src/app/[slug]/page.tsx

23 lines
631 B
TypeScript
Raw Normal View History

2025-12-24 17:05:16 +07:00
'use client';
import { useParams } from 'next/navigation';
2025-12-27 12:01:54 +07:00
import CategoryPage from '@/components/Product/Category';
import ProductDetailPage from '@/components/Product/ProductDetail';
2025-12-24 17:05:16 +07:00
2025-12-26 10:27:02 +07:00
import { resolvePageType } from '@/lib/resolvePageType';
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} />;
default:
return <div>404 Không tìm thấy</div>;
}
2025-12-24 17:05:16 +07:00
}