summaryrefslogtreecommitdiff
path: root/src/containers/profile/DeleteProfileModal.js
blob: b59db055464416f182902aede4cb4a9af7be2402 (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
import React from "react";
import {connect} from "react-redux";
import {closeDeleteProfileModal} from "../../actions/profile";
import {deleteCurrentUser} from "../../actions/users";
import ConfirmationModal from "../../components/modals/ConfirmationModal";

const NewSimulationModalComponent = ({visible, callback}) => (
    <ConfirmationModal title="Delete my account"
                       message="Are you sure you want do delete your OpenDC account?"
                       show={visible}
                       callback={callback}/>
);

const mapStateToProps = state => {
    return {
        visible: state.modals.deleteProfileModalVisible
    };
};

const mapDispatchToProps = dispatch => {
    return {
        callback: (isConfirmed) => {
            if (isConfirmed) {
                dispatch(deleteCurrentUser());
            }
            dispatch(closeDeleteProfileModal());
        }
    };
};

const NewSimulationModal = connect(
    mapStateToProps,
    mapDispatchToProps
)(NewSimulationModalComponent);

export default NewSimulationModal;