import React from 'react';
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 PropTypes from 'prop-types';

class Error extends React.Component {
    static propTypes = {
        dismissError: PropTypes.func,
        message: PropTypes.object,
    };
    handleClose = () => {
        this.props.dismissError();
    };

    render() {
        const { message } = this.props;

        return (
            message && (
                <CustomDialog open={true} onClose={this.handleClose} dialogTitle={t('errorDialogTitle')}>
                    <DialogContent>
                        <DialogContentText dangerouslySetInnerHTML={{ __html: message }} />
                    </DialogContent>
                    <DialogActions>
                        <Button onClick={this.handleClose} color="primary">
                            {t('okButtonLabel')}
                        </Button>
                    </DialogActions>
                </CustomDialog>
            )
        );
    }
}

export default Error;
