2017-01-16 13:04:02 +02:00
|
|
|
import { connect } from 'react-redux';
|
2023-05-28 17:38:10 +03:00
|
|
|
|
2023-11-15 13:01:51 +02:00
|
|
|
import { openModal, closeModal } from '../../../actions/modal';
|
2017-04-01 23:11:28 +03:00
|
|
|
import ModalRoot from '../components/modal_root';
|
2016-10-24 19:07:40 +03:00
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
2022-02-25 01:51:01 +02:00
|
|
|
ignoreFocus: state.getIn(['modal', 'ignoreFocus']),
|
|
|
|
type: state.getIn(['modal', 'stack', 0, 'modalType'], null),
|
|
|
|
props: state.getIn(['modal', 'stack', 0, 'modalProps'], {}),
|
2016-10-24 19:07:40 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
2022-02-25 01:51:01 +02:00
|
|
|
onClose (confirmationMessage, ignoreFocus = false) {
|
2021-07-25 02:14:43 +03:00
|
|
|
if (confirmationMessage) {
|
|
|
|
dispatch(
|
2023-05-25 16:42:37 +03:00
|
|
|
openModal({
|
|
|
|
modalType: 'CONFIRM',
|
|
|
|
modalProps: {
|
|
|
|
message: confirmationMessage.message,
|
|
|
|
confirm: confirmationMessage.confirm,
|
|
|
|
onConfirm: () => dispatch(closeModal({
|
|
|
|
modalType: undefined,
|
|
|
|
ignoreFocus: { ignoreFocus },
|
|
|
|
})),
|
|
|
|
} }),
|
2021-07-25 02:14:43 +03:00
|
|
|
);
|
|
|
|
} else {
|
2023-05-25 16:42:37 +03:00
|
|
|
dispatch(closeModal({
|
|
|
|
modalType: undefined,
|
|
|
|
ignoreFocus: { ignoreFocus },
|
|
|
|
}));
|
2021-07-25 02:14:43 +03:00
|
|
|
}
|
2016-10-24 19:07:40 +03:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2017-04-01 23:11:28 +03:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ModalRoot);
|