From 6ef056ad9f56857ed00b4a243098c8bc262b5a8f Mon Sep 17 00:00:00 2001 From: Enrique Date: Mon, 16 Jan 2023 09:31:00 +0100 Subject: [PATCH] order header teams by rank --- src/components/Header.astro | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/Header.astro b/src/components/Header.astro index 698d3948..8676f177 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -3,6 +3,7 @@ import Logo from './Logo.astro' import MenuIcon from './icons/Menu.astro' import SocialNetworks from './SocialNetworks.astro' import { getAllTeams } from '@services/teams.js' +import { getLeaderboard } from '@services/leaderboard.js' const menu = [ { @@ -31,7 +32,12 @@ const menu = [ } ] -const teams = await getAllTeams() +const teamsRaw = await getAllTeams() +const leaderboard = await getLeaderboard() +leaderboard.sort((a, b) => a.rank - b.rank) +const teams = leaderboard.map((teamRank) => + teamsRaw.find((team: { id: any }) => team.id === teamRank.team.id) +) ---
-