Skip to content

Commit

Permalink
Sort sellers by default
Browse files Browse the repository at this point in the history
  • Loading branch information
thalytafabrine committed Feb 16, 2024
1 parent dc5fa94 commit e6d8f01
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/convertSearchDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ const setDefaultSeller = (sellers: Array<Seller & { active: boolean }>): Seller[

const [defaultSeller] = availableSellers.sort((a, b) => (a.commertialOffer.Price > b.commertialOffer.Price ? 1 : -1))

return sellers.map((seller) => {
const sellersWithDefault = sellers.map((seller) => {
return {
sellerId: seller.sellerId,
sellerDefault: seller.sellerId === defaultSeller.sellerId,
Expand All @@ -219,6 +219,8 @@ const setDefaultSeller = (sellers: Array<Seller & { active: boolean }>): Seller[
commertialOffer: seller.commertialOffer,
}
})

return sellersWithDefault.sort((sellerA) => (sellerA.sellerDefault ? -1 : 1))
}

const getSkuSellers = (offer: SkuOfferDetails, unitMultiplier: number) => {
Expand Down

0 comments on commit e6d8f01

Please sign in to comment.