1- import React , { Component } from 'react' ;
1+ import React , { useEffect } from 'react' ;
22import { connect } from 'react-redux' ;
33import FontAwesome from 'react-fontawesome' ;
44import { browserHistory } from 'react-router' ;
@@ -11,74 +11,63 @@ import Image from '../../components/Image';
1111import logo from '../../assets/images/logo.png' ;
1212import './index.scss' ;
1313
14- class Account extends Component {
15- constructor ( props ) {
16- super ( props ) ;
1714
18- this . handleSwitch = this . handleSwitch . bind ( this ) ;
19- this . handleLogout = this . handleLogout . bind ( this ) ;
20- }
15+ const Account = ( props ) => {
2116
22- handleSwitch ( e ) {
23- const { triggerSwitchNavigation } = this . props ;
24- e . preventDefault ( ) ;
25- const name = e . target . name || e . target . id ;
26- browserHistory . push ( `/${ name } ` ) ;
27- triggerSwitchNavigation ( navigationIndexer [ name ] ) ;
28- }
29-
30- componentWillMount ( ) {
17+ useEffect ( ( ) => {
3118 // if (!localStorage.getItem('accessToken')) {
3219 // window.location = '/';
3320 // }
34- }
35-
36- componentDidMount ( ) {
3721 document . title = 'Admin Account' ;
22+ } , [ ] )
23+
24+ const handleSwitch = ( e ) => {
25+ const { triggerSwitchNavigation } = props ;
26+ e . preventDefault ( ) ;
27+ const name = e . target . name || e . target . id ;
28+ browserHistory . push ( `/${ name } ` ) ;
29+ triggerSwitchNavigation ( navigationIndexer [ name ] ) ;
3830 }
3931
40- handleLogout ( e ) {
32+ const handleLogout = ( e ) => {
4133 e . preventDefault ( ) ;
42- const { type } = this . props ;
34+ const { type } = props ;
4335 localStorage . removeItem ( 'data' ) ;
4436 localStorage . removeItem ( 'accessToken' ) ;
4537 window . location = '/' ;
4638
4739 }
48-
49- render ( ) {
50- const { active } = this . props ;
51- return < section >
52- < section className = 'leftNavigation' >
53- < section className = "navigationMenu" >
54- < p className = 'text-center' > < Image image = { logo } /> </ p >
55- { /* <p className="navigationHeader">LOGGED USER</p>
40+ const { active } = props ;
41+ return < section >
42+ < section className = 'leftNavigation' >
43+ < section className = "navigationMenu" >
44+ < p className = 'text-center' > < Image image = { logo } /> </ p >
45+ { /* <p className="navigationHeader">LOGGED USER</p>
5646 <i style={{ color: 'silver' }}>{localStorage.getItem('user')}</i> */ }
57- </ section >
58- < section className = "navigationMenu" >
59- < p className = "navigationHeader" > Dashboard</ p >
60- < button name = 'dashboard' className = { `navigationItem ${ active === navigationIndexer . dashboard ? 'activeItem' : '' } ` } onClick = { this . handleSwitch } >
61- < FontAwesome id = 'events' name = "events" onClick = { this . handleSwitch } /> Dashboard
62- </ button >
63- </ section >
64- < section className = "navigationMenu" >
65- < p className = "navigationHeader" > Contact Us</ p >
66- < button name = 'contactUs' className = { `navigationItem ${ active === navigationIndexer . contactUs ? 'activeItem' : '' } ` } onClick = { this . handleSwitch } >
67- < FontAwesome id = 'tournament' name = "tournament" onClick = { this . handleSwitch } /> Contact Us
47+ </ section >
48+ < section className = "navigationMenu" >
49+ < p className = "navigationHeader" > Dashboard</ p >
50+ < button name = 'dashboard' className = { `navigationItem ${ active === navigationIndexer . dashboard ? 'activeItem' : '' } ` } onClick = { handleSwitch } >
51+ < FontAwesome id = 'events' name = "events" onClick = { handleSwitch } /> Dashboard
6852 </ button >
69- </ section >
70- < section className = "navigationMenu" >
71- < p className = "navigationHeader" > Account </ p >
72- < button name = 'logout ' className = { `navigationItem ${ active === navigationIndexer . constants ? 'activeItem' : '' } ` } onClick = { this . handleLogout } >
73- < FontAwesome id = 'logout ' name = "sign-out " onClick = { this . handleSwitch } /> Logout
53+ </ section >
54+ < section className = "navigationMenu" >
55+ < p className = "navigationHeader" > Contact Us </ p >
56+ < button name = 'contactUs ' className = { `navigationItem ${ active === navigationIndexer . contactUs ? 'activeItem' : '' } ` } onClick = { handleSwitch } >
57+ < FontAwesome id = 'tournament ' name = "tournament " onClick = { handleSwitch } /> Contact Us
7458 </ button >
75- </ section >
7659 </ section >
77- < section className = 'dynamicContainer' >
78- { this . props . children || < Dashboard /> }
60+ < section className = "navigationMenu" >
61+ < p className = "navigationHeader" > Account</ p >
62+ < button name = 'logout' className = { `navigationItem ${ active === navigationIndexer . constants ? 'activeItem' : '' } ` } onClick = { handleLogout } >
63+ < FontAwesome id = 'logout' name = "sign-out" onClick = { handleSwitch } /> Logout
64+ </ button >
7965 </ section >
80- </ section > ;
81- }
66+ </ section >
67+ < section className = 'dynamicContainer' >
68+ { props . children || < Dashboard /> }
69+ </ section >
70+ </ section > ;
8271}
8372
8473const mapDispatchToProps = dispatch => {
0 commit comments