summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/containers/NotificationAreaContainer.tsx
blob: 1eed9f4a17b15d3e6ff61e9352780c21f01c7cef (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
import { connect } from 'react-redux';

import { shell } from 'electron';
import { links } from '../../config.json';
import AccountExpiry from '../../shared/account-expiry';
import NotificationArea from '../components/NotificationArea';
import withAppContext, { IAppContext } from '../context';
import { IReduxState, ReduxDispatch } from '../redux/store';

const mapStateToProps = (state: IReduxState, _props: IAppContext) => ({
  accountExpiry: state.account.expiry
    ? new AccountExpiry(state.account.expiry, state.userInterface.locale)
    : undefined,
  tunnelState: state.connection.status,
  version: state.version,
  blockWhenDisconnected: state.settings.blockWhenDisconnected,
});

const mapDispatchToProps = (_dispatch: ReduxDispatch, props: IAppContext) => {
  return {
    onOpenDownloadLink(): Promise<void> {
      return shell.openExternal(links.download);
    },
    onOpenBuyMoreLink(): Promise<void> {
      return props.app.openLinkWithAuth(links.purchase);
    },
  };
};

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