import React from 'react';
import PropTypes from 'prop-types';
import Button from '@material-ui/core/Button';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import { t } from 'Framework/i18n';

import './Styles.scss';
import CustomDialog from '../../../../../Shared/Components/CustomDialog';
import MainButton from '../../../../../Shared/Components/MainButton';

class Confirm extends React.Component {
    static propTypes = {
        confirm: PropTypes.object,
        onOk: PropTypes.func,
        onCancel: PropTypes.func,
        classes: PropTypes.object,
    };
    render() {
        const { confirm, onOk, onCancel } = this.props;

        const message = confirm && confirm.message ? confirm.message : '';
        const okLabel = confirm && confirm.okLabel ? confirm.okLabel : '';
        const cancelLabel = confirm && confirm.cancelLabel ? confirm.cancelLabel : '';

        return (
            <CustomDialog
                open={confirm !== null}
                onClose={onCancel}
                dialogTitle={t('errorDialogTitle')}
                onCancel={onCancel}
            >
                <DialogContent>
                    <DialogContentText>{message}</DialogContentText>
                </DialogContent>
                <DialogActions>
                    <Button onClick={onCancel} variant="contained">
                        {cancelLabel}
                    </Button>
                    <MainButton onClick={onOk} variant="contained">
                        {okLabel}
                    </MainButton>
                </DialogActions>
            </CustomDialog>
        );
    }
}

export default Confirm;
