import { signup } from '../../reducers/login'; import { useState } from 'react'; import Button from '@material-ui/core/Button'; import Grid from '@material-ui/core/Grid'; import InputAdornment from '@material-ui/core/InputAdornment'; import IconButton from '@material-ui/core/IconButton'; import TextField from '@material-ui/core/TextField'; import Typography from '@material-ui/core/Typography'; import Visibility from '@material-ui/icons/Visibility'; import VisibilityOff from '@material-ui/icons/VisibilityOff'; import { connect } from 'react-redux'; import { withStyles } from '@material-ui/styles'; const styles = (theme) => {}; const SignupPage = (props) => { //const { classes } = props; const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); const [visible, setVisible] = useState(false); const [error, setError] = useState(false); const checkSignup = () => { if (password !== confirmPassword) { setError(true); } else { setError(false); } }; return (
Sign Up { return setEmail(event.target.value ?? ''); }} onKeyPress={(event) => { if (event.key === 'Enter') { checkSignup(); if (!error) { props.signup(email, password); } } }} />
{ setPassword(event.target.value ?? ''); }} onKeyPress={(event) => { if (event.key === 'Enter') { checkSignup(); if (!error) { props.signup(email, password); } } }} InputProps={{ endAdornment: ( { return setVisible(!visible); }} edge='end'> {visible ? : } ) }} />
{ setConfirmPassword(event.target.value ?? ''); }} onKeyPress={(event) => { checkSignup(); if (event.key === 'Enter') { if (!error) { props.signup(email, password); } } }} InputProps={{ endAdornment: ( { return setVisible(!visible); }} edge='end'> {visible ? : } ) }} />
); }; export default connect( (state) => { return {}; }, (dispatch, props) => { return { signup: (email, password) => { dispatch(signup(email, password)); } }; } )(withStyles(styles)(SignupPage));