From 6b173eaf8a95432316822b1d41b084875adfbd83 Mon Sep 17 00:00:00 2001
From: "tri.susilo" <tri.susilo@altama.co.id>
Date: Wed, 8 May 2024 14:47:11 +0700
Subject: [agnes] - Feature category management

---
 src/lib/product/components/CategorySection.jsx | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 src/lib/product/components/CategorySection.jsx

(limited to 'src/lib/product/components/CategorySection.jsx')

diff --git a/src/lib/product/components/CategorySection.jsx b/src/lib/product/components/CategorySection.jsx
new file mode 100644
index 00000000..7c347fe8
--- /dev/null
+++ b/src/lib/product/components/CategorySection.jsx
@@ -0,0 +1,22 @@
+import Image from "next/image"
+
+const CategorySection = ({ categories }) => {
+    return (
+        <section className="items-center bg-danger-100">
+            <div className="grid grid-cols-4 gap-2 w-full h-full col-span-2">
+                {categories.map((category) => (
+                    <div class="max-w-sm w-fit gap-4 lg:max-w-full lg:flex bg-white px-4 py-2 border-2 border-gray_r-8 rounded-lg">
+                        <div className="flex items-center justify-center">
+                            <Image src='https://erp.indoteknik.com/api/image/product.template/image_256/544371?ratio=square' width={80} height={80} alt={category?.name} />
+                        </div>
+                        <div class="flex flex-col justify-center leading-normal">
+                            <h2 class="text-gray-900 font-bold text-sm">{category?.name}</h2>
+                        </div>
+                    </div>
+                ))}
+            </div>
+        </section>
+    )
+}
+
+export default CategorySection
\ No newline at end of file
-- 
cgit v1.2.3


From 6c79d14a11c8dba20778c0559230a406cd147cc7 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 3 Jul 2024 08:34:16 +0700
Subject: <iman> update category management

---
 src/lib/product/components/CategorySection.jsx | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

(limited to 'src/lib/product/components/CategorySection.jsx')

diff --git a/src/lib/product/components/CategorySection.jsx b/src/lib/product/components/CategorySection.jsx
index 7c347fe8..c250efeb 100644
--- a/src/lib/product/components/CategorySection.jsx
+++ b/src/lib/product/components/CategorySection.jsx
@@ -1,20 +1,24 @@
 import Image from "next/image"
+import Link from '@/core/components/elements/Link/Link'
+import { createSlug } from '@/core/utils/slug'
 
 const CategorySection = ({ categories }) => {
     return (
-        <section className="items-center bg-danger-100">
-            <div className="grid grid-cols-4 gap-2 w-full h-full col-span-2">
+        <section>
+            <div className="group/item grid grid-cols-5 gap-y-2 w-full h-full col-span-2 ">
                 {categories.map((category) => (
-                    <div class="max-w-sm w-fit gap-4 lg:max-w-full lg:flex bg-white px-4 py-2 border-2 border-gray_r-8 rounded-lg">
-                        <div className="flex items-center justify-center">
-                            <Image src='https://erp.indoteknik.com/api/image/product.template/image_256/544371?ratio=square' width={80} height={80} alt={category?.name} />
-                        </div>
-                        <div class="flex flex-col justify-center leading-normal">
-                            <h2 class="text-gray-900 font-bold text-sm">{category?.name}</h2>
+                    <div className="KartuInti h-24 w-26 max-w-sm   lg:max-w-full flex flex-col   border-[1px] border-gray-200  relative group">
+                        <div className='KartuB absolute h-48 w-60 inset-0 flex items-center justify-center '>
+                            <div className="group/edit flex items-center justify-center h-48 w-60  flex-row group-hover/item:visible">
+                                <div className=' h-36'>
+                                    <Image className="group-hover:scale-110 duration-300"  src='https://erp.indoteknik.com/api/image/product.template/image_256/544371?ratio=square' width={36} height={26} alt={category?.name} />
+                                </div>
+                                <h2 className="text-gray-700 content-center text-wrap h-12 border-t-[1px] w-60 px-1 border-gray-200 font-normal text-sm text-center">{category?.name}</h2>
+                            </div>
                         </div>
                     </div>
                 ))}
-            </div>
+        </div>
         </section>
     )
 }
-- 
cgit v1.2.3


From 1a70984f3497652b8d8b64d16053c1f2be452bd7 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Fri, 5 Jul 2024 10:06:49 +0700
Subject: <iman> update category management

---
 src/lib/product/components/CategorySection.jsx | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

(limited to 'src/lib/product/components/CategorySection.jsx')

diff --git a/src/lib/product/components/CategorySection.jsx b/src/lib/product/components/CategorySection.jsx
index c250efeb..4c66e861 100644
--- a/src/lib/product/components/CategorySection.jsx
+++ b/src/lib/product/components/CategorySection.jsx
@@ -1,26 +1,26 @@
 import Image from "next/image"
-import Link from '@/core/components/elements/Link/Link'
+import Link from 'next/link'
 import { createSlug } from '@/core/utils/slug'
 
 const CategorySection = ({ categories }) => {
     return (
         <section>
-            <div className="group/item grid grid-cols-5 gap-y-2 w-full h-full col-span-2 ">
+            <div className="group/item grid grid-cols-5 gap-y-2 gap-x-2 w-full h-full col-span-2 ">
                 {categories.map((category) => (
-                    <div className="KartuInti h-24 w-26 max-w-sm   lg:max-w-full flex flex-col   border-[1px] border-gray-200  relative group">
-                        <div className='KartuB absolute h-48 w-60 inset-0 flex items-center justify-center '>
-                            <div className="group/edit flex items-center justify-center h-48 w-60  flex-row group-hover/item:visible">
-                                <div className=' h-36'>
-                                    <Image className="group-hover:scale-110 duration-300"  src='https://erp.indoteknik.com/api/image/product.template/image_256/544371?ratio=square' width={36} height={26} alt={category?.name} />
+                    <Link href={createSlug('/shop/category/', category?.name, category?.id)} key={category?.id} passHref>
+                        <div className="group transition-colors duration-300">
+                            <div className="KartuInti h-18 w-26 max-w-sm lg:max-w-full flex flex-col border-[2px] border-gray-200 group-hover:border-red-400 rounded relative ">
+                                <div className="flex items-center justify-center h-full px-1 flex-row">
+                                    <Image className="" src='https://erp.indoteknik.com/api/image/product.template/image_256/544371?ratio=square' width={56} height={48} alt={category?.name} />
+                                    <h2 className="text-gray-700 group-hover:text-[#E20613] line-clamp-2 content-center  h-fit w-60 px-1 font-semibold text-sm text-start">{category?.name}</h2>
                                 </div>
-                                <h2 className="text-gray-700 content-center text-wrap h-12 border-t-[1px] w-60 px-1 border-gray-200 font-normal text-sm text-center">{category?.name}</h2>
                             </div>
                         </div>
-                    </div>
+                    </Link>
                 ))}
-        </div>
+            </div>
         </section>
     )
 }
 
-export default CategorySection
\ No newline at end of file
+export default CategorySection
-- 
cgit v1.2.3


From d6b459b3ea396775fae25b44d34c8dc724379224 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 20 Jul 2024 11:45:41 +0700
Subject: <iman> update mobile view

---
 src/lib/product/components/CategorySection.jsx | 51 +++++++++++++++++++-------
 1 file changed, 38 insertions(+), 13 deletions(-)

(limited to 'src/lib/product/components/CategorySection.jsx')

diff --git a/src/lib/product/components/CategorySection.jsx b/src/lib/product/components/CategorySection.jsx
index 4c66e861..278bda94 100644
--- a/src/lib/product/components/CategorySection.jsx
+++ b/src/lib/product/components/CategorySection.jsx
@@ -1,24 +1,49 @@
 import Image from "next/image"
 import Link from 'next/link'
 import { createSlug } from '@/core/utils/slug'
-
+import useDevice from '@/core/hooks/useDevice';
+import { Swiper, SwiperSlide } from 'swiper/react';
+import 'swiper/css';
 const CategorySection = ({ categories }) => {
+    const { isDesktop, isMobile } = useDevice();
     return (
         <section>
-            <div className="group/item grid grid-cols-5 gap-y-2 gap-x-2 w-full h-full col-span-2 ">
-                {categories.map((category) => (
-                    <Link href={createSlug('/shop/category/', category?.name, category?.id)} key={category?.id} passHref>
-                        <div className="group transition-colors duration-300">
-                            <div className="KartuInti h-18 w-26 max-w-sm lg:max-w-full flex flex-col border-[2px] border-gray-200 group-hover:border-red-400 rounded relative ">
-                                <div className="flex items-center justify-center h-full px-1 flex-row">
-                                    <Image className="" src='https://erp.indoteknik.com/api/image/product.template/image_256/544371?ratio=square' width={56} height={48} alt={category?.name} />
-                                    <h2 className="text-gray-700 group-hover:text-[#E20613] line-clamp-2 content-center  h-fit w-60 px-1 font-semibold text-sm text-start">{category?.name}</h2>
+            {isDesktop && 
+                <div className="group/item grid grid-cols-5 gap-y-2 gap-x-2 w-full h-full col-span-2 ">
+                    {categories.map((category) => (
+                        <Link href={createSlug('/shop/category/', category?.name, category?.id)} key={category?.id} passHref>
+                            <div className="group transition-colors duration-300">
+                                <div className="KartuInti h-18 w-26 max-w-sm lg:max-w-full flex flex-col border-[2px] border-gray-200 group-hover:border-red-400 rounded relative ">
+                                    <div className="flex items-center justify-center h-full px-1 flex-row">
+                                        <Image className="" src={category?.image_1920? category?.image_1920 : '/images/noimage.jpeg'} width={56} height={48} alt={category?.name} />
+                                        <h2 className="text-gray-700 group-hover:text-[#E20613] line-clamp-2 content-center  h-fit w-60 px-1 font-semibold text-sm text-start">{category?.name}</h2>
+                                    </div>
                                 </div>
                             </div>
-                        </div>
-                    </Link>
-                ))}
-            </div>
+                        </Link>
+                    ))}
+                </div>
+            }
+            {isMobile && 
+                <div className="py-4">
+                    <Swiper slidesPerView={2.3} spaceBetween={10}>
+                        {categories.map((category) => (
+                        <SwiperSlide>
+                             <Link href={createSlug('/shop/category/', category?.name, category?.id)} key={category?.id} passHref>
+                                <div className="group transition-colors duration-300">
+                                    <div className="KartuInti h-18 w-26 max-w-sm lg:max-w-full flex flex-col border-[2px] border-gray-200 group-hover:bg-red-200 group-hover:border-red-400 rounded relative ">
+                                        <div className="flex items-center justify-center h-full px-1 flex-row">
+                                            <Image className="" src={category?.image_1920? category?.image_1920 : '/images/noimage.jpeg'} width={56} height={48} alt={category?.name} />
+                                            <h2 className="text-gray-700 group-hover:text-[#E20613] line-clamp-2 content-center  h-fit w-60 px-1 font-semibold text-sm text-start">{category?.name}</h2>
+                                        </div>
+                                    </div>
+                                </div>
+                            </Link>
+                        </SwiperSlide>
+                        ))}
+                    </Swiper>
+                </div>
+            }
         </section>
     )
 }
-- 
cgit v1.2.3


From a78251dc5cdfdd5438aad3ce7b7e342fceb7275e Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 22 Jul 2024 16:57:47 +0700
Subject: <iman> update category management

---
 src/lib/product/components/CategorySection.jsx | 67 +++++++++++++++++++-------
 1 file changed, 50 insertions(+), 17 deletions(-)

(limited to 'src/lib/product/components/CategorySection.jsx')

diff --git a/src/lib/product/components/CategorySection.jsx b/src/lib/product/components/CategorySection.jsx
index 278bda94..e80429f4 100644
--- a/src/lib/product/components/CategorySection.jsx
+++ b/src/lib/product/components/CategorySection.jsx
@@ -4,44 +4,77 @@ import { createSlug } from '@/core/utils/slug'
 import useDevice from '@/core/hooks/useDevice';
 import { Swiper, SwiperSlide } from 'swiper/react';
 import 'swiper/css';
+import { useQuery } from 'react-query'
+import { useRouter } from 'next/router'
+
 const CategorySection = ({ categories }) => {
     const { isDesktop, isMobile } = useDevice();
+    const router = useRouter()
+
+    let teks = router.query.slug;
+    let hasil = teks?.match(/(\d+)$/)[0];
+
+    const breadcrumbs = useQuery(
+        `category-breadcrumbs/${hasil}`,
+        async () => await odooApi('GET', `/api/v1/category/${hasil}/category-breadcrumb`)
+    )
+    
     return (
         <section>
-            {isDesktop && 
+            {isDesktop && (
                 <div className="group/item grid grid-cols-5 gap-y-2 gap-x-2 w-full h-full col-span-2 ">
-                    {categories.map((category) => (
+                    {categories.slice(0, 10).map((category) => (
                         <Link href={createSlug('/shop/category/', category?.name, category?.id)} key={category?.id} passHref>
                             <div className="group transition-colors duration-300">
                                 <div className="KartuInti h-18 w-26 max-w-sm lg:max-w-full flex flex-col border-[2px] border-gray-200 group-hover:border-red-400 rounded relative ">
                                     <div className="flex items-center justify-center h-full px-1 flex-row">
-                                        <Image className="" src={category?.image_1920? category?.image_1920 : '/images/noimage.jpeg'} width={56} height={48} alt={category?.name} />
-                                        <h2 className="text-gray-700 group-hover:text-[#E20613] line-clamp-2 content-center  h-fit w-60 px-1 font-semibold text-sm text-start">{category?.name}</h2>
+                                        <Image className="" src={category?.image_1920 ? category?.image_1920 : '/images/noimage.jpeg'} width={56} height={48} alt={category?.name} />
+                                        <h2 className="text-gray-700 group-hover:text-[#E20613] line-clamp-2 content-center h-fit w-60 px-1 font-semibold text-sm text-start">{category?.name}</h2>
                                     </div>
                                 </div>
                             </div>
                         </Link>
                     ))}
                 </div>
-            }
+            )}
+            {isDesktop && categories.length > 10 && (
+                    <div className="w-full flex justify-end mt-4">
+                        <Link className=" flex justify-end mt-4 bg-red-500 text-white px-4 py-2 rounded" href={createSlug('/shop/category/', breadcrumbs.data[0]?.name, breadcrumbs.data[0]?.id)}>Lihat Semua
+                        </Link>
+                    </div>
+            )}
+
             {isMobile && 
                 <div className="py-4">
                     <Swiper slidesPerView={2.3} spaceBetween={10}>
-                        {categories.map((category) => (
-                        <SwiperSlide>
-                             <Link href={createSlug('/shop/category/', category?.name, category?.id)} key={category?.id} passHref>
-                                <div className="group transition-colors duration-300">
-                                    <div className="KartuInti h-18 w-26 max-w-sm lg:max-w-full flex flex-col border-[2px] border-gray-200 group-hover:bg-red-200 group-hover:border-red-400 rounded relative ">
-                                        <div className="flex items-center justify-center h-full px-1 flex-row">
-                                            <Image className="" src={category?.image_1920? category?.image_1920 : '/images/noimage.jpeg'} width={56} height={48} alt={category?.name} />
-                                            <h2 className="text-gray-700 group-hover:text-[#E20613] line-clamp-2 content-center  h-fit w-60 px-1 font-semibold text-sm text-start">{category?.name}</h2>
-                                        </div>
-                                    </div>
+                    {categories.slice(0, 10).map((category) => (
+                        <SwiperSlide key={category?.id}>
+                        <Link href={createSlug('/shop/category/', category?.name, category?.id)} passHref>
+                            <div className="group transition-colors duration-300">
+                            <div className="KartuInti h-18 w-26 max-w-sm lg:max-w-full flex flex-col border-[2px] border-gray-200 group-hover:bg-red-200 group-hover:border-red-400 rounded relative">
+                                <div className="flex items-center justify-center h-full px-1 flex-row">
+                                <Image
+                                    src={category?.image_1920 ? category?.image_1920 : '/images/noimage.jpeg'}
+                                    width={56}
+                                    height={48}
+                                    alt={category?.name}
+                                />
+                                <h2 className="text-gray-700 group-hover:text-[#E20613] line-clamp-2 content-center h-fit w-60 px-1 font-semibold text-sm text-start">
+                                    {category?.name}
+                                </h2>
                                 </div>
-                            </Link>
+                            </div>
+                            </div>
+                        </Link>
                         </SwiperSlide>
-                        ))}
+                    ))}
                     </Swiper>
+                    {categories.length > 10  && (
+                        <div className="w-full flex justify-end mt-4">
+                            <Link className=" flex justify-end mt-4 bg-red-500 text-white text-sm px-4 py-2 rounded" href={createSlug('/shop/category/', breadcrumbs.data[0]?.name, breadcrumbs.data[0]?.id)}>Lihat Semua
+                            </Link>
+                        </div>
+                    )}
                 </div>
             }
         </section>
-- 
cgit v1.2.3


From bf5c3b1d48da54e0e44689412ad9de9c10cf9edb Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 23 Jul 2024 09:28:21 +0700
Subject: <iman> update category management

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

(limited to 'src/lib/product/components/CategorySection.jsx')

diff --git a/src/lib/product/components/CategorySection.jsx b/src/lib/product/components/CategorySection.jsx
index e80429f4..749a56eb 100644
--- a/src/lib/product/components/CategorySection.jsx
+++ b/src/lib/product/components/CategorySection.jsx
@@ -25,10 +25,10 @@ const CategorySection = ({ categories }) => {
                 <div className="group/item grid grid-cols-5 gap-y-2 gap-x-2 w-full h-full col-span-2 ">
                     {categories.slice(0, 10).map((category) => (
                         <Link href={createSlug('/shop/category/', category?.name, category?.id)} key={category?.id} passHref>
-                            <div className="group transition-colors duration-300">
-                                <div className="KartuInti h-18 w-26 max-w-sm lg:max-w-full flex flex-col border-[2px] border-gray-200 group-hover:border-red-400 rounded relative ">
-                                    <div className="flex items-center justify-center h-full px-1 flex-row">
-                                        <Image className="" src={category?.image_1920 ? category?.image_1920 : '/images/noimage.jpeg'} width={56} height={48} alt={category?.name} />
+                            <div className="group transition-colors duration-300 ">
+                                <div className="KartuInti h-12 w-26 max-w-sm lg:max-w-full flex flex-col border-[2px] border-gray-200 group-hover:border-red-400 rounded relative ">
+                                    <div className="flex items-center justify-start h-full px-1 flex-row">
+                                        <Image className="" src={category?.image1920? category?.image1920 : '/images/noimage.jpeg'} width={56} height={48} alt={category?.name} />
                                         <h2 className="text-gray-700 group-hover:text-[#E20613] line-clamp-2 content-center h-fit w-60 px-1 font-semibold text-sm text-start">{category?.name}</h2>
                                     </div>
                                 </div>
@@ -54,7 +54,7 @@ const CategorySection = ({ categories }) => {
                             <div className="KartuInti h-18 w-26 max-w-sm lg:max-w-full flex flex-col border-[2px] border-gray-200 group-hover:bg-red-200 group-hover:border-red-400 rounded relative">
                                 <div className="flex items-center justify-center h-full px-1 flex-row">
                                 <Image
-                                    src={category?.image_1920 ? category?.image_1920 : '/images/noimage.jpeg'}
+                                    src={category?.image1920 ? category?.image1920 : '/images/noimage.jpeg'}
                                     width={56}
                                     height={48}
                                     alt={category?.name}
-- 
cgit v1.2.3


From b1341b76e94da9e64549768646bb54d2836976d0 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 23 Jul 2024 14:29:08 +0700
Subject: <iman> update categories management

---
 src/lib/product/components/CategorySection.jsx | 109 +++++++++++++++----------
 1 file changed, 68 insertions(+), 41 deletions(-)

(limited to 'src/lib/product/components/CategorySection.jsx')

diff --git a/src/lib/product/components/CategorySection.jsx b/src/lib/product/components/CategorySection.jsx
index 749a56eb..14a39e7e 100644
--- a/src/lib/product/components/CategorySection.jsx
+++ b/src/lib/product/components/CategorySection.jsx
@@ -1,15 +1,23 @@
-import Image from "next/image"
-import Link from 'next/link'
-import { createSlug } from '@/core/utils/slug'
+import Image from "next/image";
+import Link from 'next/link';
+import { createSlug } from '@/core/utils/slug';
 import useDevice from '@/core/hooks/useDevice';
 import { Swiper, SwiperSlide } from 'swiper/react';
 import 'swiper/css';
-import { useQuery } from 'react-query'
-import { useRouter } from 'next/router'
+import { useQuery } from 'react-query';
+import { useRouter } from 'next/router';
+import {
+    ChevronDownIcon,
+    ChevronUpIcon, // Import ChevronUpIcon for toggling
+    DocumentCheckIcon,
+    HeartIcon,
+} from '@heroicons/react/24/outline';
+import { useState } from 'react'; // Import useState
 
 const CategorySection = ({ categories }) => {
     const { isDesktop, isMobile } = useDevice();
-    const router = useRouter()
+    const router = useRouter();
+    const [isOpenCategory, setIsOpenCategory] = useState(false); // State to manage category visibility
 
     let teks = router.query.slug;
     let hasil = teks?.match(/(\d+)$/)[0];
@@ -17,18 +25,24 @@ const CategorySection = ({ categories }) => {
     const breadcrumbs = useQuery(
         `category-breadcrumbs/${hasil}`,
         async () => await odooApi('GET', `/api/v1/category/${hasil}/category-breadcrumb`)
-    )
-    
+    );
+
+    const handleToggleCategories = () => {
+        setIsOpenCategory(!isOpenCategory);
+    };
+
+    const displayedCategories = isOpenCategory ? categories : categories.slice(0, 10);
+
     return (
         <section>
             {isDesktop && (
                 <div className="group/item grid grid-cols-5 gap-y-2 gap-x-2 w-full h-full col-span-2 ">
-                    {categories.slice(0, 10).map((category) => (
+                    {displayedCategories.map((category) => (
                         <Link href={createSlug('/shop/category/', category?.name, category?.id)} key={category?.id} passHref>
                             <div className="group transition-colors duration-300 ">
                                 <div className="KartuInti h-12 w-26 max-w-sm lg:max-w-full flex flex-col border-[2px] border-gray-200 group-hover:border-red-400 rounded relative ">
-                                    <div className="flex items-center justify-start h-full px-1 flex-row">
-                                        <Image className="" src={category?.image1920? category?.image1920 : '/images/noimage.jpeg'} width={56} height={48} alt={category?.name} />
+                                    <div className="flex items-center justify-start h-full px-1 flex-row ">
+                                        <Image className="h-full" src={category?.image1920 ? category?.image1920 : '/images/noimage.jpeg'} width={56} height={48} alt={category?.name} />
                                         <h2 className="text-gray-700 group-hover:text-[#E20613] line-clamp-2 content-center h-fit w-60 px-1 font-semibold text-sm text-start">{category?.name}</h2>
                                     </div>
                                 </div>
@@ -38,45 +52,58 @@ const CategorySection = ({ categories }) => {
                 </div>
             )}
             {isDesktop && categories.length > 10 && (
-                    <div className="w-full flex justify-end mt-4">
-                        <Link className=" flex justify-end mt-4 bg-red-500 text-white px-4 py-2 rounded" href={createSlug('/shop/category/', breadcrumbs.data[0]?.name, breadcrumbs.data[0]?.id)}>Lihat Semua
-                        </Link>
-                    </div>
+                <div className="w-full flex justify-center mt-4">
+                    <button
+                        onClick={handleToggleCategories}
+                        className="flex justify-end mt-4 text-red-500 font-bold px-4 py-2 rounded"
+                    >
+                        {isOpenCategory ? 'Sembunyikan' : 'Lihat semua'}
+                        {isOpenCategory ? (
+                            <ChevronUpIcon className="ml-auto w-5 font-bold" />
+                        ) : (
+                            <ChevronDownIcon className="ml-auto w-5 font-bold" />
+                        )}
+                    </button>
+                </div>
             )}
 
-            {isMobile && 
+            {isMobile && (
                 <div className="py-4">
                     <Swiper slidesPerView={2.3} spaceBetween={10}>
-                    {categories.slice(0, 10).map((category) => (
-                        <SwiperSlide key={category?.id}>
-                        <Link href={createSlug('/shop/category/', category?.name, category?.id)} passHref>
-                            <div className="group transition-colors duration-300">
-                            <div className="KartuInti h-18 w-26 max-w-sm lg:max-w-full flex flex-col border-[2px] border-gray-200 group-hover:bg-red-200 group-hover:border-red-400 rounded relative">
-                                <div className="flex items-center justify-center h-full px-1 flex-row">
-                                <Image
-                                    src={category?.image1920 ? category?.image1920 : '/images/noimage.jpeg'}
-                                    width={56}
-                                    height={48}
-                                    alt={category?.name}
-                                />
-                                <h2 className="text-gray-700 group-hover:text-[#E20613] line-clamp-2 content-center h-fit w-60 px-1 font-semibold text-sm text-start">
-                                    {category?.name}
-                                </h2>
-                                </div>
-                            </div>
-                            </div>
-                        </Link>
-                        </SwiperSlide>
-                    ))}
+                        {displayedCategories.map((category) => (
+                            <SwiperSlide key={category?.id}>
+                                <Link href={createSlug('/shop/category/', category?.name, category?.id)} passHref>
+                                    <div className="group transition-colors duration-300">
+                                        <div className="KartuInti min-h-16 max-h-16 w-26 max-w-sm lg:max-w-full flex flex-col border-[2px] border-gray-200 group-hover:bg-red-200 group-hover:border-red-400 rounded relative">
+                                            <div className="flex items-center justify-center h-full px-1 flex-row">
+                                                <Image
+                                                    src={category?.image1920 ? category?.image1920 : '/images/noimage.jpeg'}
+                                                    width={56}
+                                                    height={48}
+                                                    alt={category?.name}
+                                                />
+                                                <h2 className="text-gray-700 group-hover:text-[#E20613] line-clamp-2 content-center h-fit w-60 px-1 font-semibold text-sm text-start">
+                                                    {category?.name}
+                                                </h2>
+                                            </div>
+                                        </div>
+                                    </div>
+                                </Link>
+                            </SwiperSlide>
+                        ))}
                     </Swiper>
-                    {categories.length > 10  && (
+                    {categories.length > 10 && (
                         <div className="w-full flex justify-end mt-4">
-                            <Link className=" flex justify-end mt-4 bg-red-500 text-white text-sm px-4 py-2 rounded" href={createSlug('/shop/category/', breadcrumbs.data[0]?.name, breadcrumbs.data[0]?.id)}>Lihat Semua
-                            </Link>
+                            <button
+                                onClick={handleToggleCategories}
+                                className="flex justify-end mt-4 bg-red-500 text-white text-sm px-4 py-2 rounded"
+                            >
+                                {isOpenCategory ? 'Sembunyikan Semua' : 'Lihat Semua'}
+                            </button>
                         </div>
                     )}
                 </div>
-            }
+            )}
         </section>
     )
 }
-- 
cgit v1.2.3


From 2e71abba4ca5b83cc1fec229d4d85961c4b56d71 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 25 Jul 2024 08:27:05 +0700
Subject: <iman> update category management

---
 src/lib/product/components/CategorySection.jsx | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

(limited to 'src/lib/product/components/CategorySection.jsx')

diff --git a/src/lib/product/components/CategorySection.jsx b/src/lib/product/components/CategorySection.jsx
index 14a39e7e..2af3db10 100644
--- a/src/lib/product/components/CategorySection.jsx
+++ b/src/lib/product/components/CategorySection.jsx
@@ -13,23 +13,16 @@ import {
     HeartIcon,
 } from '@heroicons/react/24/outline';
 import { useState } from 'react'; // Import useState
+import { getIdFromSlug } from '@/core/utils/slug'
 
 const CategorySection = ({ categories }) => {
     const { isDesktop, isMobile } = useDevice();
-    const router = useRouter();
     const [isOpenCategory, setIsOpenCategory] = useState(false); // State to manage category visibility
 
-    let teks = router.query.slug;
-    let hasil = teks?.match(/(\d+)$/)[0];
-
-    const breadcrumbs = useQuery(
-        `category-breadcrumbs/${hasil}`,
-        async () => await odooApi('GET', `/api/v1/category/${hasil}/category-breadcrumb`)
-    );
-
     const handleToggleCategories = () => {
         setIsOpenCategory(!isOpenCategory);
     };
+    
 
     const displayedCategories = isOpenCategory ? categories : categories.slice(0, 10);
 
-- 
cgit v1.2.3

