diff --git a/src/app/[...slug]/page.tsx b/src/app/[...slug]/page.tsx deleted file mode 100644 index b22e3cf..0000000 --- a/src/app/[...slug]/page.tsx +++ /dev/null @@ -1,53 +0,0 @@ -'use client'; -import React from 'react'; -import { useParams } from 'next/navigation'; -import Link from 'next/link'; -import { findCategoryBySlug } from '@/lib/category'; - -const CategoryPage: React.FC = () => { - const params = useParams(); - const slugArray = params?.slug as string[]; - - // tìm danh mục hiện tại theo slug - const category: Category | null = findCategoryBySlug(slugArray, categories); - - if (!category) { - return ( -
-

Không tìm thấy danh mục

-
- ); - } - - return ( -
- {/* Breadcrumb */} - - - {/* Tiêu đề danh mục */} -

{category.name}

- - {/* Nếu có danh mục con thì hiển thị */} - {category.children && category.children.length > 0 ? ( -
- {category.children.map((child) => ( -
- {child.name} -
- ))} -
- ) : ( -

Danh mục này chưa có danh mục con hoặc sản phẩm.

- )} -
- ); -}; - -export default CategoryPage; diff --git a/src/app/[slug]/page.tsx b/src/app/[slug]/page.tsx new file mode 100644 index 0000000..e32b3b1 --- /dev/null +++ b/src/app/[slug]/page.tsx @@ -0,0 +1,17 @@ +'use client'; +import { useParams } from 'next/navigation'; +import { productCategoryData } from '@/data/product/category'; + +// import component +import CategoryPage from '@components/layout/product/Category'; + +export default function DynamicPage() { + const params = useParams(); + const slug = ('/' + params?.slug) as string; + + if (productCategoryData.find((c) => c.current_category.url == slug)) { + return ; + } + + return
404 Không tìm thấy
; +} diff --git a/src/app/(size)/layout.tsx b/src/app/layout.tsx similarity index 95% rename from src/app/(size)/layout.tsx rename to src/app/layout.tsx index c2f976f..5402918 100644 --- a/src/app/(size)/layout.tsx +++ b/src/app/layout.tsx @@ -29,7 +29,7 @@ export default function RootLayout({ ) : ( <>
- {children} +
{children}