From 556e7e226a2043d43bc55bf0ff2118294bb9f330 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 29 Jul 2024 13:32:39 +0700
Subject: <iman> update lob category

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

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

diff --git a/src/lib/product/components/LobSectionCategory.jsx b/src/lib/product/components/LobSectionCategory.jsx
new file mode 100644
index 00000000..5e9934c3
--- /dev/null
+++ b/src/lib/product/components/LobSectionCategory.jsx
@@ -0,0 +1,89 @@
+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 {
+    ChevronDownIcon,
+    ChevronUpIcon, // Import ChevronUpIcon for toggling
+    DocumentCheckIcon,
+    HeartIcon,
+} from '@heroicons/react/24/outline';
+import { useState } from 'react'; // Import useState
+import { getIdFromSlug } from '@/core/utils/slug'
+
+const LobSectionCategory = ({ categories }) => {
+    const { isDesktop, isMobile } = useDevice();
+    const [isOpenCategory, setIsOpenCategory] = useState(false); // State to manage category visibility
+
+    const handleToggleCategories = () => {
+        setIsOpenCategory(!isOpenCategory);
+    };
+    console.log("categories",categories[0]?.categoryIds)
+
+    const displayedCategories = categories[0]?.categoryIds;
+
+    return (
+        <section>
+            {isDesktop && (
+                <div className="group/item grid grid-flow-col gap-y-2 gap-x-2 w-full h-full">
+                    {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-36 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="h-full w-full" src={category?.image ? category?.image : 'https://erp.indoteknik.com/web/image?model=x_banner.banner&id=5&field=x_banner_image&unique=09202023100557'} width={56} height={48} quality={100} 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>
+            )}
+
+            {isMobile && (
+                <div className="py-4">
+                    <Swiper slidesPerView={2.3} spaceBetween={10}>
+                        {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 && (
+                        <div className="w-full flex justify-end mt-4">
+                            <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>
+    )
+}
+
+export default LobSectionCategory
-- 
cgit v1.2.3


From 1a58c55e6415d78f5d155055071a649d1f56492a Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 29 Jul 2024 14:52:57 +0700
Subject: <iman> update mobile view

---
 src/lib/product/components/LobSectionCategory.jsx | 51 ++++++++++-------------
 1 file changed, 22 insertions(+), 29 deletions(-)

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

diff --git a/src/lib/product/components/LobSectionCategory.jsx b/src/lib/product/components/LobSectionCategory.jsx
index 5e9934c3..34a09e46 100644
--- a/src/lib/product/components/LobSectionCategory.jsx
+++ b/src/lib/product/components/LobSectionCategory.jsx
@@ -29,43 +29,36 @@ const LobSectionCategory = ({ categories }) => {
     return (
         <section>
             {isDesktop && (
-                <div className="group/item grid grid-flow-col gap-y-2 gap-x-2 w-full h-full">
+                <div className="group/item grid grid-flow-col gap-y-2 gap-x-4 w-full h-full">
                     {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-36 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="h-full w-full" src={category?.image ? category?.image : 'https://erp.indoteknik.com/web/image?model=x_banner.banner&id=5&field=x_banner_image&unique=09202023100557'} width={56} height={48} quality={100} 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>
+                        <Link
+                        href={createSlug('/shop/category/', category?.name, category?.id)}
+                        key={category?.id}
+                        passHref
+                        className="block hover:scale-105 transition-transform duration-300 bg-cover bg-center h-[144px]"
+                        style={{
+                          backgroundImage: `url('${category?.image ? category?.image : 'https://erp.indoteknik.com/web/image?model=x_banner.banner&id=5&field=x_banner_image&unique=09202023100557'}')`,
+                        }}
+                      >
+                      </Link>
                     ))}
                 </div>
             )}
 
             {isMobile && (
                 <div className="py-4">
-                    <Swiper slidesPerView={2.3} spaceBetween={10}>
-                        {displayedCategories.map((category) => (
+                    <Swiper slidesPerView={1.2} spaceBetween={10}>
+                        {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
+                                    href={createSlug('/shop/category/', category?.name, category?.id)}
+                                    key={category?.id}
+                                    passHref
+                                    className="block  bg-cover bg-center h-[144px]"
+                                    style={{
+                                    backgroundImage: `url('${category?.image ? category?.image : 'https://erp.indoteknik.com/web/image?model=x_banner.banner&id=5&field=x_banner_image&unique=09202023100557'}')`,
+                                    }}
+                                >
                                 </Link>
                             </SwiperSlide>
                         ))}
-- 
cgit v1.2.3


From 593c508bb87451a985a5aec7e9d7bde45b18074b Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 30 Jul 2024 09:53:35 +0700
Subject: <iman> update category lob

---
 src/lib/product/components/LobSectionCategory.jsx | 1 -
 1 file changed, 1 deletion(-)

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

diff --git a/src/lib/product/components/LobSectionCategory.jsx b/src/lib/product/components/LobSectionCategory.jsx
index 34a09e46..03d6e8c0 100644
--- a/src/lib/product/components/LobSectionCategory.jsx
+++ b/src/lib/product/components/LobSectionCategory.jsx
@@ -22,7 +22,6 @@ const LobSectionCategory = ({ categories }) => {
     const handleToggleCategories = () => {
         setIsOpenCategory(!isOpenCategory);
     };
-    console.log("categories",categories[0]?.categoryIds)
 
     const displayedCategories = categories[0]?.categoryIds;
 
-- 
cgit v1.2.3

