@@ -18,10 +18,12 @@ import { NotificationContext } from "../../../components/Notifications";
1818import Input from "../../../components/Input" ;
1919import Comment from "../../../components/Comment" ;
2020import LoadingContext from "../../../utils/LoadingContext" ;
21+ import Modal from "../../../components/Modal" ;
2122
2223const Announcement = ( { announcement, token, userRole } ) => {
2324 const [ pinned , setPinned ] = useState ( announcement . pinned ) ;
2425 const [ comments , setComments ] = useState ( announcement . comments ) ;
26+ const [ showDeleteModal , setShowDeleteModal ] = useState ( false ) ;
2527
2628 const { addNotification } = useContext ( NotificationContext ) ;
2729 const { setLoading } = useContext ( LoadingContext ) ;
@@ -180,7 +182,10 @@ const Announcement = ({ announcement, token, userRole }) => {
180182 </ Button >
181183 </ a >
182184 </ Link >
183- < Button onClick = { handleDelete } variant = "secondary" >
185+ < Button
186+ onClick = { ( ) => setShowDeleteModal ( true ) }
187+ variant = "secondary"
188+ >
184189 Delete
185190 </ Button >
186191 </ Box >
@@ -246,6 +251,26 @@ const Announcement = ({ announcement, token, userRole }) => {
246251 </ Box >
247252 ) }
248253 </ Box >
254+ { showDeleteModal && (
255+ < Modal close = { ( ) => setShowDeleteModal ( false ) } >
256+ < Text mb = { 5 } >
257+ Are you sure you want to delete this announcement? This cannot be
258+ undone.
259+ </ Text >
260+ < Box display = "flex" justifyContent = "flex-end" >
261+ < Button
262+ onClick = { ( ) => setShowDeleteModal ( false ) }
263+ variant = "secondary"
264+ mr = { 3 }
265+ >
266+ Cancel
267+ </ Button >
268+ < Button onClick = { handleDelete } variant = "danger" >
269+ Delete
270+ </ Button >
271+ </ Box >
272+ </ Modal >
273+ ) }
249274 </ >
250275 ) ;
251276} ;
0 commit comments