Skip to content

Commit

Permalink
[UI] Update rank process bar value
Browse files Browse the repository at this point in the history
  • Loading branch information
lw committed May 29, 2024
1 parent a9241c9 commit cd332e4
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/extension-koni-ui/src/Popup/Account/AccountDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,18 @@ const Component: React.FC<Props> = (props: Props) => {
maxEnergy: energyConfig?.maxEnergy
});

const currentRank = account?.attributes.rank || 'iron';
const currentPoint = account?.attributes.point || 0;

const pointPercent = useMemo(() => {
const currentRankInfo = rankInfoMap?.[currentRank];

if (currentRankInfo && currentPoint > 0) {
return (currentPoint - currentRankInfo.minPoint) * 100 / (currentRankInfo.maxPoint - currentRankInfo.minPoint);
}

return 0;
}, []);
}, [currentPoint, currentRank, rankInfoMap]);

useEffect(() => {
const accountSub = apiSDK.subscribeAccount().subscribe((data) => {
Expand Down Expand Up @@ -185,10 +194,10 @@ const Component: React.FC<Props> = (props: Props) => {
<img
alt='rank'
className={'rank-info-icon'}
src={smallRankIconMap[account?.attributes.rank || 'iron']}
src={smallRankIconMap[currentRank]}
/>
<span className='rank-info-label'>
{rankNameMap[account?.attributes.rank || 'iron']}
{rankNameMap[currentRank]}
</span>
</div>
</div>
Expand All @@ -201,11 +210,11 @@ const Component: React.FC<Props> = (props: Props) => {
/>

<span className='current-point'>
{formatInteger(account?.attributes.point || 0)}
{formatInteger(currentPoint)}
</span>

<span className='tagret-point'>
/{formatInteger(rankInfoMap?.[account?.attributes.rank || 'iron'].maxPoint || 0)}
/{formatInteger(rankInfoMap?.[currentRank].maxPoint || 0)}
</span>
</div>
</div>
Expand Down

0 comments on commit cd332e4

Please sign in to comment.