From b9ce2fb1406c3a5a79f2680bc6b19c6adbeaceb8 Mon Sep 17 00:00:00 2001 From: Keith Stevens Date: Sat, 21 Jan 2023 17:56:29 +0900 Subject: [PATCH 1/2] Ensuring localization works across all pages and fix user data fetching in admin view --- website/src/lib/oasst_api_client.ts | 2 +- website/src/pages/auth/verify.tsx | 5 +++-- website/src/pages/tasks/random.tsx | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/website/src/lib/oasst_api_client.ts b/website/src/lib/oasst_api_client.ts index b1639462..1e74b020 100644 --- a/website/src/lib/oasst_api_client.ts +++ b/website/src/lib/oasst_api_client.ts @@ -152,7 +152,7 @@ export class OasstApiClient { * Returns the `BackendUser` associated with `user_id` */ async fetch_user(user_id: string): Promise { - return this.get(`/api/v1/users/users/${user_id}`); + return this.get(`/api/v1/users/${user_id}`); } /** diff --git a/website/src/pages/auth/verify.tsx b/website/src/pages/auth/verify.tsx index 876aa677..d7a64a63 100644 --- a/website/src/pages/auth/verify.tsx +++ b/website/src/pages/auth/verify.tsx @@ -1,6 +1,7 @@ import { useColorMode } from "@chakra-ui/react"; import Head from "next/head"; import { getCsrfToken, getProviders } from "next-auth/react"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; export default function Verify() { const { colorMode } = useColorMode(); @@ -21,14 +22,14 @@ export default function Verify() { ); } -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export async function getServerSideProps(context) { +export async function getServerSideProps({ locale }) { const csrfToken = await getCsrfToken(); const providers = await getProviders(); return { props: { csrfToken, providers, + ...(await serverSideTranslations(locale, ["common"])), }, }; } diff --git a/website/src/pages/tasks/random.tsx b/website/src/pages/tasks/random.tsx index be1809c3..f1c04d2c 100644 --- a/website/src/pages/tasks/random.tsx +++ b/website/src/pages/tasks/random.tsx @@ -4,6 +4,7 @@ import { getDashboardLayout } from "src/components/Layout"; import { LoadingScreen } from "src/components/Loading/LoadingScreen"; import { Task } from "src/components/Tasks/Task"; import { useGenericTaskAPI } from "src/hooks/tasks/useGenericTaskAPI"; +export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props"; import { TaskType } from "src/types/Task"; const RandomTask = () => { From e756e5d9926fa14a2a454cafa046f58d5fdd9e22 Mon Sep 17 00:00:00 2001 From: Keith Stevens Date: Sat, 21 Jan 2023 19:03:12 +0900 Subject: [PATCH 2/2] Fixing another page with locale data --- website/src/pages/tasks/all.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/website/src/pages/tasks/all.tsx b/website/src/pages/tasks/all.tsx index ed0659c8..3ccfd4e8 100644 --- a/website/src/pages/tasks/all.tsx +++ b/website/src/pages/tasks/all.tsx @@ -2,6 +2,7 @@ import Head from "next/head"; import { TaskOption } from "src/components/Dashboard"; import { getDashboardLayout } from "src/components/Layout"; import { TaskCategory } from "src/components/Tasks/TaskTypes"; +export { getDefaultStaticProps as getStaticProps } from "src/lib/default_static_props"; const AllTasks = () => { return (