From dbe8399086f38701a978be1369234cfcb6096a22 Mon Sep 17 00:00:00 2001 From: "nabijonovdavronbek619@gmail.com" Date: Sat, 7 Feb 2026 11:27:13 +0500 Subject: [PATCH] add catalog filter card --- app/[locale]/catalog_page/page.tsx | 5 +- app/[locale]/products/page.tsx | 2 + components/pages/products/banner.tsx | 2 +- components/pages/products/catalog.tsx | 2 +- .../products/filter/catalog/filterCatalog.tsx | 96 ++++++++++++ .../pages/products/filter/catalog/loading.tsx | 23 +++ components/pages/products/filter/filter.tsx | 141 +++++++++--------- .../pages/products/product/products.tsx | 4 +- components/pages/subCategory/card.tsx | 2 +- 9 files changed, 199 insertions(+), 78 deletions(-) create mode 100644 components/pages/products/filter/catalog/filterCatalog.tsx create mode 100644 components/pages/products/filter/catalog/loading.tsx diff --git a/app/[locale]/catalog_page/page.tsx b/app/[locale]/catalog_page/page.tsx index 165fb97..e17d63e 100644 --- a/app/[locale]/catalog_page/page.tsx +++ b/app/[locale]/catalog_page/page.tsx @@ -1,12 +1,13 @@ import Catalog from "@/components/pages/home/blog/catalog"; import { ProductBanner } from "@/components/pages/products"; +import { MainSubCategory } from "@/components/pages/subCategory"; export default function Page() { return (
- +
- +
); diff --git a/app/[locale]/products/page.tsx b/app/[locale]/products/page.tsx index 007ade3..977f133 100644 --- a/app/[locale]/products/page.tsx +++ b/app/[locale]/products/page.tsx @@ -1,9 +1,11 @@ import { ProductBanner, Products } from "@/components/pages/products"; +import FilterCatalog from "@/components/pages/products/filter/catalog/filterCatalog"; export default function Page() { return (
+ {/* */}
); diff --git a/components/pages/products/banner.tsx b/components/pages/products/banner.tsx index 8612f58..69686f7 100644 --- a/components/pages/products/banner.tsx +++ b/components/pages/products/banner.tsx @@ -4,7 +4,7 @@ import { useTranslations } from "next-intl"; export function ProductBanner() { const t = useTranslations(); return ( -
+
{/* Background Image */}
state.setCategory); + const { data, isLoading } = useQuery({ + queryKey: ["category", language], + queryFn: () => httpClient(endPoints.category.all), + select: (data): CategoryType[] => data?.data?.results, + }); + useEffect(() => { + console.log("product catalog data: ", data); + }, [data]); + + if (isLoading) { + return ( +
+ {[...Array(3)].map((_, index) => ( + + ))} +
+ ); + } + + // Ma'lumot yo'q holati + if (!data || data.length === 0) { + return ( + + ); + } + + return ( +
+ {data?.map((item) => ( +
setCategory(item)} + className="shrink-0 group relative w-55 h-60 overflow-hidden rounded-2xl bg-[#17161679] border border-white/10 transition-all duration-500 hover:-translate-y-1 hover:border-red-700 cursor-pointer" + > + {/* Background glow effect */} +
+ + {/* Decorative corner accent */} +
+ + {/* Content container */} +
+ {/* Title section */} +
+
+

+ {item.name} +

+ +
+ +
+
+
+ + {/* Image container */} +
+
+ +
+ {item.name} +
+
+
+
+ ))} +
+ ); +} diff --git a/components/pages/products/filter/catalog/loading.tsx b/components/pages/products/filter/catalog/loading.tsx new file mode 100644 index 0000000..a0a42ce --- /dev/null +++ b/components/pages/products/filter/catalog/loading.tsx @@ -0,0 +1,23 @@ +// components/CatalogCardSkeletonSmall.tsx +export default function CatalogCardSkeletonSmall() { + return ( +
+
+ + {/* Title skeleton */} +
+
+
+
+ + {/* Image skeleton */} +
+
+
+
+ + {/* Shimmer */} +
+
+ ); +} diff --git a/components/pages/products/filter/filter.tsx b/components/pages/products/filter/filter.tsx index 1988f2d..45a1d17 100644 --- a/components/pages/products/filter/filter.tsx +++ b/components/pages/products/filter/filter.tsx @@ -67,86 +67,85 @@ export default function Filter() { const visibleSectionNumber = numberExpanded ? sizeData : sizeData.slice(0, 10); - - console.log("have suncategory: ", category.have_sub_category); - if (category.have_sub_category || subCategory.id !== 0) { - return null; - } - console.log("filter: ",filter); + console.log("filter: ", filter); return ( -
+
{/* Bo'lim filtri */} -
-

- Bo'lim -

-
- {visibleSectionData.map((item) => ( -
toggleFilter(item)} - className="hover:cursor-pointer flex items-center gap-2" - > - +

+ Bo'lim +

+
+ {visibleSectionData.map((item) => ( +
toggleFilter(item)} + className="hover:cursor-pointer flex items-center gap-2 w-auto shrink-0" > - {hasData(item.name) && ( - - )} - -

{item.name}

-
- ))} + + {hasData(item.name) && ( + + )} + +

{item.name}

+
+ ))} +
+
- -
+ )} {/* O'lcham filtri */} -
-

- O'lcham -

-
- {visibleSectionNumber.map((item) => ( -
toggleFilter(item)} - className="hover:cursor-pointer flex items-center gap-2" - > - +

+ O'lcham +

+
+ {visibleSectionNumber.map((item) => ( +
toggleFilter(item)} + className="hover:cursor-pointer flex items-center gap-2 w-auto shrink-0" > - {hasData(item.name) && ( - - )} - -

{item.name}

-
- ))} + + {hasData(item.name) && ( + + )} + +

{item.name}

+
+ ))} +
+
- -
+ )}
); } diff --git a/components/pages/products/product/products.tsx b/components/pages/products/product/products.tsx index 13781d7..88d3c41 100644 --- a/components/pages/products/product/products.tsx +++ b/components/pages/products/product/products.tsx @@ -4,9 +4,9 @@ import MainProduct from "./mianProduct"; export function Products() { return ( -
+
-
+
{/* filter part */} diff --git a/components/pages/subCategory/card.tsx b/components/pages/subCategory/card.tsx index fa59743..a10f533 100644 --- a/components/pages/subCategory/card.tsx +++ b/components/pages/subCategory/card.tsx @@ -32,7 +32,7 @@ export default function Card({ image, category, }); - router.push(`/${locale}/products/${slug}`); + router.push(`/${locale}/products`); }; return (