summaryrefslogtreecommitdiff
path: root/src/components/modals/ConfirmationModal.js
blob: 4543cfd434f6e78eea97c31fc95d456a78d4f50b (plain)
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
import PropTypes from "prop-types";
import React from "react";
import Modal from "./Modal";

class ConfirmationModal extends React.Component {
    static propTypes = {
        title: PropTypes.string.isRequired,
        message: PropTypes.string.isRequired,
        show: PropTypes.bool.isRequired,
        callback: PropTypes.func.isRequired,
    };

    onConfirm() {
        this.props.callback(true);
    }

    onCancel() {
        this.props.callback(false);
    }

    render() {
        return (
            <Modal title={this.props.title}
                   show={this.props.show}
                   onSubmit={this.onConfirm.bind(this)}
                   onCancel={this.onCancel.bind(this)}
                   submitButtonType="danger"
                   submitButtonText="Confirm">
                {this.props.message}
            </Modal>
        );
    }
}

export default ConfirmationModal;