import { h, Component } from 'preact';
// import PropTypes from 'prop-types';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { Redirect } from 'react-router-dom';
// import { Link } from 'react-router-dom';
import * as authActions from './auth.actions';
import { Group, Param, TextInput, Button } from '../common';
class Login extends Component {
state = {
username: '',
password: '',
}
constructor() {
super()
this.handleChange = this.handleChange.bind(this)
this.handleSubmit = this.handleSubmit.bind(this)
}
handleChange(value, name) {
this.setState({
[name]: value,
error: null,
})
}
handleSubmit(e) {
e.preventDefault()
if (this.props.auth.loading) return
this.props.actions.login(this.state.username, this.state.password)
}
render(){
if (this.props.auth.isAuthenticated) {
let { returnTo } = this.props.auth
if (!returnTo || returnTo.match(/(login|logout|signup)/i)) {
returnTo = '/'
}
return