aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/modals/notification/notification.container.js
blob: 5b98714da97fce854665366e8cbe29de1620044b (plain) (blame)
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
36
37
38
import { connect } from 'react-redux'
import Notification from './notification.component'

const { hideModal } = require('../../../actions')

const mapStateToProps = state => {
  const { appState: { modal: { modalState: { props } } } } = state
  const { onHide } = props
  return {
    onHide,
  }
}

const mapDispatchToProps = dispatch => {
  return {
    hideModal: () => dispatch(hideModal()),
  }
}

const mergeProps = (stateProps, dispatchProps, ownProps) => {
  const { onHide, ...otherStateProps } = stateProps
  const { hideModal, ...otherDispatchProps } = dispatchProps

  return {
    ...otherStateProps,
    ...otherDispatchProps,
    ...ownProps,
    onHide: () => {
      hideModal()

      if (onHide && typeof onHide === 'function') {
        onHide()
      }
    },
  }
}

export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(Notification)