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


From 4710e3573a8af2f38f03f8da4a2ab9d7f3115415 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 2 Sep 2024 13:38:56 +0700
Subject: <iman> delete fungsi loop

---
 src/lib/home/components/CategoryDynamic.jsx | 9 ++++-----
 1 file changed, 4 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 48a60323..0ab9312a 100644
--- a/src/lib/home/components/CategoryDynamic.jsx
+++ b/src/lib/home/components/CategoryDynamic.jsx
@@ -27,8 +27,8 @@ const CategoryDynamic = () => {
           
           updatedCategoryData[category.categoryIdI] = countLevel1?.numFound;
           
-          for (const subCategory of countLevel1.children) {
-            updatedSubCategoryData[subCategory.id] = subCategory.numFound;
+          for (const subCategory of countLevel1?.children) {
+            updatedSubCategoryData[subCategory.id] = subCategory?.numFound;
           }
         }
 
@@ -42,7 +42,6 @@ const CategoryDynamic = () => {
 
   const swiperBanner = {
     modules: [Pagination, ],
-    loop: true, 
     classNames:'mySwiper',
     slidesPerView: 3,
     spaceBetween:10, 
@@ -84,10 +83,10 @@ const CategoryDynamic = () => {
                                 alt={subCategory.name}
                                 width={90}
                                 height={30}
-                                className='object-fit'
+                                className='object-fit p-4'
                               />
                               <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>
+                                <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
-- 
cgit v1.2.3


From 52b6604cac87d06500597de8dd56be61eb6fad10 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 2 Sep 2024 14:46:44 +0700
Subject: <iman> update category management

---
 src/lib/home/components/CategoryDynamic.jsx | 52 ++++++++++++++---------------
 1 file changed, 26 insertions(+), 26 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 0ab9312a..c257e9f9 100644
--- a/src/lib/home/components/CategoryDynamic.jsx
+++ b/src/lib/home/components/CategoryDynamic.jsx
@@ -13,32 +13,32 @@ import { Navigation, Pagination, Autoplay } from 'swiper';
 
 const CategoryDynamic = () => {
   const { categoryManagement } = useCategoryManagement();
-  const [categoryData, setCategoryData] = useState({});
-  const [subCategoryData, setSubCategoryData] = useState({});
+  // const [categoryData, setCategoryData] = useState({});
+  // const [subCategoryData, setSubCategoryData] = useState({});
   
-  useEffect(() => {
-    const fetchCategoryData = async () => {
-      if (categoryManagement && categoryManagement.data) {
-        const updatedCategoryData = {};
-        const updatedSubCategoryData = {};
+  // useEffect(() => {
+  //   const fetchCategoryData = async () => {
+  //     if (categoryManagement && categoryManagement.data) {
+  //       const updatedCategoryData = {};
+  //       const updatedSubCategoryData = {};
         
-        for (const category of categoryManagement.data) {
-          const countLevel1 = await odooApi('GET', `/api/v1/category/numFound?parent_id=${category.categoryIdI}`);
+  //       for (const category of categoryManagement.data) {
+  //         const countLevel1 = await odooApi('GET', `/api/v1/category/numFound?parent_id=${category.categoryIdI}`);
           
-          updatedCategoryData[category.categoryIdI] = countLevel1?.numFound;
+  //         updatedCategoryData[category.categoryIdI] = countLevel1?.numFound;
           
-          for (const subCategory of countLevel1?.children) {
-            updatedSubCategoryData[subCategory.id] = subCategory?.numFound;
-          }
-        }
+  //         for (const subCategory of countLevel1?.children) {
+  //           updatedSubCategoryData[subCategory.id] = subCategory?.numFound;
+  //         }
+  //       }
 
-        setCategoryData(updatedCategoryData);
-        setSubCategoryData(updatedSubCategoryData);
-      }
-    };
+  //       setCategoryData(updatedCategoryData);
+  //       setSubCategoryData(updatedSubCategoryData);
+  //     }
+  //   };
 
-    fetchCategoryData();
-  }, [categoryManagement.isLoading]);
+  //   fetchCategoryData();
+  // }, [categoryManagement.isLoading]);
 
   const swiperBanner = {
     modules: [Pagination, ],
@@ -54,16 +54,16 @@ const CategoryDynamic = () => {
   return (
     <div>
         {categoryManagement && categoryManagement.data?.map((category) => {
-          const countLevel1 = categoryData[category.categoryIdI] || 0;
+          // const countLevel1 = categoryData[category.categoryIdI] || 0;
           
           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}>
+                  {/* <Skeleton isLoaded={countLevel1 != 0}>
                     <p className={`text-gray_r-10 text-sm`}>{countLevel1} Produk tersedia</p>
-                  </Skeleton>
+                  </Skeleton> */}
                   <Link href={createSlug('/shop/category/', category?.name, category?.categoryIdI)} className="!text-red-500 font-semibold">Lihat Semua</Link>
                 </div>
                 
@@ -71,7 +71,7 @@ const CategoryDynamic = () => {
                 <Swiper {...swiperBanner}
                 >
                   {category.categories.map((subCategory) => {
-                    const countLevel2 = subCategoryData[subCategory.idLevel2] || 0;
+                    // const countLevel2 = subCategoryData[subCategory.idLevel2] || 0;
 
                     return (
                       <SwiperSlide key={subCategory.id}>
@@ -87,11 +87,11 @@ const CategoryDynamic = () => {
                               />
                               <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}>
+                                {/* <Skeleton isLoaded={countLevel2 != 0}>
                                   <p className={`text-gray_r-10 text-sm`}>
                                     {countLevel2} Produk tersedia
                                   </p>
-                                </Skeleton>
+                                </Skeleton> */}
                                 <Link href={createSlug('/shop/category/', subCategory?.name, subCategory?.idLevel2)} className="!text-red-500 font-semibold">Lihat Semua</Link>
                               </div>
                             </div>
-- 
cgit v1.2.3


From 969ca83a9adce96b3b58973654b29d3c2dd47a88 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 5 Sep 2024 17:49:57 +0700
Subject: <iman> update mapping solr

---
 src/lib/home/components/CategoryDynamic.jsx | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

(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 c257e9f9..11a15d6d 100644
--- a/src/lib/home/components/CategoryDynamic.jsx
+++ b/src/lib/home/components/CategoryDynamic.jsx
@@ -1,5 +1,6 @@
-import React, { useEffect, useState } from 'react';
+import React, { useEffect, useState, useCallback } from 'react';
 import useCategoryManagement from '../hooks/useCategoryManagement';
+import {fetchPopulerProductSolr} from '../api/categoryManagementApi'
 import NextImage from 'next/image';
 import Link from "next/link";
 import { createSlug } from '@/core/utils/slug';
@@ -12,6 +13,28 @@ import 'swiper/css/pagination';
 import { Navigation, Pagination, Autoplay } from 'swiper';
 
 const CategoryDynamic = () => {
+
+  const [manufactures, setManufactures] = useState([])
+  const loadBrand = useCallback(async () => {
+    // setIsLoading(true)
+    //Get brand from odoo
+    /*const result = await odooApi(
+      'GET',
+      `/api/v1/manufacture?limit=0&offset=${manufactures.length}&name=${name}`
+    )*/
+
+    // Change get brands from solr
+    const items = await fetchPopulerProductSolr();
+
+    console.log("items",items)
+    
+    // setIsLoading(false)
+    // setManufactures((manufactures) => [...result.data])
+  }, [])
+
+  useEffect(() => {
+    loadBrand()
+  }, [loadBrand])
   const { categoryManagement } = useCategoryManagement();
   // const [categoryData, setCategoryData] = useState({});
   // const [subCategoryData, setSubCategoryData] = useState({});
-- 
cgit v1.2.3

