summaryrefslogtreecommitdiff
path: root/src/api/productApi.js
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-08-31 09:25:53 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-08-31 09:25:53 +0700
commit6a0c477de3df773f2a818b904029624c212f083f (patch)
treee1f7a09eb83509de594fe7dbb015a71dd18cec26 /src/api/productApi.js
parent3de1a412bba31b19b8b443dd91df8aff8d6eda07 (diff)
parentc6e970598c6c23f0606d1bc19036f0decd57cc05 (diff)
Merge branch 'release' into Feature/new-cart-popup
Diffstat (limited to 'src/api/productApi.js')
-rw-r--r--src/api/productApi.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/api/productApi.js b/src/api/productApi.js
index 009d95ef..4a29b59d 100644
--- a/src/api/productApi.js
+++ b/src/api/productApi.js
@@ -2,8 +2,11 @@ import axios from 'axios'
export const popularProductApi = () => {
return async () => {
+ const today = new Date();
+ const dayOfYear = Math.floor((today - new Date(today.getFullYear(), 0, 0)) / 86400000);
+ const page = (dayOfYear % 24) + 1;
const dataPopularProducts = await axios(
- `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/search?q=*&page=1&orderBy=popular-weekly&priceFrom=1`
+ `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/search?q=*&page=${page}&orderBy=stock&priceFrom=1`
)
return dataPopularProducts.data.response
}