diff options
| author | trisusilo48 <tri.susilo@altama.co.id> | 2024-08-23 14:20:08 +0700 |
|---|---|---|
| committer | trisusilo48 <tri.susilo@altama.co.id> | 2024-08-23 14:20:08 +0700 |
| commit | e17210013af6aa12e1641cd9055d892e16409e1e (patch) | |
| tree | 3cc3adb21f804c75379970b36835cb5ae985a744 /src/api | |
| parent | 67731281227f961c9b56f9f310951a8e5c82ab39 (diff) | |
| parent | 0cf2e5aa835155904a1242e74ff7935760513c48 (diff) | |
Merge branch 'release' of https://bitbucket.org/altafixco/next-indoteknik into release
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 } |
