summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/containers/SettingsPage.tsx
blob: 2bea17892bd5a685310b50fc307d40b3104b8429 (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
33
34
35
import { connect } from 'react-redux';
import Settings from '../components/Settings';
import withAppContext, { IAppContext } from '../context';
import { IHistoryProps, withHistory } from '../lib/history';
import { RoutePath } from '../lib/routes';
import { IReduxState, ReduxDispatch } from '../redux/store';

const mapStateToProps = (state: IReduxState, props: IAppContext) => ({
  preferredLocaleDisplayName: props.app.getPreferredLocaleDisplayName(
    state.settings.guiSettings.preferredLocale,
  ),
  loginState: state.account.status,
  connectedToDaemon: state.userInterface.connectedToDaemon,
  accountExpiry: state.account.expiry,
  appVersion: state.version.current,
  consistentVersion: state.version.consistent,
  upToDateVersion: state.version.suggestedUpgrade ? false : true,
  suggestedIsBeta: state.version.suggestedIsBeta ?? false,
  isOffline: state.connection.isBlocked,
});
const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IHistoryProps & IAppContext) => {
  return {
    onQuit: () => props.app.quit(),
    onClose: () => props.history.dismiss(),
    onViewSelectLanguage: () => props.history.push(RoutePath.selectLanguage),
    onViewAccount: () => props.history.push(RoutePath.accountSettings),
    onViewSupport: () => props.history.push(RoutePath.support),
    onViewPreferences: () => props.history.push(RoutePath.preferences),
    onViewAdvancedSettings: () => props.history.push(RoutePath.advancedSettings),
    onExternalLink: (url: string) => props.app.openUrl(url),
    updateAccountData: () => props.app.updateAccountData(),
  };
};

export default withAppContext(withHistory(connect(mapStateToProps, mapDispatchToProps)(Settings)));