diff --git a/Client/src/Components/TabPanels/Account/ProfilePanel.jsx b/Client/src/Components/TabPanels/Account/ProfilePanel.jsx index a56b65919..a1cf7956e 100644 --- a/Client/src/Components/TabPanels/Account/ProfilePanel.jsx +++ b/Client/src/Components/TabPanels/Account/ProfilePanel.jsx @@ -72,6 +72,10 @@ const ProfilePanel = () => { ); if (error) return; + setLocalData((prev) => ({ + ...prev, + deleteProfileImage: false, + })); setProgress((prev) => ({ ...prev, isLoading: true })); setFile({ src: URL.createObjectURL(pic), @@ -116,13 +120,17 @@ const ProfilePanel = () => { // Resets picture-related states and clears interval const removePicture = () => { errors["picture"] && clearError("picture"); + setLocalData((prev) => ({ + ...prev, + deleteProfileImage: true, + })); clearInterval(intervalRef.current); // interrupt interval if image upload is canceled prior to completing the process setProgress({ value: 0, isLoading: false }); }; // Closes the picture update modal and resets related states const closePictureModal = () => { - removePicture(); + // removePicture(); setIsOpen(""); }; @@ -154,6 +162,10 @@ const ProfilePanel = () => { // Removes current profile image from UI const handleDeletePicture = () => { // TODO - implement delete picture function + setLocalData((prev) => ({ + ...prev, + deleteProfileImage: true, + })); }; // Initiates the account deletion process diff --git a/Client/src/Features/Auth/authSlice.js b/Client/src/Features/Auth/authSlice.js index bec0f3035..7bc238708 100644 --- a/Client/src/Features/Auth/authSlice.js +++ b/Client/src/Features/Auth/authSlice.js @@ -52,6 +52,7 @@ export const update = createAsyncThunk( fd.append("firstname", form.firstname); fd.append("lastname", form.lastname); fd.append("profileImage", imageResult.data); + fd.append("deleteProfileImage", form.deleteProfileImage); const res = await axios.post(`${BASE_URL}/auth/user/${user._id}`, fd, { headers: {