From 16403a7d834bbe1f2f4dddf8791baa8a1163222b Mon Sep 17 00:00:00 2001
From: mat <github@matdoes.dev>
Date: Sat, 9 Apr 2022 15:20:37 -0500
Subject: Fixes

Fix leaderboards section not showing correct units & hyperlink directly to profile from leaderboards
---
 src/lib/sections/Leaderboards.svelte | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'src/lib/sections/Leaderboards.svelte')

diff --git a/src/lib/sections/Leaderboards.svelte b/src/lib/sections/Leaderboards.svelte
index 2041733..a0fa4dc 100644
--- a/src/lib/sections/Leaderboards.svelte
+++ b/src/lib/sections/Leaderboards.svelte
@@ -2,7 +2,7 @@
 	import { API_URL } from '$lib/api'
 
 	import type { CleanMemberProfile } from '$lib/APITypes'
-	import { cleanId } from '$lib/utils'
+	import { cleanId, formatNumberFromUnit } from '$lib/utils'
 
 	export let data: CleanMemberProfile
 </script>
@@ -14,7 +14,10 @@
 		{#each leaderboards as leaderboard}
 			<li class="leaderboard-item">
 				<a href="/leaderboard/{leaderboard.name}" class="leaderboard-item-anchor">
-					{leaderboard.positionIndex + 1}) <b>{cleanId(leaderboard.name)}</b>: {leaderboard.value.toLocaleString()}
+					{leaderboard.positionIndex + 1}) <b>{cleanId(leaderboard.name)}</b>: {formatNumberFromUnit(
+						leaderboard.value,
+						leaderboard.unit ?? cleanId(leaderboard.name).toLowerCase()
+					)}
 				</a>
 			</li>
 		{/each}
-- 
cgit 

