diff --git a/app/(dashboard)/repo-settings/[repositoryId]/players/page.tsx b/app/(dashboard)/repo-settings/[repositoryId]/players/page.tsx index 69df5c2..1f6a3a9 100644 --- a/app/(dashboard)/repo-settings/[repositoryId]/players/page.tsx +++ b/app/(dashboard)/repo-settings/[repositoryId]/players/page.tsx @@ -1,4 +1,4 @@ -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; +import UserProfileSummary from "@/components/ui/userProfileSummary"; import { getUsersForRepository } from "@/lib/repository/service"; export const metadata = { @@ -9,27 +9,35 @@ export const metadata = { export default async function RepoSettings({ params }) { const players = await getUsersForRepository(params.repositoryId); + const arrayOfPlayersWithTheirTotalPoints = players.map((player) => { + const totalPointsForThisSinglePlayer = player.pointTransactions.reduce((acc, pt) => acc + pt.points, 0); + return { + ...player, + totalPointsForThisSinglePlayer: totalPointsForThisSinglePlayer, + }; + }); + + // Sort users by total points in descending order + const arrayOfUsersInRepoInDescendingOrder = arrayOfPlayersWithTheirTotalPoints.sort( + (a, b) => b.totalPointsForThisSinglePlayer - a.totalPointsForThisSinglePlayer + ); + return (
No players enrolled in this repository.
) : ( - // Replace with Leaderboard component{player.name}
-