summaryrefslogtreecommitdiff
path: root/src/pages/index.js
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-02-01 09:15:32 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-02-01 09:15:32 +0700
commitba023d9022189343d83998af8586ea65ddf1cf28 (patch)
tree4f511cdb33a52f7b81db015e7436ac33b6575844 /src/pages/index.js
parent1db44ff539ca77ceff4bc8affa87ba16b8c12705 (diff)
Fix get category homepage
Diffstat (limited to 'src/pages/index.js')
-rw-r--r--src/pages/index.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/pages/index.js b/src/pages/index.js
index b233f81e..94be7f3a 100644
--- a/src/pages/index.js
+++ b/src/pages/index.js
@@ -42,11 +42,18 @@ export default function Home({ heroBanners }) {
getPopularProducts();
const getCategoryProducts = async () => {
- const dataCategoryProducts = await apiOdoo('GET', '/api/v1/categories_homepage');
- setCategoryProducts(dataCategoryProducts);
+ if (!categoryProducts) {
+ const categoryIds = await apiOdoo('GET', '/api/v1/categories_homepage/ids');
+ const categories = [];
+ for (const id in categoryIds) {
+ const dataCategoryProducts = await apiOdoo('GET', `/api/v1/categories_homepage?id=${id}`);
+ categories.push(...dataCategoryProducts);
+ setCategoryProducts(categories);
+ }
+ }
}
getCategoryProducts();
- }, []);
+ }, [ categoryProducts ]);
return (
<>