-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (34 loc) · 1.46 KB
/
index.js
File metadata and controls
41 lines (34 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import {Route, NavLink} from 'react-router-dom'
import {connect} from 'react-redux'
import {signIn, signUp} from '../../../ducks/auth'
import {errorSelector, loadingSelector} from '../../../ducks/auth'
import SignInForm from '../../auth/SignInForm'
import SignUpForm from '../../auth/SignUpForm'
class Auth extends Component {
static propTypes = {
authError: PropTypes.object,
authLoading: PropTypes.bool.isRequired
};
render() {
const {authLoading, authError} = this.props;
return (
<div>
<h2>Auth page</h2>
<ul>
<li><NavLink to = '/auth/sign-in' activeStyle={{color: 'red'}}>Sign In</NavLink></li>
<li><NavLink to = '/auth/sign-up' activeStyle={{color: 'red'}}>Sign Up</NavLink></li>
</ul>
<Route path='/auth/sign-in' render={() => <SignInForm onSubmit={this.onSignIn} authError={authError} authLoading={authLoading} />} />
<Route path='/auth/sign-up' render={() => <SignUpForm onSubmit={this.onSignUp}/>} />
</div>
)
}
onSignIn = ({ email, password }) => this.props.signIn(email, password)
onSignUp = ({ email, password }) => this.props.signUp(email, password)
}
export default connect(state => ({
authError: errorSelector(state),
authLoading: loadingSelector(state)
}), { signIn, signUp })(Auth)