diff --git a/website/src/components/Dashboard/LeaderboardWidget.tsx b/website/src/components/Dashboard/LeaderboardWidget.tsx
index aa89d585..a47816a2 100644
--- a/website/src/components/Dashboard/LeaderboardWidget.tsx
+++ b/website/src/components/Dashboard/LeaderboardWidget.tsx
@@ -17,7 +17,7 @@ export function LeaderboardWidget() {
-
+
diff --git a/website/src/components/DataTable.tsx b/website/src/components/DataTable.tsx
index a8106317..5f222a86 100644
--- a/website/src/components/DataTable.tsx
+++ b/website/src/components/DataTable.tsx
@@ -93,7 +93,7 @@ export const DataTable = ({
)}
- {caption}
+ {caption}
{getHeaderGroups().map((headerGroup) => (
diff --git a/website/src/components/LeaderboardTable/LeaderboardTable.tsx b/website/src/components/LeaderboardTable/LeaderboardTable.tsx
index 847e4dc4..3b6aafcd 100644
--- a/website/src/components/LeaderboardTable/LeaderboardTable.tsx
+++ b/website/src/components/LeaderboardTable/LeaderboardTable.tsx
@@ -1,7 +1,7 @@
import { CircularProgress } from "@chakra-ui/react";
import { createColumnHelper } from "@tanstack/react-table";
import { useTranslation } from "next-i18next";
-import React, { useMemo } from "react";
+import React, { useMemo, useState } from "react";
import { get } from "src/lib/api";
import { LeaderboardEntity, LeaderboardReply, LeaderboardTimeFrame } from "src/types/Leaderboard";
import useSWRImmutable from "swr/immutable";
@@ -13,7 +13,15 @@ const columnHelper = createColumnHelper();
/**
* Presents a grid of leaderboard entries with more detailed information.
*/
-export const LeaderboardTable = ({ timeFrame, limit }: { timeFrame: LeaderboardTimeFrame; limit: number }) => {
+export const LeaderboardTable = ({
+ timeFrame,
+ limit: limit,
+ rowPerPage,
+}: {
+ timeFrame: LeaderboardTimeFrame;
+ limit: number;
+ rowPerPage: number;
+}) => {
const { t } = useTranslation("leaderboard");
const {
data: reply,
@@ -52,6 +60,12 @@ export const LeaderboardTable = ({ timeFrame, limit }: { timeFrame: LeaderboardT
return t("last_updated_at", { val, formatParams: { val: { dateStyle: "full", timeStyle: "short" } } });
}, [t, reply?.last_updated]);
+ const [page, setPage] = useState(1);
+ const data = useMemo(() => {
+ const start = (page - 1) * rowPerPage;
+ return reply?.leaderboard.slice(start, start + rowPerPage) || [];
+ }, [rowPerPage, page, reply?.leaderboard]);
+
if (isLoading) {
return ;
}
@@ -60,5 +74,18 @@ export const LeaderboardTable = ({ timeFrame, limit }: { timeFrame: LeaderboardT
return Unable to load leaderboard;
}
- return ;
+ const maxPage = Math.ceil(reply.leaderboard.length / rowPerPage);
+
+ return (
+ setPage((p) => p + 1)}
+ onPreviousClick={() => setPage((p) => p - 1)}
+ >
+ );
};
diff --git a/website/src/pages/leaderboard.tsx b/website/src/pages/leaderboard.tsx
index c4d317b1..b5a72d91 100644
--- a/website/src/pages/leaderboard.tsx
+++ b/website/src/pages/leaderboard.tsx
@@ -21,7 +21,7 @@ const Leaderboard = () => {
-
+
{t("daily")}
{t("weekly")}
{t("monthly")}
@@ -29,16 +29,16 @@ const Leaderboard = () => {
-
+
-
+
-
+
-
+