Created
May 20, 2021 11:31
-
-
Save GeoffMahugu/f30776baaedcf033ee2ca9a02b13dd1a to your computer and use it in GitHub Desktop.
This is the final SignUp Page for react app.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react' | |
import { Link, useHistory } from 'react-router-dom'; | |
import firebase from 'firebase'; | |
import IPageProps from '../../interfaces/page.interface'; | |
import { SignInWithSocialMedia } from '../../modules/auth'; | |
import { Providers } from '../../config/firebase'; | |
const SignUpPage: React.FunctionComponent<IPageProps> = props => { | |
const [authenticating, setAuthenticating] = useState<boolean>(false); | |
const [error, setError] = useState<string>(''); | |
const history = useHistory(); | |
const signInWithSocialMedia = (provider: firebase.auth.AuthProvider) => { | |
if (error !== '') setError(''); | |
setAuthenticating(true); | |
SignInWithSocialMedia(provider) | |
.then(result => { | |
history.push('/'); | |
}) | |
.catch(error => { | |
setAuthenticating(false); | |
setError(error.message); | |
}); | |
} | |
return ( | |
<div className="AuthLogin"> | |
<div className="auth-main-container"> | |
<div> | |
<h1 >Welcome to React App</h1> | |
<p >Please Signup to continue by choosing one of the options below.</p> | |
</div> | |
<div className="auth-btn-wrapper"> | |
<button | |
disabled={authenticating} | |
onClick={() => signInWithSocialMedia(Providers.google)} | |
> | |
SignUp with Google</button> | |
<button | |
disabled={authenticating} | |
onClick={() => signInWithSocialMedia(Providers.facebook)} | |
> | |
Sign with Facebook</button> | |
<Link to={`/`}> | |
<button>Back To Home Page</button> | |
</Link> | |
</div> | |
</div> | |
</div> | |
); | |
} | |
export default SignUpPage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment