From 266d123ea9a2516913aa6f72d8c5855aea99652c Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 29 Aug 2024 15:42:22 +0700
Subject: <iman> update navbar category link & change category dynamic to
 slider

---
 src/lib/home/components/CategoryDynamic.jsx | 130 ++++++++++++++++------------
 1 file changed, 76 insertions(+), 54 deletions(-)

(limited to 'src/lib/home/components/CategoryDynamic.jsx')

diff --git a/src/lib/home/components/CategoryDynamic.jsx b/src/lib/home/components/CategoryDynamic.jsx
index b7798a24..7f8a4135 100644
--- a/src/lib/home/components/CategoryDynamic.jsx
+++ b/src/lib/home/components/CategoryDynamic.jsx
@@ -4,7 +4,12 @@ import NextImage from 'next/image';
 import Link from "next/link";
 import { createSlug } from '@/core/utils/slug';
 import odooApi from '@/core/api/odooApi';
-import { Skeleton} from '@chakra-ui/react'
+import { Skeleton } from '@chakra-ui/react';
+import { Swiper, SwiperSlide } from 'swiper/react';
+import 'swiper/css';
+import 'swiper/css/navigation';
+import 'swiper/css/pagination';
+import { Navigation, Pagination, Autoplay } from 'swiper';
 
 const CategoryDynamic = () => {
   const { categoryManagement } = useCategoryManagement();
@@ -34,6 +39,18 @@ const CategoryDynamic = () => {
 
     fetchCategoryData();
   }, [categoryManagement.isLoading]);
+
+  const swiperBanner = {
+    autoplay: {
+      delay: 6000,
+      disableOnInteraction: false,
+    },
+    modules: [Pagination, Autoplay],
+    loop: true, 
+    classNames:'mySwiper',
+    slidesPerView: 3,
+    spaceBetween:10, 
+  };
  
   return (
     <div>
@@ -42,64 +59,69 @@ const CategoryDynamic = () => {
           
           return (
             <Skeleton key={category.id} isLoaded={categoryManagement}>
-            <div key={category.id}>
-              <div className='bagian-judul flex flex-row justify-start items-center gap-3 mb-4 mt-4'>
-                <div className='font-semibold sm:text-h-lg mr-2'>{category.name}</div>
-                <Skeleton isLoaded={countLevel1 !=0}>
-                  <p className={`text-gray_r-10 text-sm`}>{countLevel1} Produk tersedia</p>
-                </Skeleton>
-                <Link href={createSlug('/shop/category/', category?.name, category?.categoryIdI)} className="!text-red-500 font-semibold">Lihat Semua</Link>
-              </div>
-              <div className='grid grid-cols-3 gap-2'>
-                {category.categories.map((subCategory) => {
-                  const countLevel2 = subCategoryData[subCategory.idLevel2] || 0;
+              <div key={category.id}>
+                <div className='bagian-judul flex flex-row justify-start items-center gap-3 mb-4 mt-4'>
+                  <div className='font-semibold sm:text-h-lg mr-2'>{category.name}</div>
+                  <Skeleton isLoaded={countLevel1 != 0}>
+                    <p className={`text-gray_r-10 text-sm`}>{countLevel1} Produk tersedia</p>
+                  </Skeleton>
+                  <Link href={createSlug('/shop/category/', category?.name, category?.categoryIdI)} className="!text-red-500 font-semibold">Lihat Semua</Link>
+                </div>
+                
+                {/* Swiper for SubCategories */}
+                <Swiper {...swiperBanner}
+                >
+                  {category.categories.map((subCategory) => {
+                    const countLevel2 = subCategoryData[subCategory.idLevel2] || 0;
 
-                  return (
-                    <div key={subCategory.id} className='border rounded justify-start items-start'>
-                      <div className='p-3'>
-                        <div className='flex flex-row border rounded mb-2 justify-start items-center'>
-                          <NextImage
-                            src={subCategory.image ? subCategory.image : "/images/noimage.jpeg"}
-                            alt={subCategory.name}
-                            width={90}
-                            height={30}
-                            className='object-fit'
-                          />
-                          <div className='bagian-judul flex flex-col justify-center items-start gap-2 ml-2'>
-                            <div className='font-semibold text-lg mr-2'>{subCategory.name}</div>
-                            <Skeleton isLoaded={countLevel2 != 0}>
-                            <p className={`text-gray_r-10 text-sm`}>
-                              {countLevel2} Produk tersedia
-                            </p>
-                            </Skeleton>
-                            <Link href={createSlug('/shop/category/', subCategory?.name, subCategory?.idLevel2)} className="!text-red-500 font-semibold">Lihat Semua</Link>
-                          </div>
-                        </div>
-                        <div className='grid grid-cols-2 gap-2 overflow-y-auto max-h-[240px]'>
-                          {subCategory.childFrontendIdI.map((childCategory) => (
-                            <div key={childCategory.id}>
-                              <Link href={createSlug('/shop/category/', childCategory?.name, childCategory?.idLevel3)} className="flex flex-row gap-2 border rounded group hover:border-red-500">
-                                <NextImage
-                                  src={childCategory.image ? childCategory.image : "/images/noimage.jpeg"}
-                                  alt={childCategory.name}
-                                  className='p-2 ml-1'
-                                  width={40}
-                                  height={40}
-                                />
-                                <div className='bagian-judul flex flex-col justify-center items-center gap-2 break-words line-clamp-2 group-hover:text-red-500'>
-                                  <div className='font-semibold line-clamp-2 group-hover:text-red-500 text-sm mr-2'>{childCategory.name}</div>
+                    return (
+                      <SwiperSlide key={subCategory.id}>
+                        <div className='border rounded justify-start items-start '>
+                          <div className='p-3'>
+                            <div className='flex flex-row border rounded mb-2 justify-start items-center'>
+                              <NextImage
+                                src={subCategory.image ? subCategory.image : "/images/noimage.jpeg"}
+                                alt={subCategory.name}
+                                width={90}
+                                height={30}
+                                className='object-fit'
+                              />
+                              <div className='bagian-judul flex flex-col justify-center items-start gap-2 ml-2'>
+                                <div className='font-semibold text-lg mr-2'>{subCategory.name}</div>
+                                <Skeleton isLoaded={countLevel2 != 0}>
+                                  <p className={`text-gray_r-10 text-sm`}>
+                                    {countLevel2} Produk tersedia
+                                  </p>
+                                </Skeleton>
+                                <Link href={createSlug('/shop/category/', subCategory?.name, subCategory?.idLevel2)} className="!text-red-500 font-semibold">Lihat Semua</Link>
+                              </div>
+                            </div>
+                            <div className='grid grid-cols-2 gap-2 overflow-y-auto max-h-[240px] min-h-[240px] content-start'>
+                              {subCategory.childFrontendIdI.map((childCategory) => (
+                                <div key={childCategory.id} className=''>
+                                  <Link href={createSlug('/shop/category/', childCategory?.name, childCategory?.idLevel3)} className="flex flex-row gap-2 border rounded group hover:border-red-500">
+                                    <NextImage
+                                      src={childCategory.image ? childCategory.image : "/images/noimage.jpeg"}
+                                      alt={childCategory.name}
+                                      className='p-2 ml-1'
+                                      width={40}
+                                      height={40}
+                                    />
+                                    <div className='bagian-judul flex flex-col justify-center items-center gap-2 break-words line-clamp-2 group-hover:text-red-500'>
+                                      <div className='font-semibold line-clamp-2 group-hover:text-red-500 text-sm mr-2'>{childCategory.name}</div>
+                                    </div>
+                                  </Link>
                                 </div>
-                              </Link>
+                              ))}
                             </div>
-                          ))}
+                          </div>
                         </div>
-                      </div>
-                    </div>
-                  );
-                })}
+                      </SwiperSlide>
+                    );
+                  })}
+                </Swiper>
               </div>
-            </div>
-          </Skeleton>
+            </Skeleton>
           );
         })}
     </div>
-- 
cgit v1.2.3


From 28691cd9eed9ea4480d978ae83a8a9424caf8ef4 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 29 Aug 2024 16:13:51 +0700
Subject: <iman> add pagintion

---
 src/lib/home/components/CategoryDynamic.jsx | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'src/lib/home/components/CategoryDynamic.jsx')

diff --git a/src/lib/home/components/CategoryDynamic.jsx b/src/lib/home/components/CategoryDynamic.jsx
index 7f8a4135..48a60323 100644
--- a/src/lib/home/components/CategoryDynamic.jsx
+++ b/src/lib/home/components/CategoryDynamic.jsx
@@ -41,15 +41,15 @@ const CategoryDynamic = () => {
   }, [categoryManagement.isLoading]);
 
   const swiperBanner = {
-    autoplay: {
-      delay: 6000,
-      disableOnInteraction: false,
-    },
-    modules: [Pagination, Autoplay],
+    modules: [Pagination, ],
     loop: true, 
     classNames:'mySwiper',
     slidesPerView: 3,
     spaceBetween:10, 
+    pagination: {
+      dynamicBullets: true,
+      clickable: true,
+    }
   };
  
   return (
-- 
cgit v1.2.3

