From f774603b7fc83df18f4e50ee55d4b3ccedd4d340 Mon Sep 17 00:00:00 2001 From: guru_sainath Date: Tue, 13 Jun 2023 14:37:25 +0530 Subject: [PATCH] chore: onboarding workflow in authentication (#1281) --- .../components/account/email-code-form.tsx | 29 +-- .../account/github-login-button.tsx | 6 +- apps/app/components/account/google-login.tsx | 6 +- apps/app/pages/index.tsx | 50 +++-- apps/app/pages/onboarding.tsx | 197 +++++++++--------- 5 files changed, 159 insertions(+), 129 deletions(-) diff --git a/apps/app/components/account/email-code-form.tsx b/apps/app/components/account/email-code-form.tsx index 9132ee994..e1b7aea98 100644 --- a/apps/app/components/account/email-code-form.tsx +++ b/apps/app/components/account/email-code-form.tsx @@ -16,7 +16,7 @@ type EmailCodeFormValues = { token?: string; }; -export const EmailCodeForm = ({ onSuccess }: any) => { +export const EmailCodeForm = ({ handleSignIn }: any) => { const [codeSent, setCodeSent] = useState(false); const [codeResent, setCodeResent] = useState(false); const [isCodeResending, setIsCodeResending] = useState(false); @@ -66,18 +66,23 @@ export const EmailCodeForm = ({ onSuccess }: any) => { const handleSignin = async (formData: EmailCodeFormValues) => { setIsLoading(true); - await authenticationService.magicSignIn(formData).catch((error) => { - setIsLoading(false); - setToastAlert({ - title: "Oops!", - type: "error", - message: error?.response?.data?.error ?? "Enter the correct code to sign in", + await authenticationService + .magicSignIn(formData) + .then((response) => { + handleSignIn(response); + }) + .catch((error) => { + setIsLoading(false); + setToastAlert({ + title: "Oops!", + type: "error", + message: error?.response?.data?.error ?? "Enter the correct code to sign in", + }); + setError("token" as keyof EmailCodeFormValues, { + type: "manual", + message: error?.error, + }); }); - setError("token" as keyof EmailCodeFormValues, { - type: "manual", - message: error.error, - }); - }); }; const emailOld = getValues("email"); diff --git a/apps/app/components/account/github-login-button.tsx b/apps/app/components/account/github-login-button.tsx index 3da7317e8..d997b3a3d 100644 --- a/apps/app/components/account/github-login-button.tsx +++ b/apps/app/components/account/github-login-button.tsx @@ -35,12 +35,12 @@ export const GithubLoginButton: FC = (props) => { }, []); return ( -
+
- diff --git a/apps/app/components/account/google-login.tsx b/apps/app/components/account/google-login.tsx index 237439def..c12fb4e24 100644 --- a/apps/app/components/account/google-login.tsx +++ b/apps/app/components/account/google-login.tsx @@ -47,7 +47,11 @@ export const GoogleLoginButton: FC = (props) => { return ( <>