Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 DialogTitle from '@material-ui/core/DialogTitle';
- import PropTypes from 'prop-types';
- import React, {useContext} from 'react';
- import {TodoContext} from '../contexts/TodoContext';
- function DeleteDialog(props) {
- const context = useContext(TodoContext);
- const hide = () => {
- props.setDeleteConfirmationIsShown(false);
- };
- return (
- <Dialog onClose={hide} fullWidth={true} maxWidth='sm' open={props.open}>
- <DialogTitle>Are you sure you wish to delete this to-do?</DialogTitle>
- <DialogContent>
- {props.todo.name}
- </DialogContent>
- <DialogActions>
- <Button onClick={hide}>Cancel</Button>
- <Button onClick={() => {
- context.deleteTodo({id: props.todo.id, name: props.todo.name});
- hide();
- }}>
- Delete
- </Button>
- </DialogActions>
- </Dialog>
- );
- }
- DeleteDialog.propTypes = {
- open: PropTypes.bool.isRequired,
- setDeleteConfirmationIsShown: PropTypes.func.isRequired,
- todo: PropTypes.shape({
- id: PropTypes.number.isRequired,
- name: PropTypes.string.isRequired,
- }),
- };
- export default DeleteDialog;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement