From 181d40fab14c9170a7bbd9fe1782db727f5b19d6 Mon Sep 17 00:00:00 2001
From: ilyayudovin <ilyayudovin123@gmail.com>
Date: Tue, 16 Jun 2020 15:14:40 +0300
Subject: add form transfer to signIn and signUp

---
 src/pages/AuthPage/AuthPage.tsx | 27 ++++++---------------------
 1 file changed, 6 insertions(+), 21 deletions(-)

(limited to 'src/pages/AuthPage/AuthPage.tsx')

diff --git a/src/pages/AuthPage/AuthPage.tsx b/src/pages/AuthPage/AuthPage.tsx
index 9b8040c..c490078 100644
--- a/src/pages/AuthPage/AuthPage.tsx
+++ b/src/pages/AuthPage/AuthPage.tsx
@@ -1,8 +1,8 @@
 import React, {useState} from 'react';
-import { Authorization} from '../../types';
+import {Authorization} from '../../types';
 import SignInForm from './SignInForm';
 import {makeStyles} from "@material-ui/core";
-import Registration from "./Registration";
+import SignUpForm from "./SignUpForm";
 
 interface PropTypes {
   logIn: (name: string, password: string) => Promise<boolean>;
@@ -19,28 +19,13 @@ const useStyles = makeStyles(theme => ({
 
 const AuthPage: React.FC<PropTypes> = ({logIn}) => {
   const classes = useStyles();
-  const[authorization,setAuthorization] = useState<Authorization>({authorize: 'signUp'});
-
-  const handleSignUp = () => {
-    setAuthorization({authorize: 'signUp'});
-    console.log(authorization.authorize);
-  };
-
-  const handleRegistration = () => {
-    setAuthorization({authorize: 'registration'});
-    console.log(authorization.authorize);
-  };
+  const [authorization, setAuthorization] = useState<Authorization>({authorize: 'signIn'});
 
   return (
     <>
-      <div className={classes.authorize}>
-        <div onClick={handleSignUp}>SignUp</div>
-        <div>or</div>
-        <div onClick={handleRegistration}>Registrate</div>
-      </div>
-      { authorization.authorize === 'signUp' && <SignInForm logIn={logIn} /> }
-      { authorization.authorize === 'registration' && <Registration logIn={logIn} /> }
-      </>
+      {authorization.authorize === 'signIn' && <SignInForm logIn={logIn} setAuthorization={setAuthorization}/>}
+      {authorization.authorize === 'signUp' && <SignUpForm logIn={logIn} setAuthorization={setAuthorization} />}
+    </>
   );
 };
 
-- 
cgit v1.2.3

