You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-wallet/src/components/notifications/Context/index.js

64 lines
1.9 KiB

6 years ago
/* @flow */
import * as React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { injectIntl } from 'react-intl';
5 years ago
import type { IntlShape } from 'react-intl';
6 years ago
import type { State, Dispatch } from 'flowtype';
import { subscribe } from 'actions/BlockchainActions';
6 years ago
import * as NotificationActions from 'actions/NotificationActions';
import StaticNotifications from './components/Static';
import AccountNotifications from './components/Account';
import ActionNotifications from './components/Action';
5 years ago
type OwnProps = {|
intl: IntlShape,
|};
export type StateProps = {|
5 years ago
router: $ElementType<State, 'router'>,
notifications: $ElementType<State, 'notifications'>,
selectedAccount: $ElementType<State, 'selectedAccount'>,
wallet: $ElementType<State, 'wallet'>,
blockchain: $ElementType<State, 'blockchain'>,
children?: React.Node,
5 years ago
|};
6 years ago
5 years ago
export type DispatchProps = {|
5 years ago
close: typeof NotificationActions.close,
blockchainReconnect: typeof subscribe,
5 years ago
|};
6 years ago
5 years ago
export type Props = {| ...OwnProps, ...StateProps, ...DispatchProps |};
6 years ago
const Notifications = (props: Props) => (
<React.Fragment>
6 years ago
<StaticNotifications {...props} />
<AccountNotifications {...props} />
<ActionNotifications {...props} />
</React.Fragment>
6 years ago
);
5 years ago
const mapStateToProps = (state: State): StateProps => ({
6 years ago
router: state.router,
notifications: state.notifications,
selectedAccount: state.selectedAccount,
wallet: state.wallet,
blockchain: state.blockchain,
});
5 years ago
const mapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({
6 years ago
close: bindActionCreators(NotificationActions.close, dispatch),
blockchainReconnect: bindActionCreators(subscribe, dispatch),
6 years ago
});
5 years ago
export default injectIntl<OwnProps>(
connect<Props, OwnProps, StateProps, DispatchProps, State, Dispatch>(
5 years ago
mapStateToProps,
mapDispatchToProps
)(Notifications)
);