Settings.jsx 2.13 KB
Newer Older
1
import React from 'react';
Benjamin Chodoroff's avatar
Benjamin Chodoroff committed
2
import { connect } from 'react-redux';
valzav's avatar
valzav committed
3
import tt from 'counterpart';
Benjamin Chodoroff's avatar
Benjamin Chodoroff committed
4
import * as appActions from 'app/redux/AppReducer';
Benjamin Chodoroff's avatar
Benjamin Chodoroff committed
5
import o2j from 'shared/clash/object2json';
6 7

class Settings extends React.Component {
roadscape's avatar
roadscape committed
8 9 10 11 12 13
    handleLanguageChange = event => {
        const locale = event.target.value;
        const userPreferences = { ...this.props.user_preferences, locale };
        this.props.setUserPreferences(userPreferences);
    };

14
    render() {
/ /\ / /\/'s avatar
/ /\ / /\/ committed
15
        const { user_preferences } = this.props;
Benjamin Chodoroff's avatar
Benjamin Chodoroff committed
16 17
        return (
            <div className="Settings">
18 19 20
                <div className="row">
                    <div className="small-12 medium-6 large-4 columns">
                        <h4>{tt('settings_jsx.preferences')}</h4>
/ /\ / /\/'s avatar
/ /\ / /\/ committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
                        {tt('g.choose_language')}
                        <select
                            defaultValue={user_preferences.locale}
                            onChange={this.handleLanguageChange}
                        >
                            <option value="en">English</option>
                            <option value="es">Spanish Español</option>
                            <option value="ru">Russian русский</option>
                            <option value="fr">French français</option>
                            <option value="it">Italian italiano</option>
                            <option value="ko">Korean 한국어</option>
                            <option value="ja">Japanese 日本語</option>
                            <option value="pl">Polish</option>
                            <option value="zh">Chinese 简体中文</option>
                        </select>
36 37
                    </div>
                </div>
Benjamin Chodoroff's avatar
Benjamin Chodoroff committed
38 39
            </div>
        );
40 41 42
    }
}

43
export default connect(
44 45
    // mapStateToProps
    (state, ownProps) => {
46
        const user_preferences = state.app.get('user_preferences').toJS();
47
        return {
48
            user_preferences,
Benjamin Chodoroff's avatar
Benjamin Chodoroff committed
49 50
            ...ownProps,
        };
51 52 53
    },
    // mapDispatchToProps
    dispatch => ({
roadscape's avatar
roadscape committed
54 55 56
        setUserPreferences: payload => {
            dispatch(appActions.setUserPreferences(payload));
        },
57
    })
Benjamin Chodoroff's avatar
Benjamin Chodoroff committed
58
)(Settings);