summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/containers/SelectLanguagePage.tsx
blob: 5c073c22e1ba370d899b124efba903f2014c550e (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
import { connect } from 'react-redux';
import { RouteComponentProps, withRouter } from 'react-router';
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: RouteComponentProps & IAppContext) => {
  return {
    preferredLocalesList: props.app.getPreferredLocaleList(),
    async setPreferredLocale(locale: string) {
      await props.app.setPreferredLocale(locale);
      props.history.goBack();
    },
    onClose() {
      props.history.goBack();
    },
  };
};

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