Skip to content

Commit

Permalink
fix store discounts rss
Browse files Browse the repository at this point in the history
  • Loading branch information
saadeghi committed Dec 18, 2023
1 parent ad3a0f2 commit dd134e2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/docs/src/routes/store/+layout.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ export async function load({ params }) {
if (productsResponse.ok) {
storeInfo.products = await productsResponse.json()

// sort
// sort products by id
storeInfo.products.data.sort((a, b) => {
const idA = parseInt(a.id)
const idB = parseInt(b.id)
return idB - idA
return parseInt(b.id) - parseInt(a.id)
})
// add additional product data
storeInfo.products.data.forEach((item) => {
Expand All @@ -35,7 +33,12 @@ export async function load({ params }) {
}
if (discountsResponse.ok) {
storeInfo.discounts = await discountsResponse.json()
// sort discounts by id
storeInfo.discounts.data.sort((a, b) => {
return parseInt(b.id) - parseInt(a.id)
})
}
console.log(storeInfo.discounts.data)
return {
tech,
products: storeInfo.products,
Expand Down

0 comments on commit dd134e2

Please sign in to comment.