Skip to content

Commit

Permalink
display on-chain tier and detected tier instead of suggested tier (#451)
Browse files Browse the repository at this point in the history
* display on-chain tier and detected tier instead of suggested tier
* fix bank sort by tier
* fix lint
  • Loading branch information
mschneider authored Jan 10, 2025
1 parent 81dc9bb commit 9d42fed
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 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 @@ -266,25 +268,20 @@ const Dashboard: NextPage = () => {
<h3 className="mb-3 mt-6 flex text-base text-th-fgd-3">
<span>Banks</span>
<span className="ml-auto pr-12 text-sm font-normal">
Current / <span className="text-th-success">Suggested</span>{' '}
Current / <span className="text-th-success">Detected</span>{' '}
</span>
</h3>
<div className="border-b border-th-bkg-3">
{banks
.sort((a, b) => {
const aTier = getSuggestedAndCurrentTier(a, midPriceImp)
const bTier = getSuggestedAndCurrentTier(b, midPriceImp)
const aIsReduceOnly = a.areDepositsReduceOnly()
const bIsReduceOnly = b.areDepositsReduceOnly()
if (aIsReduceOnly && !bIsReduceOnly) {
return 1
} else if (!aIsReduceOnly && bIsReduceOnly) {
return -1
} else {
return (
sortByTier(aTier?.currentTier?.preset_name) -
sortByTier(bTier?.currentTier?.preset_name)
)
return sortByTier(a.tier) - sortByTier(b.tier)
}
})
.map((bank, i) => {
Expand Down Expand Up @@ -944,10 +941,10 @@ const BankDisclosure = ({
</div>
<div className="flex items-center space-x-3">
<div className="flex space-x-2">
<div>{currentTier?.preset_name}</div>
<div>{formattedBankValues.tier}</div>
<div>/</div>
<div className="text-th-success">
{LISTING_PRESETS[suggestedTierKey].preset_name}
{currentTier?.preset_name}
</div>
</div>
<ChevronDownIcon
Expand Down

0 comments on commit 9d42fed

Please sign in to comment.