Fix locale leaderboard after rebase

This commit is contained in:
rjmacarthy
2023-01-21 20:33:27 +00:00
parent 81a392232e
commit edeae8cc84
3 changed files with 9 additions and 7 deletions
+1 -2
View File
@@ -13,6 +13,5 @@
"sign_in": "Sign In",
"sign_out": "Sign Out",
"terms_of_service": "Terms of Service",
"title": "Open Assistant",
"last_updated_at": "Last updated at: {{val, datetime}}"
"title": "Open Assistant"
}
@@ -1,5 +1,6 @@
{
"daily": "Daily",
"last_updated_at": "Last updated at: {{val, datetime}}",
"leaderboard": "Leaderboard",
"monthly": "Monthly",
"overall": "Overall",
@@ -6,19 +6,19 @@ import { get } from "src/lib/api";
import { LeaderboardReply, LeaderboardTimeFrame } from "src/types/Leaderboard";
import useSWRImmutable from "swr/immutable";
const columns = [
const getColumns = (t) => [
{
Header: "Rank",
Header: t("rank"),
accessor: "rank",
style: { width: "90px" },
},
{
Header: "Score",
Header: t("score"),
accessor: "leader_score",
style: { width: "90px" },
},
{
Header: "User",
Header: t("user"),
accessor: "display_name",
},
];
@@ -27,11 +27,13 @@ const columns = [
* Presents a grid of leaderboard entries with more detailed information.
*/
const LeaderboardGridCell = ({ timeFrame }: { timeFrame: LeaderboardTimeFrame }) => {
const { t } = useTranslation();
const { t } = useTranslation(["leaderboard", "common"]);
const { data: reply } = useSWRImmutable<LeaderboardReply>(`/api/leaderboard?time_frame=${timeFrame}`, get, {
revalidateOnMount: true,
});
const columns = useMemo(() => getColumns(t), [t]);
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable({
columns,
data: reply?.leaderboard ?? [],