Skip to content

Commit

Permalink
fix bank sort by tier
Browse files Browse the repository at this point in the history
  • Loading branch information
mschneider committed Jan 10, 2025
1 parent 65c622d commit 6cfac26
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,16 @@ const Dashboard: NextPage = () => {

const sortByTier = (tier: string | undefined) => {
const tierOrder: Record<string, number> = {
AAA: 0,
AA: 1,
A: 2,
'A-': 3,
BBB: 4,
BB: 5,
B: 6,
C: 7,
S: 0,
AAA: 1,
AA: 2,
A: 3,
'A-': 4,
BBB: 5,
BB: 6,
B: 7,
C: 8,
D: 9,
}
if (tier) {
return tierOrder[tier]
Expand Down Expand Up @@ -272,8 +274,9 @@ const Dashboard: NextPage = () => {
<div className="border-b border-th-bkg-3">
{banks
.sort((a, b) => {
const aTier = getSuggestedAndCurrentTier(a, midPriceImp)
const bTier = getSuggestedAndCurrentTier(b, midPriceImp)
const aTier = a.tier
const bTier = b.tier
console.log('sort', a.name, a.tier, sortByTier(aTier), b.name, b.tier, sortByTier(bTier))
const aIsReduceOnly = a.areDepositsReduceOnly()
const bIsReduceOnly = b.areDepositsReduceOnly()
if (aIsReduceOnly && !bIsReduceOnly) {
Expand All @@ -282,8 +285,8 @@ const Dashboard: NextPage = () => {
return -1
} else {
return (
sortByTier(aTier?.currentTier?.preset_name) -
sortByTier(bTier?.currentTier?.preset_name)
sortByTier(aTier) -
sortByTier(bTier)
)
}
})
Expand Down

0 comments on commit 6cfac26

Please sign in to comment.