summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/containers/NotificationAreaContainer.tsx
blob: 814b055d9764c1e9e2cd81e64ad36ab741c266ee (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 { shell } from 'electron';
import { links } from '../../config.json';
import NotificationArea from '../components/NotificationArea';
import withAppContext, { IAppContext } from '../context';
import AccountExpiry from '../lib/account-expiry';
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),
);