summaryrefslogtreecommitdiffhomepage
path: root/app/containers/SupportPage.js
blob: aaa9f786cd9c0ba18dc3156874a42bda2a79b65c (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
// @flow
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { push } from 'react-router-redux';
import Support from '../components/Support';
import { openItem } from '../lib/platform';
import { collectProblemReport, sendProblemReport } from '../lib/problem-report';

import type { ReduxState, ReduxDispatch } from '../redux/store';
import type { SharedRouteProps } from '../routes';

const mapStateToProps = (state: ReduxState) => state;

const mapDispatchToProps = (dispatch: ReduxDispatch, _props: SharedRouteProps) => {
  const { push: pushHistory } = bindActionCreators({ push }, dispatch);

  return {
    onClose: () => pushHistory('/settings'),

    onCollectLog: (toRedact) => {
      return collectProblemReport(toRedact);
    },

    onViewLog: (path) => openItem(path),

    onSend: (email, message, savedReport) => {
      return sendProblemReport(email, message, savedReport);
    }
  };
};

export default connect(mapStateToProps, mapDispatchToProps)(Support);