From 39cf7a6066d3b7064cb57e4f5583232b4d4d2292 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 3 Sep 2024 08:53:30 +0700 Subject: delete popular brand --- src/lib/category/components/Category.jsx | 4 +- src/lib/category/components/PopularBrand.jsx | 88 ++++++++++++++-------------- 2 files changed, 46 insertions(+), 46 deletions(-) (limited to 'src/lib') diff --git a/src/lib/category/components/Category.jsx b/src/lib/category/components/Category.jsx index f76e6e42..91553295 100644 --- a/src/lib/category/components/Category.jsx +++ b/src/lib/category/components/Category.jsx @@ -86,14 +86,14 @@ const Category = () => { ))} -
+ {/*
{Array.isArray(promotionProgram?.data) && promotionProgram?.data.length > 0 && promotionProgram?.data[0]?.map((banner, index) => (
{`${banner.name}`}
))} -
+
*/} ))} 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 (
-
+ {/*
{topBrands.map((brand, index) => (
{
))} -
+
*/} {/* {topBrands.length > 8 && (