content: /*
   *
   * LanguageToggle
   *
   */
  
  import React from 'react';
  import { connect } from 'react-redux';
  import { createSelector } from 'reselect';
  
  import Toggle from 'components/Toggle';
  import Wrapper from './Wrapper';
  import messages from './messages';
  import { appLocales } from '../../i18n';
  import { changeLocale } from '../LanguageProvider/actions';
  import { selectLocale } from '../LanguageProvider/selectors';
  
  export class LocaleToggle extends React.PureComponent { // eslint-disable-line react/prefer-stateless-function
    render() {
      return (
        <Wrapper>
          <Toggle value={this.props.locale} values={appLocales} messages={messages} onToggle={this.props.onLocaleToggle} />
        </Wrapper>
      );
    }
  }
  
  LocaleToggle.propTypes = {
    onLocaleToggle: React.PropTypes.func,
    locale: React.PropTypes.string,
  };
  
  const mapStateToProps = createSelector(
    selectLocale(),
    (locale) => ({ locale })
  );
  
  export function mapDispatchToProps(dispatch) {
    return {
      onLocaleToggle: (evt) => dispatch(changeLocale(evt.target.value)),
      dispatch,
    };
  }
  
  export default connect(mapStateToProps, mapDispatchToProps)(LocaleToggle);
  