import { Button } from 'components/shared/Button'; 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 { CreatePasskey } from './CreatePasskey'; 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'; type Provider = 'google' | 'github' | 'apple' | 'email'; type Props = { onDone: () => void; }; export const SignUp = ({ onDone }: Props) => { const [email, setEmail] = useState(''); const [provider, setProvider] = useState(false); const { toast } = useToast(); const snowball = useSnowball(); async function handleSignupRedirect() { let wallet: PKPEthersWallet | undefined; const google = snowball.auth.google; if (google.canHandleOAuthRedirectBack()) { setProvider('google'); await google.handleOAuthRedirectBack(); wallet = await google.getEthersWallet(); await signInWithEthereum(wallet); } if (wallet) { onDone(); } } useEffect(() => { handleSignupRedirect(); }, []); const loading = provider; const emailValid = /.@./.test(email); if (provider === 'email') { return ; } return (
Sign up to Snowball
OR
Email
setEmail(e.target.value)} disabled={!!loading} />
Already an user?
Sign in now
); };