diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-06-16 20:21:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-16 20:21:35 +0300 |
commit | 0e7c2d476225b3e381a86710a3635ab707387499 (patch) | |
tree | 27a9134031b4c90a9c887fbf9d8d2fa0e80a4109 /src/pages/AuthPage/AuthPage.tsx | |
parent | b860685d212200b5a46b7fea066306b851bf6e26 (diff) | |
parent | 5ec0669e6160f025017684a7d48f1d07a1768785 (diff) | |
download | which-ui-0e7c2d476225b3e381a86710a3635ab707387499.tar.gz |
Merge pull request #38 from ilyayudovin/registration
Registration form
Diffstat (limited to 'src/pages/AuthPage/AuthPage.tsx')
-rw-r--r-- | src/pages/AuthPage/AuthPage.tsx | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/src/pages/AuthPage/AuthPage.tsx b/src/pages/AuthPage/AuthPage.tsx index 72733f0..dc90c01 100644 --- a/src/pages/AuthPage/AuthPage.tsx +++ b/src/pages/AuthPage/AuthPage.tsx @@ -1,12 +1,54 @@ -import React from 'react'; +import React, { useState } from 'react'; +import { makeStyles } from '@material-ui/core/styles'; import SignInForm from './SignInForm'; +import SignUpForm from './SignUpForm'; + interface PropTypes { logIn: (name: string, password: string) => Promise<boolean>; } +const useStyles = makeStyles({ + formTransfer: { + display: 'flex', + justifyContent: 'center' + }, + transferButton: { + marginLeft: 10, + color: 'green', + cursor: 'pointer' + } +}); + const AuthPage: React.FC<PropTypes> = ({ logIn }) => { - return <SignInForm logIn={logIn} />; + const [auth, setAuth] = useState<'signIn' | 'signUp'>('signIn'); + const classes = useStyles(); + + const handleRedirect = () => { + setAuth(auth === 'signIn' ? 'signUp' : 'signIn'); + }; + + const footerInfo = { + signIn: ['Don\'t have an account?', 'Sign in'], + signUp: ['Already have an account?', 'Sign up'] + }; + + return ( + <> + {auth === 'signIn' && <SignInForm logIn={logIn} />} + {auth === 'signUp' && <SignUpForm logIn={logIn} />} + <div className={classes.formTransfer}> + <div>{footerInfo[auth][0]}</div> + <span + onClick={handleRedirect} + className={classes.transferButton} + role="presentation" + > + {footerInfo[auth][1]} + </span> + </div> + </> + ); }; export default AuthPage; |