From 7c4a2ccc8aa2b5fabc674d614b0ab5ab78617258 Mon Sep 17 00:00:00 2001 From: manishpali17 <129128602+manishpali17@users.noreply.github.com> Date: Wed, 22 May 2024 16:46:49 +0530 Subject: [PATCH] fix loading error discord --- src/app/discord/redirect/page.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/discord/redirect/page.tsx b/src/app/discord/redirect/page.tsx index cc8da5740..db34d7bc2 100644 --- a/src/app/discord/redirect/page.tsx +++ b/src/app/discord/redirect/page.tsx @@ -5,9 +5,10 @@ import { useEffect, useState } from 'react'; export default function DiscordOauthRedirect() { const [loading, setLoading] = useState(true); - const [error, setError] = useState(false); + const [error, setError] = useState(''); const searchParams = useSearchParams(); const code = searchParams.get('code'); + const discordError = searchParams.get('error'); const updateDiscordUser = async (code: string) => { try { @@ -39,7 +40,11 @@ export default function DiscordOauthRedirect() { if (code) { updateDiscordUser(code); } - }, [code]); + if (discordError) { + setLoading(false); + setError(discordError); + } + }, [code, discordError]); if (loading) { return
Loading...
;