Commit ec3d2b51 authored by Patrik Meijer's avatar Patrik Meijer
Browse files

Add ConfirmDialog

parent e35f77ea
import React from 'react';
import PropTypes from 'prop-types';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
function ConfirmDialog(props) {
return (
<div>
<Dialog
open
onClose={() => props.onClose(false)}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title">{props.title}</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-description">
{props.message}
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={() => props.onClose(false)} color="primary">
{props.noButtonText}
</Button>
<Button onClick={() => props.onClose(true)} color="primary" autoFocus>
{props.yesButtonText}
</Button>
</DialogActions>
</Dialog>
</div>
);
}
ConfirmDialog.propTypes = {
title: PropTypes.string.isRequired,
message: PropTypes.string.isRequired,
noButtonText: PropTypes.string,
yesButtonText: PropTypes.string,
onClose: PropTypes.func,
};
ConfirmDialog.defaultProps = {
onClose: (ok) => {
console.log(`OK was${ok ? '' : ' not'} pressed`);
},
noButtonText: 'Cancel',
yesButtonText: 'OK',
};
export default ConfirmDialog;
export {default} from './ConfirmDialog';
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment