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

67 lines
2.0 KiB

6 years ago
/* @flow */
import * as React from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { injectIntl } from 'react-intl';
6 years ago
import type { MapStateToProps, MapDispatchToProps } from 'react-redux';
import type { State, Dispatch } from 'flowtype';
import { reconnect } from 'actions/DiscoveryActions';
import * as NotificationActions from 'actions/NotificationActions';
import StaticNotifications from './components/Static';
import AccountNotifications from './components/Account';
import ActionNotifications from './components/Action';
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,
};
6 years ago
export type DispatchProps = {
5 years ago
close: typeof NotificationActions.close,
blockchainReconnect: typeof reconnect,
};
type OwnProps = {
5 years ago
intl: any,
};
6 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: MapStateToProps<State, OwnProps, StateProps> = (
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: MapDispatchToProps<Dispatch, OwnProps, DispatchProps> = (
dispatch: Dispatch
): DispatchProps => ({
6 years ago
close: bindActionCreators(NotificationActions.close, dispatch),
blockchainReconnect: bindActionCreators(reconnect, dispatch),
});
5 years ago
export default injectIntl(
connect(
mapStateToProps,
mapDispatchToProps
)(Notifications)
);