summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/containers/SelectLanguagePage.tsx
blob: 4be5e5472a3397628d94210ff9524b5a566c0c96 (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
28
29
30
31
32
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),
);