|
@@ -1,5 +1,6 @@
|
1
|
1
|
import React from 'react'
|
2
|
2
|
import { connect } from 'react-redux'
|
|
3
|
+import { withRouter } from 'react-router'
|
3
|
4
|
import i18n from '../i18n.js'
|
4
|
5
|
import appFactory from '../appFactory.js'
|
5
|
6
|
import { translate } from 'react-i18next'
|
|
@@ -21,7 +22,7 @@ import {
|
21
|
22
|
import {
|
22
|
23
|
postUserLogout
|
23
|
24
|
} from '../action-creator.async.js'
|
24
|
|
-import { COOKIE } from '../helper.js'
|
|
25
|
+import { COOKIE, PAGE } from '../helper.js'
|
25
|
26
|
|
26
|
27
|
class Header extends React.Component {
|
27
|
28
|
handleClickLogo = () => {}
|
|
@@ -42,7 +43,7 @@ class Header extends React.Component {
|
42
|
43
|
handleClickHelp = () => {}
|
43
|
44
|
|
44
|
45
|
handleClickLogout = async () => {
|
45
|
|
- const { dispatch, t } = this.props
|
|
46
|
+ const { history, dispatch, t } = this.props
|
46
|
47
|
|
47
|
48
|
const fetchPostUserLogout = await dispatch(postUserLogout())
|
48
|
49
|
if (fetchPostUserLogout.status === 204) {
|
|
@@ -50,6 +51,7 @@ class Header extends React.Component {
|
50
|
51
|
Cookies.remove(COOKIE.USER_AUTH)
|
51
|
52
|
|
52
|
53
|
dispatch(setUserDisconnected())
|
|
54
|
+ history.push(PAGE.LOGIN)
|
53
|
55
|
} else {
|
54
|
56
|
dispatch(newFlashMessage(t('Disconnection error', 'danger')))
|
55
|
57
|
}
|
|
@@ -107,4 +109,4 @@ class Header extends React.Component {
|
107
|
109
|
}
|
108
|
110
|
|
109
|
111
|
const mapStateToProps = ({ lang, user }) => ({ lang, user })
|
110
|
|
-export default connect(mapStateToProps)(translate()(appFactory(Header)))
|
|
112
|
+export default withRouter(connect(mapStateToProps)(translate()(appFactory(Header))))
|