@@ -4,8 +4,25 @@ import femaleOctocat from '../../assets/images/femalecodertocat.png';
4
4
import { Link } from 'react-router-dom' ;
5
5
import { BACKEND_URL , PROD_URL } from '../../constants' ;
6
6
import { Helmet } from 'react-helmet' ;
7
+ import { readEndpoint } from 'redux-json-api' ;
8
+ import PropTypes from 'prop-types' ;
9
+ import { bindActionCreators } from 'redux' ;
10
+ import { connect } from 'react-redux' ;
11
+ import ReactRouterPropTypes from 'react-router-prop-types' ;
7
12
8
13
class Signup extends React . Component {
14
+ static propTypes = {
15
+ readEndpoint : PropTypes . func . isRequired ,
16
+ authenticated : PropTypes . bool . isRequired ,
17
+ history : ReactRouterPropTypes . history . isRequired ,
18
+ }
19
+
20
+ componentWillReceiveProps ( ) {
21
+ if ( this . props . authenticated ) {
22
+ this . props . history . push ( '/profile' ) ;
23
+ }
24
+ }
25
+
9
26
render ( ) {
10
27
return (
11
28
< section id = "hero" className = "dark-bg img-bg img-bg-soft" style = { { backgroundImage : `url(${ blueBg } )` } } >
@@ -49,4 +66,15 @@ class Signup extends React.Component {
49
66
}
50
67
}
51
68
52
- export default Signup ;
69
+ const mapStateToProps = ( state ) => {
70
+ const { profile } = state ;
71
+ return {
72
+ authenticated : profile . authenticated || false ,
73
+ } ;
74
+ } ;
75
+
76
+ const mapDispatchToProps = ( dispatch ) => bindActionCreators ( {
77
+ readEndpoint,
78
+ } , dispatch ) ;
79
+
80
+ export default connect ( mapStateToProps , mapDispatchToProps ) ( Signup ) ;
0 commit comments