summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-09-03 01:54:48 +0000
committertrisusilo <tri.susilo@altama.co.id>2024-09-03 01:54:48 +0000
commit81156ddb13c01868c0e08042813482bfc1d3e353 (patch)
tree036c1cda4678597ed2b45ab296c805ed17de21f0
parentce83c5b1d40b92e7312808d5caa515708f9117d5 (diff)
parent39cf7a6066d3b7064cb57e4f5583232b4d4d2292 (diff)
Merged in delete-topBrand (pull request #288)
<iman> delete popular brand Approved-by: trisusilo
-rw-r--r--src/lib/category/components/Category.jsx4
-rw-r--r--src/lib/category/components/PopularBrand.jsx88
2 files changed, 46 insertions, 46 deletions
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 = () => {
</div>
))}
</div>
- <div className='category-mega-box__child-wrapper !w-[260px] !flex !flex-col !gap-4'>
+ {/* <div className='category-mega-box__child-wrapper !w-[260px] !flex !flex-col !gap-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>
</div>
))}
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