update
This commit is contained in:
@@ -1,17 +1,22 @@
|
||||
'use client';
|
||||
import { useParams } from 'next/navigation';
|
||||
import { productCategoryData } from '@/data/product/category';
|
||||
import CategoryPage from '@/components/product/Category';
|
||||
import ProductDetailPage from '@/components/product/ProductDetail';
|
||||
|
||||
// import component
|
||||
import CategoryPage from '@components/layout/product/Category';
|
||||
import { resolvePageType } from '@/lib/resolvePageType';
|
||||
|
||||
export default function DynamicPage() {
|
||||
const params = useParams();
|
||||
const slug = ('/' + params?.slug) as string;
|
||||
const { slug } = useParams();
|
||||
const fullSlug = '/' + slug;
|
||||
|
||||
if (productCategoryData.find((c) => c.current_category.url == slug)) {
|
||||
return <CategoryPage slug={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>;
|
||||
}
|
||||
|
||||
return <div>404 Không tìm thấy</div>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user