diff --git a/frontend/pages/edit/profile.tsx b/frontend/pages/edit/profile.tsx index 51904d7..8d45e84 100644 --- a/frontend/pages/edit/profile.tsx +++ b/frontend/pages/edit/profile.tsx @@ -18,20 +18,9 @@ import { export default function Index() { const [user, setUser] = useRecoilState(userState); const router = useRouter(); - - useEffect(() => { - if (!user) { - router.push("/"); - } - }, [user]); - - if (!user) { - return ; - } - const [state, setState] = useState(cloneDeep(user)); - const originalOrder = state.fields + const originalOrder = state?.fields ? state.fields.map((f, i) => { const field: EditField = { id: i, @@ -60,6 +49,17 @@ export default function Index() { : []; const [fields, setFields] = useState(cloneDeep(originalOrder)); + + useEffect(() => { + if (!user) { + router.push("/"); + } + }, [user]); + + if (!user) { + return ; + } + const fieldsUpdated = !fieldsEqual(fields, originalOrder); return ( diff --git a/frontend/pages/login/discord.tsx b/frontend/pages/login/discord.tsx index 63edfc3..9936884 100644 --- a/frontend/pages/login/discord.tsx +++ b/frontend/pages/login/discord.tsx @@ -3,10 +3,9 @@ import { useRouter } from "next/router"; import { useRecoilState } from "recoil"; import fetchAPI from "../../lib/fetch"; import { userState } from "../../lib/state"; -import { APIError, MeUser, SignupResponse } from "../../lib/types"; +import { MeUser, SignupResponse } from "../../lib/types"; import TextInput from "../../components/TextInput"; import Loading from "../../components/Loading"; -import { stat } from "fs"; import Button, { ButtonStyle } from "../../components/Button"; import Notice from "../../components/Notice"; @@ -54,7 +53,7 @@ export default function Discord() { if (!router.query.code || !router.query.state) { return; } - if (state.ticket || state.token) { + if (!state.ticket && !state.token) { return; } @@ -130,13 +129,7 @@ export default function Discord() { }; return ( - <> -

Get started

-

- You{"'"}ve logged in with Discord as{" "} - {state.discord}. -

- +
{state.error && (

{state.error.message ?? state.error}

@@ -144,31 +137,62 @@ export default function Discord() {
)} - - {state.requireInvite && ( -
); }