diff --git a/front-end/src/Pages/Deliverables.jsx b/front-end/src/Pages/Deliverables.jsx index 344277d..518ab60 100644 --- a/front-end/src/Pages/Deliverables.jsx +++ b/front-end/src/Pages/Deliverables.jsx @@ -116,6 +116,8 @@ const onInputChange=(e)=>{ //When 'Update' button is clicked in the interface : Only Edit const onUpdateSubmit = async (e) => { e.preventDefault(); // Prevent default form submission + const confirmUpdate = window.confirm('Are you sure you want to update this deliverable?'); + if (!confirmUpdate) return; try { await axios.put(`http://localhost:8080/deliverable/update/${deliverable.deliverableId}`, deliverable); // Optionally, reload the data after successful submission @@ -143,13 +145,21 @@ const onInputChange=(e)=>{ const onDeleteClick = async (deliverableId) => { console.log("Delete button clicked"); console.log(deliverableId); - try { - await axios.delete(`http://localhost:8080/deliverable/delete/${deliverableId}`); - loadData(); - alert("Deliverable Deleted!"); - } catch (error) { - console.error("Error deleting deliverable:", error); - } + const confirmDelete = window.confirm('Are you sure you want to delete this deliverable?'); + if (!confirmDelete) return; + try { + await axios.delete(`http://localhost:8080/deliverable/delete/${deliverableId}`); + loadData(); + if (response.status === 200) { + alert('Deliverable deleted successfully'); + loadData(); + } else { + alert('Failed to delete deliverable'); + } + } catch (error) { + console.error("Error deleting deliverable:", error); + alert("Failed to delete deliverable!"); + } } /************************** View a specific entry *************************************/ diff --git a/front-end/src/Pages/Gallery.jsx b/front-end/src/Pages/Gallery.jsx index a0e73ba..f0ddf86 100644 --- a/front-end/src/Pages/Gallery.jsx +++ b/front-end/src/Pages/Gallery.jsx @@ -87,12 +87,16 @@ const Gallery = () => { * Sends a DELETE request to remove the item from the backend. */ const onDeleteClick = async (albumID) => { + const confirmDelete = window.confirm('Are you sure you want to delete this album?'); + if (!confirmDelete) return; try { await axios.delete(`http://localhost:8080/api/v1/gallery/${albumID}`); const latestGallery = await fetchGallery(); setGallery(latestGallery); + alert('Album deleted successfully'); } catch (error) { console.error("Error deleting gallery item:", error); + alert("Failed to delete album!"); } } // When 'Close' button is clicked: for Edit, and Add New diff --git a/front-end/src/Pages/News.jsx b/front-end/src/Pages/News.jsx index 1cdeb07..1a65162 100644 --- a/front-end/src/Pages/News.jsx +++ b/front-end/src/Pages/News.jsx @@ -77,14 +77,17 @@ const News = () => { const onDeleteClick = async (newsID) => { console.log("Delete button clicked"); console.log(newsID); // Log the newsID for debugging + const confirmDelete = window.confirm('Are you sure you want to delete this news?'); + if (!confirmDelete) return; try { await axios.delete(`http://localhost:8080/api/v1/news/${newsID}`); // Send DELETE request - // Fetch the updated list of news and update the state const latestNews = await fetchNews(); setNews(latestNews); + alert('News deleted successfully'); } catch (error) { console.error("Error deleting news:", error); // Log any errors + alert("Failed to delete news!"); } } // When 'Close' button is clicked: for Edit, and Add New diff --git a/front-end/src/Pages/ProjectManagement.jsx b/front-end/src/Pages/ProjectManagement.jsx index 25db560..c074c22 100644 --- a/front-end/src/Pages/ProjectManagement.jsx +++ b/front-end/src/Pages/ProjectManagement.jsx @@ -176,7 +176,7 @@ try { headers: { 'Content-Type': 'multipart/form-data' }}); - alert("task added"); + alert("Task added successfully!"); // reload the data after successful submission setTasks([...tasks,task]) // Clear the form fields after successful submission if needed @@ -192,26 +192,30 @@ try { //When 'Update' button is clicked in the interface : Only Edit const onUpdateSubmit = async (e) => { e.preventDefault(); // Prevent default form submission + setIsLoading(true); // Show loading indicator + const confirmUpdate = window.confirm('Are you sure you want to update this task?'); + if (!confirmUpdate) return; + const {assignedUsers, ...newtaskFormat } = task; const formData = new FormData(); for (const key in newtaskFormat) { formData.append(key, newtaskFormat[key]); } formData.append("assignedUsers",JSON.stringify(assignedUsers.map(({ admin, ...assignedUsersDetails }) => assignedUsersDetails))) - console.log("task",task) try { - console.log("task.... ",formData) await axios.put(`http://localhost:8080/api/v1/tasks/updateWithUsers`, formData, { headers: { 'Content-Type': 'multipart/form-data' }});; - - // Optionally, change the tasks list after successful submission - setTasks([...tasks,task]) - setEditRow(false); - setShowInterface() + // Optionally, change the tasks list after successful submission + setTasks([...tasks,task]) + setEditRow(false); + setShowInterface(false) + alert("Task updated successfully!"); } catch (error) { console.error("Error editing tasks:", error); + } finally { + setIsLoading(false); // Hide loading indicator } }; @@ -463,8 +467,10 @@ if(loggedInUser){ } - - {addRow?
: } +