|
@@ -21,7 +21,8 @@ import {
|
21
|
21
|
setUserDisconnected
|
22
|
22
|
} from '../action-creator.sync.js'
|
23
|
23
|
import {
|
24
|
|
- postUserLogout
|
|
24
|
+ postUserLogout,
|
|
25
|
+ putUserLang
|
25
|
26
|
} from '../action-creator.async.js'
|
26
|
27
|
import { COOKIE, PAGE, PROFILE } from '../helper.js'
|
27
|
28
|
|
|
@@ -35,10 +36,19 @@ class Header extends React.Component {
|
35
|
36
|
handleChangeInput = e => this.setState({inputSearchValue: e.target.value})
|
36
|
37
|
handleClickSubmit = () => {}
|
37
|
38
|
|
38
|
|
- handleChangeLang = idLang => {
|
39
|
|
- this.props.dispatch(setUserLang(idLang))
|
40
|
|
- i18n.changeLanguage(idLang)
|
41
|
|
- this.props.dispatchCustomEvent('allApp_changeLang', idLang)
|
|
39
|
+ handleChangeLang = async idLang => {
|
|
40
|
+ const { props } = this
|
|
41
|
+
|
|
42
|
+ const fetchPutUserLang = await props.dispatch(putUserLang(props.user, idLang))
|
|
43
|
+ switch (fetchPutUserLang.status) {
|
|
44
|
+ case 200:
|
|
45
|
+ props.dispatch(setUserLang(idLang))
|
|
46
|
+ i18n.changeLanguage(idLang)
|
|
47
|
+ props.dispatchCustomEvent('allApp_changeLang', idLang)
|
|
48
|
+ break
|
|
49
|
+ default: props.dispatch(newFlashMessage(props.t('Error while saving new lang'))); break
|
|
50
|
+ }
|
|
51
|
+
|
42
|
52
|
}
|
43
|
53
|
|
44
|
54
|
handleClickHelp = () => {}
|
|
@@ -93,7 +103,7 @@ class Header extends React.Component {
|
93
|
103
|
|
94
|
104
|
<MenuActionListItemDropdownLang
|
95
|
105
|
langList={lang}
|
96
|
|
- idLangActive={user.lang}
|
|
106
|
+ idLangActive={user.lang ? user.lang : 'en'}
|
97
|
107
|
onChangeLang={this.handleChangeLang}
|
98
|
108
|
/>
|
99
|
109
|
|