forked from iiitl/MERN_AUTH
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iiitl#7 Implement Alert Box for Confirming Task Deletion
- Loading branch information
1 parent
50a9b8b
commit cc4e306
Showing
3 changed files
with
84 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React, { useState } from "react"; | ||
|
||
export const Modal = ({ handleClick }) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
// console.log(handleClick); | ||
const openModal = () => { | ||
setIsOpen(true); | ||
}; | ||
|
||
const closeModal = () => { | ||
setIsOpen(false); | ||
}; | ||
|
||
const deleteTask = () => { | ||
setIsOpen(false); | ||
handleClick(); | ||
}; | ||
|
||
return ( | ||
<span> | ||
<span className="material-symbols-outlined" onClick={openModal}> | ||
delete | ||
</span> | ||
{isOpen && ( | ||
<div className="modal-overlay"> | ||
<div className="modal"> | ||
<h2>Are you sure you want to delete the task?</h2> | ||
<div className="over-b"> | ||
<button className="button" onClick={deleteTask}> | ||
Yes | ||
</button> | ||
<button className="button" onClick={closeModal}> | ||
Close | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
)} | ||
</span> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters