import React, {useState, useRef} from 'react'; import {makeStyles} from '@material-ui/core/styles'; import TextField from '@material-ui/core/TextField'; import Button from '@material-ui/core/Button'; 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 SignInForm: React.FC = ({logIn, setAuthorization}) => { const [error, setError] = useState(false); const classes = useStyles(); const nameRef = useRef(); const passwordRef = useRef(); const onClick = async () => { const name = nameRef.current?.value; const password = passwordRef.current?.value; if (name && password) { logIn(name, password).then(success => { if (!success) setError(true); }); } }; const handleSignUp = () => { setAuthorization({authorize: 'signUp'}); }; return ( <>
Sign In
Don't have an account?
Sign Up
); }; export default SignInForm;