2017-12-05 03:00:11 +01:00
|
|
|
const { Component } = require('react')
|
|
|
|
const PropTypes = require('prop-types')
|
|
|
|
const h = require('react-hyperscript')
|
|
|
|
const { connect } = require('react-redux')
|
|
|
|
const actions = require('../../actions')
|
|
|
|
|
|
|
|
class NotificationModal extends Component {
|
|
|
|
render () {
|
|
|
|
const {
|
|
|
|
header,
|
|
|
|
message,
|
2018-02-08 18:18:25 +01:00
|
|
|
showCancelButton = false,
|
|
|
|
showConfirmButton = false,
|
|
|
|
hideModal,
|
|
|
|
onConfirm,
|
2017-12-05 03:00:11 +01:00
|
|
|
} = this.props
|
|
|
|
|
2018-02-08 18:18:25 +01:00
|
|
|
const showButtons = showCancelButton || showConfirmButton
|
|
|
|
|
2017-12-05 03:00:11 +01:00
|
|
|
return h('div', [
|
2018-02-08 18:18:25 +01:00
|
|
|
h('div.notification-modal__wrapper', {
|
2017-12-05 03:00:11 +01:00
|
|
|
}, [
|
|
|
|
|
2018-02-08 18:18:25 +01:00
|
|
|
h('div.notification-modal__header', {}, [
|
2017-12-05 03:00:11 +01:00
|
|
|
header,
|
|
|
|
]),
|
|
|
|
|
2018-02-08 18:18:25 +01:00
|
|
|
h('div.notification-modal__message-wrapper', {}, [
|
|
|
|
h('div.notification-modal__message', {}, [
|
2017-12-05 03:00:11 +01:00
|
|
|
message,
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
|
|
|
|
h('div.modal-close-x', {
|
2018-02-08 18:18:25 +01:00
|
|
|
onClick: hideModal,
|
2017-12-05 03:00:11 +01:00
|
|
|
}),
|
|
|
|
|
2018-02-08 18:18:25 +01:00
|
|
|
showButtons && h('div.notification-modal__buttons', [
|
|
|
|
|
|
|
|
showCancelButton && h('div.btn-cancel.notification-modal__buttons__btn', {
|
|
|
|
onClick: hideModal,
|
|
|
|
}, 'Cancel'),
|
|
|
|
|
|
|
|
showConfirmButton && h('div.btn-clear.notification-modal__buttons__btn', {
|
|
|
|
onClick: () => {
|
|
|
|
onConfirm()
|
|
|
|
hideModal()
|
|
|
|
},
|
|
|
|
}, 'Confirm'),
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
2017-12-05 03:00:11 +01:00
|
|
|
]),
|
|
|
|
])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NotificationModal.propTypes = {
|
|
|
|
hideModal: PropTypes.func,
|
|
|
|
header: PropTypes.string,
|
2018-02-08 18:18:25 +01:00
|
|
|
message: PropTypes.node,
|
|
|
|
showCancelButton: PropTypes.bool,
|
|
|
|
showConfirmButton: PropTypes.bool,
|
|
|
|
onConfirm: PropTypes.func,
|
2017-12-05 03:00:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => {
|
|
|
|
return {
|
|
|
|
hideModal: () => {
|
|
|
|
dispatch(actions.hideModal())
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = connect(null, mapDispatchToProps)(NotificationModal)
|