Skip to content

Commit

Permalink
add DeleteConfirm modal – needs work #29
Browse files Browse the repository at this point in the history
Move Confirmation modal into a different component or use a page instead
  • Loading branch information
blahosyl committed Aug 1, 2024
1 parent 045b8b7 commit 6020f1c
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/pages/tasks/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const Task = (props) => {
const is_owner = currentUser?.username === owner;
const history = useHistory();
const [showDeleteModal, setShowDeleteModal] = useState(false);
const [showDeletionComplete, setShowDeletionComplete] = useState(false);

const handleEdit = () => {
history.push(`/tasks/${id}/edit`);
Expand All @@ -52,6 +53,7 @@ const Task = (props) => {
} catch (err) {
console.log(err);
setShowDeleteModal(false);
setShowDeletionComplete(false);
}
};

Expand Down Expand Up @@ -139,7 +141,11 @@ const Task = (props) => {
<Modal.Footer>
<Button
variant="secondary"
onClick={() => setShowDeleteModal(false)}
onClick={() =>
{setShowDeleteModal(false);
showDeletionComplete(true);
}
}
>
Cancel
</Button>
Expand All @@ -148,6 +154,30 @@ const Task = (props) => {
</Button>
</Modal.Footer>
</Modal>

{/* deletion complete confirmation modal */}
<Modal
show={showDeletionComplete}
onHide={() => setShowDeletionComplete(false)}
centered={true}
>
<Modal.Header closeButton>
<Modal.Title>Task Deleted</Modal.Title>
</Modal.Header>
<Modal.Body>You have successfully deleted the task</Modal.Body>
<Modal.Footer>
<Button
variant="primary"
onClick={() =>
showDeletionComplete(false)
}
>
Close
</Button>
</Modal.Footer>
</Modal>


</Media>
</Card.Body>

Expand Down

0 comments on commit 6020f1c

Please sign in to comment.