From 181d40fab14c9170a7bbd9fe1782db727f5b19d6 Mon Sep 17 00:00:00 2001 From: ilyayudovin Date: Tue, 16 Jun 2020 15:14:40 +0300 Subject: add form transfer to signIn and signUp --- src/pages/AuthPage/SignUpForm.tsx | 84 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/pages/AuthPage/SignUpForm.tsx (limited to 'src/pages/AuthPage/SignUpForm.tsx') diff --git a/src/pages/AuthPage/SignUpForm.tsx b/src/pages/AuthPage/SignUpForm.tsx new file mode 100644 index 0000000..29f17b1 --- /dev/null +++ b/src/pages/AuthPage/SignUpForm.tsx @@ -0,0 +1,84 @@ +import React, {useRef} from 'react'; +import {makeStyles} from '@material-ui/core/styles'; +import TextField from '@material-ui/core/TextField'; +import Button from '@material-ui/core/Button'; +import {Authorization} from '../../types'; +import {get, post} from '../../requests'; + +interface PropTypes { + logIn: (name: string, password: string) => Promise; + setAuthorization: (authorization: { authorize: string }) => void ; +} + +const useStyles = makeStyles(theme => ({ + root: { + '& > *': { + margin: theme.spacing(1), + width: '25ch' + }, + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + textAlign: 'center' + }, + formTransfer: { + display: 'flex', + justifyContent: 'center' + }, + transferButton: { + marginLeft: 10, + color: 'green' + }, + formHeader: { + textAlign: 'center', + fontSize: 25 + } +})); + +const SignUpForm: React.FC = ({logIn,setAuthorization}) => { + const classes = useStyles(); + const inputRef = useRef(); + const inputRefPassword = useRef(); + + + const onClick = () => { + const name = inputRef.current?.value; + const password = inputRefPassword.current?.value; + const newUser = { + name: name, + password: password, + avatarUrl: '', + }; + if (name && password) { + post(`/users`,newUser).then(response => { + logIn(name, password); + }); + } + }; + + const handleSignIn = () => { + setAuthorization({authorize: 'signIn'}); + }; + + return ( + <> +
Sign Up
+
+ + + + + +
+
Already have an account?
+
Sign In
+
+ + ); +}; + +export default SignUpForm; -- cgit v1.2.3