diff --git a/app/components/dashboard-components/leaderboard.tsx b/app/components/dashboard-components/leaderboard.tsx index f8336d6..a9c2fa5 100644 --- a/app/components/dashboard-components/leaderboard.tsx +++ b/app/components/dashboard-components/leaderboard.tsx @@ -41,29 +41,32 @@ const Leaderboard = ({ user }: { user: AuthUser | null }) => { setLeaderboardLoading(true); const result = await make_api_call<{ message: string; - leaderboard: { + profiles: { + full_name: string | null; github_username: string; - bounty: string; - pull_requests_merged: string; + bounty: number; + solutions: number; }[]; }>({ - url: `${process.env.NEXT_PUBLIC_BACKEND_URL}/leaderboard`, + url: `${process.env.NEXT_PUBLIC_BACKEND_URL}/registrations`, method: 'GET', headers: { Authorization: `Bearer ${user?.access_token}`, }, }); - const formattedData: TUserData[] = (result.data?.leaderboard ?? []).map( - (item) => ({ - fullName: '', - username: item.github_username, - bounty: Number.parseInt(item.bounty), + const formattedData: TUserData[] = (result.data?.profiles ?? []).map( + (profile) => ({ + fullName: profile.full_name || '', + username: profile.github_username, + bounty: profile.bounty, accountActive: true, - _count: { Solution: item.pull_requests_merged }, + _count: { Solution: profile.solutions.toString() }, }), ); + formattedData.sort((a, b) => b.bounty - a.bounty); + setLeaderboardData(formattedData); formattedData.forEach((userData, index) => { @@ -212,7 +215,7 @@ const Leaderboard = ({ user }: { user: AuthUser | null }) => { : 'List of all registered participants.'} - {currentView === 'leaderboard' ? ( + {/* {currentView === 'leaderboard' ? ( - )} + )} */}
{
{currentView === 'leaderboard' && ( <> -
+ -
+
{data.bounty}