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; } const useStyles = makeStyles(theme => ({ root: { '& > *': { margin: theme.spacing(1), width: theme.spacing(35) }, display: 'flex', flexDirection: 'column', alignItems: 'center', textAlign: 'center' }, formHeader: { textAlign: 'center', fontSize: 25 } })); const SignInForm: React.FC = ({ logIn }) => { 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); }); } }; return ( <>
Sign In
); }; export default SignInForm;