-
-
Notifications
You must be signed in to change notification settings - Fork 468
/
DeleteEventProjectModal.tsx
70 lines (66 loc) · 1.85 KB
/
DeleteEventProjectModal.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React from 'react';
import { Modal, Button } from 'react-bootstrap';
import { toast } from 'react-toastify';
import { useMutation } from '@apollo/client';
import { DELETE_EVENT_PROJECT_MUTATION } from 'GraphQl/Mutations/mutations';
type ModalPropType = {
show: boolean;
project: {
_id: string;
title: string;
description: string;
};
handleClose: () => void;
refetchData: () => void;
};
export const DeleteEventProjectModal = (props: ModalPropType): JSX.Element => {
const [deleteMutation] = useMutation(DELETE_EVENT_PROJECT_MUTATION);
const deleteProject = (): void => {
toast.warn('Deleting the project...');
deleteMutation({
variables: {
id: props.project._id,
},
})
.then(() => {
toast.success('Deleted the project successfully!');
props.refetchData();
props.handleClose();
})
.catch((err) => {
toast.error('There was an error in deleting the project details!');
toast.error(err.message);
});
};
return (
<>
<Modal
show={props.show}
onHide={props.handleClose}
backdrop="static"
centered
>
<Modal.Header closeButton className="bg-primary">
<Modal.Title className="text-white">Delete Event Project</Modal.Title>
</Modal.Header>
<Modal.Body>
<div className="m-1 text-lg mb-0" id="deleteEventProjectConfirm">
Are you sure you want to delete this?
</div>
</Modal.Body>
<Modal.Footer>
<Button
variant="outline-secondary"
onClick={props.handleClose}
className="m-1"
>
Cancel
</Button>
<Button variant="danger" onClick={deleteProject} className="m-1">
Delete
</Button>
</Modal.Footer>
</Modal>
</>
);
};