From bfb4a3f30b1ee0d04a1729193b06421c6ff20891 Mon Sep 17 00:00:00 2001 From: Gilbert Date: Tue, 4 Jun 2024 16:26:15 -0500 Subject: [PATCH] Revert "remove email signup for now" This reverts commit 0e9c3a07fd45c70185dcdb1faaaaf102ced5342a. --- packages/frontend/src/pages/auth/SignUp.tsx | 66 +++++++++++---------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/packages/frontend/src/pages/auth/SignUp.tsx b/packages/frontend/src/pages/auth/SignUp.tsx index 67460d9b..581e9595 100644 --- a/packages/frontend/src/pages/auth/SignUp.tsx +++ b/packages/frontend/src/pages/auth/SignUp.tsx @@ -1,20 +1,26 @@ import { Button } from 'components/shared/Button'; -import { GithubIcon, LoaderIcon } from 'components/shared/CustomIcon'; +import { + ArrowRightCircleFilledIcon, + GithubIcon, + LoaderIcon, +} from 'components/shared/CustomIcon'; import { GoogleIcon } from 'components/shared/CustomIcon/GoogleIcon'; +import { DotBorder } from 'components/shared/DotBorder'; import { WavyBorder } from 'components/shared/WavyBorder'; import { useEffect, useState } from 'react'; import { useSnowball } from 'utils/use-snowball'; +import { Input } from 'components/shared/Input'; import { AppleIcon } from 'components/shared/CustomIcon/AppleIcon'; import { Link } from 'react-router-dom'; import { useToast } from 'components/shared/Toast'; import { PKPEthersWallet } from '@lit-protocol/pkp-ethers'; import { signInWithEthereum } from 'utils/siwe'; import { logError } from 'utils/log-error'; -// import { -// subOrganizationIdForEmail, -// turnkeySignin, -// turnkeySignup, -// } from 'utils/turnkey-frontend'; +import { + subOrganizationIdForEmail, + turnkeySignin, + turnkeySignup, +} from 'utils/turnkey-frontend'; type Provider = 'google' | 'github' | 'apple' | 'email'; @@ -25,7 +31,7 @@ type Props = { }; export const SignUp = ({ onDone }: Props) => { - // const [email, setEmail] = useState(''); + const [email, setEmail] = useState(''); const [error, setError] = useState(); const [provider, setProvider] = useState(false); @@ -81,29 +87,29 @@ export const SignUp = ({ onDone }: Props) => { } } - // async function authEmail() { - // setProvider('email'); - // try { - // const orgId = await subOrganizationIdForEmail(email); - // console.log('orgId', orgId); - // if (orgId) { - // await turnkeySignin(orgId); - // window.location.href = '/dashboard'; - // } else { - // await turnkeySignup(email); - // onDone(); - // } - // } catch (err: any) { - // setError({ type: 'email', message: err.message }); - // } - // } + async function authEmail() { + setProvider('email'); + try { + const orgId = await subOrganizationIdForEmail(email); + console.log('orgId', orgId); + if (orgId) { + await turnkeySignin(orgId); + window.location.href = '/dashboard'; + } else { + await turnkeySignup(email); + onDone(); + } + } catch (err: any) { + setError({ type: 'email', message: err.message }); + } + } useEffect(() => { handleSignupRedirect(); }, []); const loading = provider; - // const emailValid = /.@./.test(email); + const emailValid = /.@./.test(email); return (
@@ -193,16 +199,16 @@ export const SignUp = ({ onDone }: Props) => {
)} - {/*
+
OR
-
*/} +
- {/*
+
Email
@@ -211,8 +217,8 @@ export const SignUp = ({ onDone }: Props) => { onChange={(e) => setEmail(e.target.value)} disabled={!!loading} /> -
*/} - {/* */} +
{error && error.type === 'email' && (