summaryrefslogtreecommitdiff
path: root/src/lib/category/components/Category.jsx
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-08-31 09:25:53 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-08-31 09:25:53 +0700
commit6a0c477de3df773f2a818b904029624c212f083f (patch)
treee1f7a09eb83509de594fe7dbb015a71dd18cec26 /src/lib/category/components/Category.jsx
parent3de1a412bba31b19b8b443dd91df8aff8d6eda07 (diff)
parentc6e970598c6c23f0606d1bc19036f0decd57cc05 (diff)
Merge branch 'release' into Feature/new-cart-popup
Diffstat (limited to 'src/lib/category/components/Category.jsx')
-rw-r--r--src/lib/category/components/Category.jsx47
1 files changed, 15 insertions, 32 deletions
diff --git a/src/lib/category/components/Category.jsx b/src/lib/category/components/Category.jsx
index c147a3b3..f76e6e42 100644
--- a/src/lib/category/components/Category.jsx
+++ b/src/lib/category/components/Category.jsx
@@ -5,12 +5,17 @@ import { createSlug } from '@/core/utils/slug'
import { ChevronRightIcon } from '@heroicons/react/24/outline'
import Image from 'next/image'
import { useEffect, useState } from 'react'
+import PopularBrand from './PopularBrand'
+import { bannerApi } from '@/api/bannerApi';
+const { useQuery } = require('react-query')
const Category = () => {
const [categories, setCategories] = useState([])
const [openCategories, setOpenCategory] = useState([]);
-
+ const [banner, setBanner] = useState([]);
+ const promotionProgram = useQuery('banner-promo-category-card', bannerApi({ type: 'banner-promo-category-card' }));
+
useEffect(() => {
const loadCategories = async () => {
let dataCategories = await odooApi('GET', '/api/v1/category/tree')
@@ -30,7 +35,6 @@ const Category = () => {
}
loadCategories()
}, [])
-
return (
<DesktopView>
<div className='category-mega-box'>
@@ -38,8 +42,11 @@ const Category = () => {
<div key={category.id} className='flex'>
<Link
href={createSlug('/shop/category/', category.name, category.id)}
- className='category-mega-box__parent'
+ className='category-mega-box__parent flex items-center'
>
+ <div className='mr-2 flex justify-center items-center'>
+ <Image src={category.image} alt='' width={25} height={25} />
+ </div>
{category.name}
</Link>
<div className='category-mega-box__child-wrapper'>
@@ -80,36 +87,12 @@ const Category = () => {
))}
</div>
<div className='category-mega-box__child-wrapper !w-[260px] !flex !flex-col !gap-4'>
- <div className='flex flex-col'>
- <div className='grid grid-cols-2 max-h-full w-full gap-2'>
- {category.childs.map((brand, index) => (
- (index < 8 ) && (
- <div key={brand.id} className='w-full flex items-center justify-center pb-2'>
- <Link
- href={createSlug('/shop/category/', brand.name, brand.id)}
- className='category-mega-box__child-one w-fit h-full flex items-center justify-center '
- >
- <Image src='https://erp.indoteknik.com/api/image/x_manufactures/x_logo_manufacture/661' alt='' width={104} height={44} objectFit='cover' />
- </Link>
- </div>
- )
- ))}
- </div>
- {category.childs.length > 8 && (
- <div className='flex hover:bg-gray_r-8/35 rounded-10'>
- <Link
- href={createSlug('/shop/category/', category.name, category.id)}
- className='category-mega-box__child-one flex items-center gap-4 font-bold hover:ml-4'
- >
- <p className='mt-2 mb-0 text-danger-500 font-semibold'>Lihat Semua Brand</p>
- <ChevronRightIcon className='w-4 text-danger-500 font-bold' />
- </Link>
- </div>
- )}
- </div>
- <div className='flex w-60 h-20 object-cover'>
- <Image src='https://erp.indoteknik.com/api/image/x_banner.banner/x_banner_image/397' alt='' width={275} height={4} />
+ <PopularBrand category={category} />
+ {Array.isArray(promotionProgram?.data) && promotionProgram?.data.length > 0 && promotionProgram?.data[0]?.map((banner, index) => (
+ <div key={index} className='flex w-60 h-20 object-cover'>
+ <Image src={`${banner.image}`} alt={`${banner.name}`} width={275} height={4} />
</div>
+ ))}
</div>
</div>
</div>