import React from 'react' import { connect } from 'react-redux' import i18n from '../i18n.js' import { translate } from 'react-i18next' import Cookies from 'js-cookie' import Logo from '../component/Header/Logo.jsx' import NavbarToggler from '../component/Header/NavbarToggler.jsx' import MenuLinkList from '../component/Header/MenuLinkList.jsx' import MenuActionListItemSearch from '../component/Header/MenuActionListItem/Search.jsx' import MenuActionListItemDropdownLang from '../component/Header/MenuActionListItem/DropdownLang.jsx' import MenuActionListItemHelp from '../component/Header/MenuActionListItem/Help.jsx' import MenuActionListItemMenuProfil from '../component/Header/MenuActionListItem/MenuProfil.jsx' import MenuActionListItemNotification from '../component/Header/MenuActionListItem/Notification.jsx' import logoHeader from '../img/logo-tracim.png' import { newFlashMessage, setLangActive, setUserDisconnected } from '../action-creator.sync.js' import { postUserLogout } from '../action-creator.async.js' import { COOKIE } from '../helper.js' class Header extends React.Component { handleClickLogo = () => {} handleClickFeature = () => {} handleClickExplore = () => {} handleClickAbout = () => {} handleChangeInput = e => this.setState({inputSearchValue: e.target.value}) handleClickSubmit = () => {} handleChangeLang = langId => { this.props.dispatch(setLangActive(langId)) i18n.changeLanguage(langId) } handleClickHelp = () => {} handleClickLogout = async () => { const { dispatch, t } = this.props const fetchPostUserLogout = await dispatch(postUserLogout()) if (fetchPostUserLogout.status === 204) { Cookies.remove(COOKIE.USER_LOGIN) Cookies.remove(COOKIE.USER_AUTH) dispatch(setUserDisconnected()) } else { dispatch(newFlashMessage(t('Disconnection error', 'danger'))) } } render () { const { lang, user } = this.props return (
) } } const mapStateToProps = ({ lang, user }) => ({ lang, user }) export default connect(mapStateToProps)(translate()(Header))