Skip to content

Commit

Permalink
Points: rank card fixes (#5332)
Browse files Browse the repository at this point in the history
* fixes

* fix ens display
  • Loading branch information
benisgold authored Jan 19, 2024
1 parent 78e2cb7 commit 75c371b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/screens/points/components/LeaderboardRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const LeaderboardRow = ({
numberOfLines={1}
containsEmoji
>
{ens ?? formattedAddress ?? ''}
{ens || formattedAddress || ''}
</Text>
</Box>
</Stack>
Expand Down
17 changes: 13 additions & 4 deletions src/screens/points/content/PointsContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ export default function PointsContent() {

const totalUsers = points?.points?.leaderboard.stats.total_users;
const rank = points?.points?.user.stats.position.current;
const lastWeekRank = points?.points?.user.stats.last_airdrop.position.current;
const lastWeekRank =
points?.points?.user.stats.last_airdrop?.position.current;
const rankChange = rank && lastWeekRank ? rank - lastWeekRank : undefined;
const isUnranked = !!points?.points?.user?.stats?.position?.unranked;

Expand All @@ -150,18 +151,26 @@ export default function PointsContent() {

if (rankChange === 0) return '􁘢';

if (rankChange > 0) return '􀑁';
if (rankChange < 0) return '􀑁';

return '􁘳';
};

const getRankChangeIconColor = () => {
if (rankChange === undefined || rankChange < 0) return colors.red;
if (rankChange === undefined || rankChange > 0) return colors.red;

if (rankChange === 0) return colors.yellow;

return colors.green;
};

const getRankChangeText = () => {
if (rankChange !== undefined) {
return Math.abs(rankChange).toLocaleString('en-US');
}
return '';
};

return (
<Box height="full" background="surfacePrimary" as={Page} flex={1}>
<ScrollView
Expand Down Expand Up @@ -288,7 +297,7 @@ export default function PointsContent() {
subtitle={
isUnranked
? i18n.t(i18n.l.points.points.points_to_rank)
: rankChange?.toString() || ''
: getRankChangeText()
}
mainTextColor={isUnranked ? 'secondary' : 'primary'}
accentColor={
Expand Down

0 comments on commit 75c371b

Please sign in to comment.