From e1769c102f1597cc0b53a8b915f858239d197aeb Mon Sep 17 00:00:00 2001 From: Yannic Kilcher Date: Sat, 25 Nov 2023 16:58:48 +0100 Subject: [PATCH] next build fixes --- website/src/pages/chat/[id].tsx | 7 ------- website/src/pages/chat/index.tsx | 10 ++++++++++ website/src/pages/contributors.tsx | 6 +++++- website/src/pages/dashboard.tsx | 13 +++++++------ website/src/pages/index.tsx | 11 +++++------ 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/website/src/pages/chat/[id].tsx b/website/src/pages/chat/[id].tsx index 8e3cf55f75..c55645afe1 100644 --- a/website/src/pages/chat/[id].tsx +++ b/website/src/pages/chat/[id].tsx @@ -8,10 +8,8 @@ import { get } from "src/lib/api"; import { ModelInfo, PluginEntry } from "src/types/Chat"; export { getServerSideProps } from "src/lib/defaultServerSideProps"; import useSWRImmutable from "swr/immutable"; -import { useBrowserConfig } from "src/hooks/env/BrowserEnv"; const Chat = () => { - const { BYE } = useBrowserConfig(); const router = useRouter(); const { query } = router; const id = query.id as string; @@ -23,11 +21,6 @@ const Chat = () => { keepPreviousData: true, }); - if (BYE) { - router.push("/bye"); - return null; - } - return ( <> diff --git a/website/src/pages/chat/index.tsx b/website/src/pages/chat/index.tsx index 3e2856b459..68fcdeef90 100644 --- a/website/src/pages/chat/index.tsx +++ b/website/src/pages/chat/index.tsx @@ -1,12 +1,22 @@ import Head from "next/head"; +import { useRouter } from "next/router"; import { useTranslation } from "next-i18next"; import React from "react"; import { ChatListBase } from "src/components/Chat/ChatListBase"; import { DashboardLayout } from "src/components/Layout"; export { getStaticProps } from "src/lib/defaultServerSideProps"; +import { useBrowserConfig } from "src/hooks/env/BrowserEnv"; const ChatList = () => { const { t } = useTranslation(); + const { BYE } = useBrowserConfig(); + const router = useRouter(); + + React.useEffect(() => { + if (BYE) { + router.push("/bye"); + } + }, [router, BYE]); return ( <> diff --git a/website/src/pages/contributors.tsx b/website/src/pages/contributors.tsx index 98610c4fb4..8f38f71269 100644 --- a/website/src/pages/contributors.tsx +++ b/website/src/pages/contributors.tsx @@ -1,8 +1,12 @@ import { useRouter } from "next/router"; +import { useEffect } from "react"; const ContributorsPage = () => { const router = useRouter(); - router.push("https://ykilcher.com/oa-contributors"); + useEffect(() => { + router.push("https://ykilcher.com/oa-contributors"); + }, [router]); + return null; }; diff --git a/website/src/pages/dashboard.tsx b/website/src/pages/dashboard.tsx index 2f6d9c0e84..17282b61d2 100644 --- a/website/src/pages/dashboard.tsx +++ b/website/src/pages/dashboard.tsx @@ -1,7 +1,8 @@ import { Button, Card, CardBody, Flex, Heading } from "@chakra-ui/react"; import Head from "next/head"; +import { useRouter } from "next/router"; import { useTranslation } from "next-i18next"; -import { useMemo } from "react"; +import { useEffect, useMemo } from "react"; import { LeaderboardWidget, TaskOption, WelcomeCard } from "src/components/Dashboard"; import { DashboardLayout } from "src/components/Layout"; import { get } from "src/lib/api"; @@ -14,7 +15,6 @@ import { useBrowserConfig } from "src/hooks/env/BrowserEnv"; import { useCurrentLocale } from "src/hooks/locale/useCurrentLocale"; import { API_ROUTES } from "src/lib/routes"; import useSWR from "swr"; -import { useRouter } from "next/router"; const Dashboard = () => { const { t } = useTranslation(["dashboard", "common", "tasks"]); @@ -57,10 +57,11 @@ const Dashboard = () => { }, }; - if (BYE) { - router.push("/bye"); - return null; - } + useEffect(() => { + if (BYE) { + router.push("/bye"); + } + }, [BYE, router]); return ( <> diff --git a/website/src/pages/index.tsx b/website/src/pages/index.tsx index 453d6b7cf7..60e04cd284 100644 --- a/website/src/pages/index.tsx +++ b/website/src/pages/index.tsx @@ -16,15 +16,14 @@ const Home = () => { const { status } = useSession(); const { t } = useTranslation(); useEffect(() => { + if (BYE) { + router.push("/bye"); + } + if (status === "authenticated") { router.push("/dashboard"); } - }, [router, status]); - - if (BYE) { - router.push("/bye"); - return null; - } + }, [router, status, BYE]); return ( <>