Skip to content

Commit

Permalink
Sort leaderboard entries by amount received
Browse files Browse the repository at this point in the history
  • Loading branch information
sktbrd committed Dec 18, 2024
1 parent 3cde2a8 commit 3d39829
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/pages/HomePage/components/Leaderboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</tr>
</thead>
<tbody>
<tr v-for="(entry, index) in entries" :key="index">
<tr v-for="(entry, index) in sortedEntries" :key="index">
<td class="user-cell">
<a :href="`https://nounspace.com/s/${entry.username}`" target="_blank" class="user-link">
<img v-if="entry.pfp_url" :src="entry.pfp_url" alt="Profile Picture" class="profile-pic" />
Expand All @@ -25,18 +25,22 @@
</template>

<script setup lang="ts">
import { defineProps } from 'vue';
import { defineProps, computed } from 'vue';

const props = defineProps({
title: {
type: String,
required: true
},
entries: {
type: Array,
type: Array as () => Array<{ username: string; pfp_url?: string; display_name: string; amount_received: number }>,
required: true
}
});

const sortedEntries = computed(() => {
return [...props.entries].sort((a, b) => b.amount_received - a.amount_received);
});
</script>

<style scoped>
Expand Down

0 comments on commit 3d39829

Please sign in to comment.