diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-09-03 08:53:30 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-09-03 08:53:30 +0700 |
| commit | 39cf7a6066d3b7064cb57e4f5583232b4d4d2292 (patch) | |
| tree | 036c1cda4678597ed2b45ab296c805ed17de21f0 /src/lib/category/components/PopularBrand.jsx | |
| parent | ce83c5b1d40b92e7312808d5caa515708f9117d5 (diff) | |
<iman> delete popular brand
Diffstat (limited to 'src/lib/category/components/PopularBrand.jsx')
| -rw-r--r-- | src/lib/category/components/PopularBrand.jsx | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/src/lib/category/components/PopularBrand.jsx b/src/lib/category/components/PopularBrand.jsx index 4777fded..8124b5b4 100644 --- a/src/lib/category/components/PopularBrand.jsx +++ b/src/lib/category/components/PopularBrand.jsx @@ -13,60 +13,60 @@ import { fetchPopulerProductSolr } from '../api/popularProduct' const SOLR_HOST = process.env.SOLR_HOST const PopularBrand = ({ category }) => { - const [topBrands, setTopBrands] = useState([]); + // const [topBrands, setTopBrands] = useState([]); - const fetchTopBrands = async () => { - try { - const items = await fetchPopulerProductSolr(`category_id_ids:(${category?.categoryDataIds?.join(' OR ')})`); - const getTop12UniqueBrands = (prod) => { - const brandMap = new Map(); + // const fetchTopBrands = async () => { + // try { + // const items = await fetchPopulerProductSolr(`category_id_ids:(${category?.categoryDataIds?.join(' OR ')})`); + // const getTop12UniqueBrands = (prod) => { + // const brandMap = new Map(); - for (const product of prod) { - const { manufacture_name, manufacture_id, qty_sold } = product; + // for (const product of prod) { + // const { manufacture_name, manufacture_id, qty_sold } = product; - if (brandMap.has(manufacture_name)) { - // Update the existing brand's qty_sold - brandMap.set(manufacture_name, { - name: manufacture_name, - id: manufacture_id, - qty_sold: brandMap.get(manufacture_name).qty_sold + qty_sold - }); - } else { - // Add a new brand to the map - brandMap.set(manufacture_name, { - name: manufacture_name, - id: manufacture_id, - qty_sold - }); - } - } + // if (brandMap.has(manufacture_name)) { + // // Update the existing brand's qty_sold + // brandMap.set(manufacture_name, { + // name: manufacture_name, + // id: manufacture_id, + // qty_sold: brandMap.get(manufacture_name).qty_sold + qty_sold + // }); + // } else { + // // Add a new brand to the map + // brandMap.set(manufacture_name, { + // name: manufacture_name, + // id: manufacture_id, + // qty_sold + // }); + // } + // } - // Convert the map to an array and sort by qty_sold in descending order - const sortedBrands = Array.from(brandMap.values()).sort((a, b) => b.qty_sold - a.qty_sold); + // // Convert the map to an array and sort by qty_sold in descending order + // const sortedBrands = Array.from(brandMap.values()).sort((a, b) => b.qty_sold - a.qty_sold); - // Return the top 12 brands - return sortedBrands.slice(0, 18); - }; + // // Return the top 12 brands + // return sortedBrands.slice(0, 18); + // }; - // Using the fetched products - const products = items; - const top12UniqueBrands = getTop12UniqueBrands(products); + // // Using the fetched products + // const products = items; + // const top12UniqueBrands = getTop12UniqueBrands(products); - // Set the top 12 brands to the state - setTopBrands(top12UniqueBrands); - } catch (error) { - console.error("Error fetching data from Solr", error); - throw error; - } - } + // // Set the top 12 brands to the state + // setTopBrands(top12UniqueBrands); + // } catch (error) { + // console.error("Error fetching data from Solr", error); + // throw error; + // } + // } - useEffect(() => { - fetchTopBrands(); - }, [category]); + // useEffect(() => { + // fetchTopBrands(); + // }, [category]); return ( <div className='flex flex-col'> - <div className='grid grid-cols-3 max-h-full w-full gap-2'> + {/* <div className='grid grid-cols-3 max-h-full w-full gap-2'> {topBrands.map((brand, index) => ( <div key={index} className='w-full flex items-center justify-center pb-2'> <Link @@ -77,7 +77,7 @@ const PopularBrand = ({ category }) => { </Link> </div> ))} - </div> + </div> */} {/* {topBrands.length > 8 && ( <div className='flex hover:bg-gray_r-8/35 rounded-10'> <Link |
