From 266d123ea9a2516913aa6f72d8c5855aea99652c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 29 Aug 2024 15:42:22 +0700 Subject: 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 (
@@ -42,64 +59,69 @@ const CategoryDynamic = () => { return ( -
-
-
{category.name}
- -

{countLevel1} Produk tersedia

-
- Lihat Semua -
-
- {category.categories.map((subCategory) => { - const countLevel2 = subCategoryData[subCategory.idLevel2] || 0; +
+
+
{category.name}
+ +

{countLevel1} Produk tersedia

+
+ Lihat Semua +
+ + {/* Swiper for SubCategories */} + + {category.categories.map((subCategory) => { + const countLevel2 = subCategoryData[subCategory.idLevel2] || 0; - return ( -
-
-
- -
-
{subCategory.name}
- -

- {countLevel2} Produk tersedia -

-
- Lihat Semua -
-
-
- {subCategory.childFrontendIdI.map((childCategory) => ( -
- - -
-
{childCategory.name}
+ return ( + +
+
+
+ +
+
{subCategory.name}
+ +

+ {countLevel2} Produk tersedia +

+
+ Lihat Semua +
+
+
+ {subCategory.childFrontendIdI.map((childCategory) => ( +
+ + +
+
{childCategory.name}
+
+
- + ))}
- ))} +
-
-
- ); - })} + + ); + })} +
-
- + ); })}
-- cgit v1.2.3 From 28691cd9eed9ea4480d978ae83a8a9424caf8ef4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 29 Aug 2024 16:13:51 +0700 Subject: 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 Date: Mon, 2 Sep 2024 13:38:56 +0700 Subject: 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' />
-
{subCategory.name}
+
{subCategory?.name}

{countLevel2} Produk tersedia -- cgit v1.2.3 From 52b6604cac87d06500597de8dd56be61eb6fad10 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 2 Sep 2024 14:46:44 +0700 Subject: 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 (

{categoryManagement && categoryManagement.data?.map((category) => { - const countLevel1 = categoryData[category.categoryIdI] || 0; + // const countLevel1 = categoryData[category.categoryIdI] || 0; return (
{category.name}
- + {/*

{countLevel1} Produk tersedia

-
+
*/} Lihat Semua
@@ -71,7 +71,7 @@ const CategoryDynamic = () => { {category.categories.map((subCategory) => { - const countLevel2 = subCategoryData[subCategory.idLevel2] || 0; + // const countLevel2 = subCategoryData[subCategory.idLevel2] || 0; return ( @@ -87,11 +87,11 @@ const CategoryDynamic = () => { />
{subCategory?.name}
- + {/*

{countLevel2} Produk tersedia

-
+
*/} Lihat Semua
-- cgit v1.2.3 From 969ca83a9adce96b3b58973654b29d3c2dd47a88 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 5 Sep 2024 17:49:57 +0700 Subject: 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