summaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/productApi.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/api/productApi.js b/src/api/productApi.js
index feb91257..6d043172 100644
--- a/src/api/productApi.js
+++ b/src/api/productApi.js
@@ -1,10 +1,26 @@
+import odooApi from '@/core/api/odooApi'
+import productSearchApi from '@/lib/product/api/productSearchApi'
import axios from 'axios'
+import { useState } from 'react'
export const popularProductApi = () => {
+ let dataFlashSale = null
return async () => {
+ const flashSale = await odooApi('GET', '/api/v1/flashsale/header')
+ if(flashSale){
+ const dataProducts = await productSearchApi({
+ query: `fq=flashsale_id_i:${flashSale[0].pricelistId}&fq=flashsale_price_f:[1 TO *]&limit=2`,
+ operation: 'AND'
+ })
+ dataFlashSale = dataProducts.response.products
+ }
const dataPopularProducts = await axios(
`${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/search?q=*&page=1&orderBy=popular-weekly`
)
+ dataPopularProducts.data.response.products = [
+ ...dataFlashSale,
+ ...dataPopularProducts.data.response.products,
+ ];
return dataPopularProducts.data.response
}
}