summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/components/modals/ConfirmationModal.js
blob: 589047dc2410370091c1d289ee574a7026c44023 (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
36
37
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