diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-08-23 14:04:44 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-08-23 14:04:44 +0700 |
| commit | 500c6cf822114a82ca90c70b212e2f969f4d30da (patch) | |
| tree | 941b8d53b8dc024166878c1eec6b3e56c73a348e /src/api | |
| parent | 56be886ad93b2bb8bc82fbd14410b3a85662c1d6 (diff) | |
<iman> add ready stock
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/productApi.js | 5 |
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 } |
