Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order header teams by rank #334

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down Expand Up @@ -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)
)
---

<header
Expand Down Expand Up @@ -80,7 +86,9 @@ const teams = await getAllTeams()
</div>
</nav>

<nav class='flex gap-4 self-center items-center md:justify-between md:w-[724px] lg:w-full max-w-4xl'>
<nav
class='flex gap-4 self-center items-center md:justify-between md:w-[724px] lg:w-full max-w-4xl'
>
<input type='checkbox' id='menu' hidden class='peer' />
<label
for='menu'
Expand Down