summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/containers/SelectLanguagePage.tsx
blob: f72c79d1f2b933e622eeb5c1a0e93f1a7a08c3f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { goBack } from 'connected-react-router';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import SelectLanguage from '../components/SelectLanguage';
import withAppContext, { IAppContext } from '../context';
import { IReduxState, ReduxDispatch } from '../redux/store';

const mapStateToProps = (state: IReduxState) => ({
  preferredLocale: state.settings.guiSettings.preferredLocale,
});

const mapDispatchToProps = (dispatch: ReduxDispatch, props: IAppContext) => {
  const history = bindActionCreators({ goBack }, dispatch);

  return {
    preferredLocalesList: props.app.getPreferredLocaleList(),
    setPreferredLocale(locale: string) {
      props.app.setPreferredLocale(locale);
      history.goBack();
    },
    onClose() {
      history.goBack();
    },
  };
};

export default withAppContext(connect(mapStateToProps, mapDispatchToProps)(SelectLanguage));