From 5f49ae55231539064bd9dfb89f964bb0217b966d Mon Sep 17 00:00:00 2001 From: ThEditor Date: Tue, 17 Sep 2024 18:47:11 +0530 Subject: [PATCH] fix: signup redirect --- src/components/signin/signin-form.tsx | 13 +++++++++++++ src/components/signup/signup-form.tsx | 8 ++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/components/signin/signin-form.tsx b/src/components/signin/signin-form.tsx index f5b2dab..0f11a36 100644 --- a/src/components/signin/signin-form.tsx +++ b/src/components/signin/signin-form.tsx @@ -20,6 +20,7 @@ const SignInForm = ({ className }: SignInFormProps) => { password: "", }); const [submitting, setSubmitting] = useState(false); + const [justRegistered, setJustRegistered] = useState(false); const { toast } = useToast(); useEffect(() => { @@ -33,6 +34,12 @@ const SignInForm = ({ className }: SignInFormProps) => { duration: 5000, }); } + + const urlParams = new URLSearchParams(window.location.search); + const reg = urlParams.get("reg"); + if (reg === "true") { + setJustRegistered(true); + } }, [toast]); // Handler for input changes @@ -81,6 +88,12 @@ const SignInForm = ({ className }: SignInFormProps) => { className, )} > + {/* Just Registered Toast */} + {justRegistered && ( + + You have successfully registered. Please sign in. + + )} {/* Sign In Header */} SIGN IN diff --git a/src/components/signup/signup-form.tsx b/src/components/signup/signup-form.tsx index fe08416..852c239 100644 --- a/src/components/signup/signup-form.tsx +++ b/src/components/signup/signup-form.tsx @@ -85,15 +85,19 @@ const SignUpForm = ({ className }: SignUpFormProps) => { duration: 5000, }); setSubmitting(false); - return { data: { access_token: "" } }; + return { data: { access_token: "", msg_code: -1 } }; }) - ).data as { access_token: string }; + ).data as { access_token: string, msg_code: number }; setSubmitting(false); if (res.access_token) { window.localStorage.setItem("token", res.access_token); window.location.href = "/signup"; } + + if (res.msg_code === 13) { + window.location.href = "/signin?reg=true"; + } }; const handleAdd = () => {