{"size": 2176, "ext": "js", "max_stars_repo_path": "devUI/src/components/common/DeleteRecord.js", "max_stars_repo_name": "geekyorion/devSocialMedia", "max_stars_repo_stars_event_min_datetime": "2020-11-07T13:38:16.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-07T13:38:16.000Z", "max_issues_repo_path": "devUI/src/components/common/DeleteRecord.js", "max_issues_repo_name": "geekyorion/devSocialMedia", "max_issues_repo_issues_event_min_datetime": "2022-02-27T23:53:29.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-27T23:53:29.000Z", "max_forks_repo_path": "devUI/src/components/common/DeleteRecord.js", "max_forks_repo_name": "geekyorion/devSocialMedia", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 39.5636363636, "max_line_length": 118, "alphanum_fraction": 0.4710477941}
import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { isEmpty } from '../../utils/utils';

const DeleteRecord = () => {
    const dispatch = useDispatch();
    const processing = useSelector(state => state.processing.processing);
    const deleteState = useSelector(state => state.delete);

    const handleDelete = () => {
        const param = deleteState.modalParam;
        if (isEmpty(param)) {
            dispatch(deleteState.modalFunc());
        } else {
            dispatch(deleteState.modalFunc(param));
        }
        window.$('#deleteRecord').modal('hide');
    };

    return (
        <div className="modal fade" id="deleteRecord" tabIndex="-1" aria-labelledby="deleteRecord" aria-hidden="true">
            <div className="modal-dialog">
                <div className="modal-content">
                    <div className="modal-header">
                        <h5 className="modal-title" id="deleteRecordTitle">Delete {deleteState.modalType}</h5>
                        <button type="button" className="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div className="modal-body">
                        <p>
                            Are you sure you want to delete this {deleteState.modalType}.
                            <br />
                            This can not be undone.
                        </p>
                    </div>
                    <div className="modal-footer">
                        <button type="button" className="btn btn-secondary btn-sm" data-dismiss="modal">Close</button>
                        <button
                            type="button"
                            className="btn btn-danger btn-sm"
                            onClick={handleDelete}
                            disabled={processing}
                        >
                            Delete
                        </button>
                    </div>
                </div>
            </div>
        </div>
    );
};

export default DeleteRecord;
