From 9072f84681f1a108187dfba7928ac01971276049 Mon Sep 17 00:00:00 2001 From: tieptk Date: Wed, 24 Dec 2025 17:05:16 +0700 Subject: [PATCH] update --- src/app/[...slug]/page.tsx | 53 ------- src/app/[slug]/page.tsx | 17 +++ src/app/{(size) => }/layout.tsx | 2 +- src/app/{(size) => }/page.tsx | 0 src/components/common/Breadcrumb.tsx | 46 ++++++ .../layout/home/SliderHome/index.tsx | 2 +- .../product/Category/BannerCategory/index.tsx | 37 +++++ .../layout/product/Category/index.tsx | 81 +++++++++++ .../bannerData.ts => data/banner/index.ts} | 69 +++++++++ src/lib/category.ts | 64 ++------- src/styles/globals.css | 9 -- src/types/{home => global}/Banner.ts | 5 + src/types/{home => global}/TypeListProduct.ts | 0 src/types/global/index.ts | 1 + src/types/home/index.ts | 3 +- src/types/product/category/index.ts | 133 ++++++++++++++++-- 16 files changed, 389 insertions(+), 133 deletions(-) delete mode 100644 src/app/[...slug]/page.tsx create mode 100644 src/app/[slug]/page.tsx rename src/app/{(size) => }/layout.tsx (95%) rename src/app/{(size) => }/page.tsx (100%) create mode 100644 src/components/common/Breadcrumb.tsx create mode 100644 src/components/layout/product/Category/BannerCategory/index.tsx create mode 100644 src/components/layout/product/Category/index.tsx rename src/{components/layout/home/SliderHome/bannerData.ts => data/banner/index.ts} (92%) rename src/types/{home => global}/Banner.ts (91%) rename src/types/{home => global}/TypeListProduct.ts (100%) 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}