From aed8055fbef665984574bc98bb6223c1c54a821a Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 23 Jul 2024 09:42:57 +0700
Subject: <iman> marged develompent & category management

---
 src/lib/home/components/PreferredBrand.jsx | 42 +++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 12 deletions(-)

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

diff --git a/src/lib/home/components/PreferredBrand.jsx b/src/lib/home/components/PreferredBrand.jsx
index 6b64a444..1aa9746b 100644
--- a/src/lib/home/components/PreferredBrand.jsx
+++ b/src/lib/home/components/PreferredBrand.jsx
@@ -1,5 +1,5 @@
-import { Swiper, SwiperSlide } from 'swiper/react'
-import { useCallback, useEffect, useState } from 'react'
+import { Swiper, SwiperProps, SwiperSlide }  from 'swiper/react';
+import  { Navigation, Pagination, Autoplay } from 'swiper';
 import usePreferredBrand from '../hooks/usePreferredBrand'
 import PreferredBrandSkeleton from './Skeleton/PreferredBrandSkeleton'
 import BrandCard from '@/lib/brand/components/BrandCard'
@@ -38,6 +38,22 @@ const PreferredBrand = () => {
 
   const { preferredBrands } = usePreferredBrand(query)
   const { isMobile, isDesktop } = useDevice()
+  const swiperBanner = {
+    modules:[Navigation, Pagination, Autoplay],
+    autoplay: {
+      delay: 4000,
+      disableOnInteraction: false
+    },
+    loop: true,
+    className: 'h-[70px] md:h-[100px] w-full',
+    slidesPerView: isMobile ? 4 : 8,
+    spaceBetween: isMobile ? 12 : 0,
+    pagination: {
+      dynamicBullets: true,
+      dynamicMainBullets: isMobile ? 6 : 8,
+      clickable: true,
+    }
+  }
 
   return (
     <div className='px-4 sm:px-0'>
@@ -54,16 +70,18 @@ const PreferredBrand = () => {
           </Link>
         )}
       </div>
-      {manufactures.isLoading && <PreferredBrandSkeleton />}
-      {!manufactures.isLoading && (
-        <Swiper slidesPerView={isMobile ? 3.5 : 7.5} spaceBetween={isMobile ? 12 : 24} freeMode>
-          {manufactures.map((manufacture) => (
-            <SwiperSlide key={manufacture.id}>
-              <BrandCard brand={manufacture} />
-            </SwiperSlide>
-          ))}
-        </Swiper>
-      )}
+      <div className='border rounded border-gray_r-6'>
+        {preferredBrands.isLoading && <PreferredBrandSkeleton />}
+        {!preferredBrands.isLoading && (
+          <Swiper {...swiperBanner}>
+            {preferredBrands.data?.data.map((brand) => (
+              <SwiperSlide key={brand.id}>
+                <BrandCard brand={brand} />
+              </SwiperSlide>
+            ))}
+          </Swiper>
+        )}
+      </div>
     </div>
   )
 }
-- 
cgit v1.2.3


From cf48c684d2f8da4dd70e2ed0f57623169bc5106f Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 23 Jul 2024 10:01:58 +0700
Subject: <iman> update error code

---
 src/lib/home/components/PreferredBrand.jsx | 34 +-----------------------------
 1 file changed, 1 insertion(+), 33 deletions(-)

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

diff --git a/src/lib/home/components/PreferredBrand.jsx b/src/lib/home/components/PreferredBrand.jsx
index 1aa9746b..f822b9a0 100644
--- a/src/lib/home/components/PreferredBrand.jsx
+++ b/src/lib/home/components/PreferredBrand.jsx
@@ -5,37 +5,10 @@ import PreferredBrandSkeleton from './Skeleton/PreferredBrandSkeleton'
 import BrandCard from '@/lib/brand/components/BrandCard'
 import useDevice from '@/core/hooks/useDevice'
 import Link from '@/core/components/elements/Link/Link'
-import axios from 'axios'
 
 const PreferredBrand = () => {
   let query = 'level_s'
   let params = 'prioritas'
-  const [isLoading, setIsLoading] = useState(true)
-  const [startWith, setStartWith] = useState(null)
-  const [manufactures, setManufactures] = useState([])
-
-  const loadBrand = useCallback(async () => {
-    setIsLoading(true)
-    const name = startWith ? `${startWith}*` : ''
-    const result = await axios(`${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/brands?params=${name}`)
-    
-    setIsLoading(false)
-    setManufactures((manufactures) => [...result.data])
-  }, [startWith])
-
-  const toggleStartWith = (alphabet) => {
-    setManufactures([])
-    if (alphabet == startWith) {
-      setStartWith(null)
-      return
-    }
-    setStartWith(alphabet)
-  }
-
-  useEffect(() => {
-    loadBrand()
-  }, [loadBrand])
-
   const { preferredBrands } = usePreferredBrand(query)
   const { isMobile, isDesktop } = useDevice()
   const swiperBanner = {
@@ -64,11 +37,6 @@ const PreferredBrand = () => {
             Lihat Semua
           </Link>
         )}
-        {isMobile && (
-          <Link href='/shop/brands' className='!text-red-500 font-semibold sm:text-h-sm'>
-            Lihat Semua
-          </Link>
-        )}
       </div>
       <div className='border rounded border-gray_r-6'>
         {preferredBrands.isLoading && <PreferredBrandSkeleton />}
@@ -86,4 +54,4 @@ const PreferredBrand = () => {
   )
 }
 
-export default PreferredBrand
+export default PreferredBrand
\ No newline at end of file
-- 
cgit v1.2.3

