From 1a3bef5d01fb50ad731f269f0a76b5c5fd52813d Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 22 Jul 2024 16:56:30 +0700
Subject: <update brand view

---
 src/lib/home/components/PreferredBrand.jsx | 41 ++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 11 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 571c4745..fc899665 100644
--- a/src/lib/home/components/PreferredBrand.jsx
+++ b/src/lib/home/components/PreferredBrand.jsx
@@ -1,4 +1,5 @@
-import { Swiper, SwiperSlide } from 'swiper/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'
@@ -10,6 +11,22 @@ const PreferredBrand = () => {
   let params = 'prioritas'
   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'>
@@ -21,16 +38,18 @@ const PreferredBrand = () => {
           </Link>
         )}
       </div>
-      {preferredBrands.isLoading && <PreferredBrandSkeleton />}
-      {!preferredBrands.isLoading && (
-        <Swiper slidesPerView={isMobile ? 3.5 : 7.5} spaceBetween={isMobile ? 12 : 24} freeMode>
-          {preferredBrands.data?.data.map((brand) => (
-            <SwiperSlide key={brand.id}>
-              <BrandCard brand={brand} />
-            </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 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/home/components/PreferredBrand.jsx | 44 ++++++++++++++++++++++++------
 1 file changed, 36 insertions(+), 8 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 fc899665..ae12505d 100644
--- a/src/lib/home/components/PreferredBrand.jsx
+++ b/src/lib/home/components/PreferredBrand.jsx
@@ -1,14 +1,42 @@
-import { Swiper, SwiperProps, SwiperSlide }  from 'swiper/react';
+import { Swiper, SwiperSlide } from 'swiper/react'
 import  { Navigation, Pagination, Autoplay } from 'swiper';
+import { useCallback, useEffect, useState } from 'react'
 import usePreferredBrand from '../hooks/usePreferredBrand'
 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 = {
@@ -27,7 +55,7 @@ const PreferredBrand = () => {
       clickable: true,
     }
   }
-
+  const preferredBrandsData = manufactures ? manufactures.slice(0, 20) : []
   return (
     <div className='px-4 sm:px-0'>
       <div className='flex justify-between items-center mb-4'>
@@ -39,12 +67,12 @@ const PreferredBrand = () => {
         )}
       </div>
       <div className='border rounded border-gray_r-6'>
-        {preferredBrands.isLoading && <PreferredBrandSkeleton />}
-        {!preferredBrands.isLoading && (
+        {manufactures.isLoading && <PreferredBrandSkeleton />}
+        {!manufactures.isLoading && (
           <Swiper {...swiperBanner}>
-            {preferredBrands.data?.data.map((brand) => (
-              <SwiperSlide key={brand.id}>
-                <BrandCard brand={brand} />
+            {preferredBrandsData.map((manufacture) => (
+              <SwiperSlide key={manufacture.id}>
+                <BrandCard brand={manufacture} />
               </SwiperSlide>
             ))}
           </Swiper>
@@ -54,4 +82,4 @@ const PreferredBrand = () => {
   )
 }
 
-export default PreferredBrand
+export default PreferredBrand
\ No newline at end of file
-- 
cgit v1.2.3


From 7e26430c7e808c167a330fc2cd4ce217f288757c Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 20 Aug 2024 16:29:22 +0700
Subject: <iman> delete border brand homepage

---
 src/lib/home/components/PreferredBrand.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(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 fdefb526..56268db7 100644
--- a/src/lib/home/components/PreferredBrand.jsx
+++ b/src/lib/home/components/PreferredBrand.jsx
@@ -71,7 +71,7 @@ const PreferredBrand = () => {
           </Link>
         )}
       </div>
-      <div className='border rounded border-gray_r-6'>
+      <div className=''>
         {manufactures.isLoading && <PreferredBrandSkeleton />}
         {!manufactures.isLoading && (
           <Swiper {...swiperBanner}>
-- 
cgit v1.2.3


From c28642a0003f0bd996614cb6849d951c7e276a11 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Tue, 17 Sep 2024 14:37:18 +0700
Subject: optimize page and tag html

---
 src/lib/home/components/PreferredBrand.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(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 b30fa5c9..973bb77e 100644
--- a/src/lib/home/components/PreferredBrand.jsx
+++ b/src/lib/home/components/PreferredBrand.jsx
@@ -59,7 +59,7 @@ const PreferredBrand = () => {
   return (
     <div className='px-4 sm:px-0'>
       <div className='flex justify-between items-center mb-4'>
-        <div className='font-semibold sm:text-h-lg'>Brand Pilihan</div>
+        <h1 className='font-semibold sm:text-h-lg'><Link href='/shop/brands' className='!text-black font-semibold'>Brand Pilihan</Link></h1>
         {isDesktop && (
           <Link href='/shop/brands' className='!text-red-500 font-semibold'>
             Lihat Semua
-- 
cgit v1.2.3


From 87f8fc7887ac03558b1edd819bff31f44ca84f71 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Tue, 17 Sep 2024 15:03:27 +0700
Subject: v mobile

---
 src/lib/home/components/PreferredBrand.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(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 973bb77e..4d53272b 100644
--- a/src/lib/home/components/PreferredBrand.jsx
+++ b/src/lib/home/components/PreferredBrand.jsx
@@ -59,7 +59,7 @@ const PreferredBrand = () => {
   return (
     <div className='px-4 sm:px-0'>
       <div className='flex justify-between items-center mb-4'>
-        <h1 className='font-semibold sm:text-h-lg'><Link href='/shop/brands' className='!text-black font-semibold'>Brand Pilihan</Link></h1>
+        <h1 className='font-semibold text-[14px] sm:text-h-lg'><Link href='/shop/brands' className='!text-black font-semibold'>Brand Pilihan</Link></h1>
         {isDesktop && (
           <Link href='/shop/brands' className='!text-red-500 font-semibold'>
             Lihat Semua
-- 
cgit v1.2.3


From 840b50072a885dd3cf41ea3351d70c9a1d525ff4 Mon Sep 17 00:00:00 2001
From: trisusilo48 <tri.susilo@altama.co.id>
Date: Fri, 20 Sep 2024 15:11:11 +0700
Subject: update quiery preference brands

---
 src/lib/home/components/PreferredBrand.jsx | 8 ++++----
 1 file changed, 4 insertions(+), 4 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 4d53272b..eefced60 100644
--- a/src/lib/home/components/PreferredBrand.jsx
+++ b/src/lib/home/components/PreferredBrand.jsx
@@ -9,7 +9,7 @@ import Link from '@/core/components/elements/Link/Link'
 import axios from 'axios'
 
 const PreferredBrand = () => {
-  let query = 'level_s'
+  let query = ''
   let params = 'prioritas'
   const [isLoading, setIsLoading] = useState(true)
   const [startWith, setStartWith] = useState(null)
@@ -18,7 +18,7 @@ const PreferredBrand = () => {
   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}`)
+    const result = await axios(`${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/brands?rows=20`)
     
     setIsLoading(false)
     setManufactures((manufactures) => [...result.data])
@@ -35,9 +35,9 @@ const PreferredBrand = () => {
 
   useEffect(() => {
     loadBrand()
-  }, [loadBrand])
+  }, [])
 
-  const { preferredBrands } = usePreferredBrand(query)
+  // const { preferredBrands } = usePreferredBrand(query)
   const { isMobile, isDesktop } = useDevice()
   const swiperBanner = {
     modules:[Navigation, Pagination, Autoplay],
-- 
cgit v1.2.3

