Added delete image flag to form
This commit is contained in:
1 parent
7deb796fa1
commit
2c2cffcc84
2 files changed
+14
-1
No files matched your search
@@ -72,6 +72,10 @@ const ProfilePanel = () => {
|
|||||||
);
|
);
|
||||||
if (error) return;
|
if (error) return;
|
||||||
|
|
||||||
|
setLocalData((prev) => ({
|
||||||
|
...prev,
|
||||||
|
deleteProfileImage: false,
|
||||||
|
}));
|
||||||
setProgress((prev) => ({ ...prev, isLoading: true }));
|
setProgress((prev) => ({ ...prev, isLoading: true }));
|
||||||
setFile({
|
setFile({
|
||||||
src: URL.createObjectURL(pic),
|
src: URL.createObjectURL(pic),
|
||||||
@@ -116,13 +120,17 @@ const ProfilePanel = () => {
|
|||||||
// Resets picture-related states and clears interval
|
// Resets picture-related states and clears interval
|
||||||
const removePicture = () => {
|
const removePicture = () => {
|
||||||
errors["picture"] && clearError("picture");
|
errors["picture"] && clearError("picture");
|
||||||
|
setLocalData((prev) => ({
|
||||||
|
...prev,
|
||||||
|
deleteProfileImage: true,
|
||||||
|
}));
|
||||||
clearInterval(intervalRef.current); // interrupt interval if image upload is canceled prior to completing the process
|
clearInterval(intervalRef.current); // interrupt interval if image upload is canceled prior to completing the process
|
||||||
setProgress({ value: 0, isLoading: false });
|
setProgress({ value: 0, isLoading: false });
|
||||||
};
|
};
|
||||||
|
|
||||||
// Closes the picture update modal and resets related states
|
// Closes the picture update modal and resets related states
|
||||||
const closePictureModal = () => {
|
const closePictureModal = () => {
|
||||||
removePicture();
|
// removePicture();
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -154,6 +162,10 @@ const ProfilePanel = () => {
|
|||||||
// Removes current profile image from UI
|
// Removes current profile image from UI
|
||||||
const handleDeletePicture = () => {
|
const handleDeletePicture = () => {
|
||||||
// TODO - implement delete picture function
|
// TODO - implement delete picture function
|
||||||
|
setLocalData((prev) => ({
|
||||||
|
...prev,
|
||||||
|
deleteProfileImage: true,
|
||||||
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initiates the account deletion process
|
// Initiates the account deletion process
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export const update = createAsyncThunk(
|
|||||||
fd.append("firstname", form.firstname);
|
fd.append("firstname", form.firstname);
|
||||||
fd.append("lastname", form.lastname);
|
fd.append("lastname", form.lastname);
|
||||||
fd.append("profileImage", imageResult.data);
|
fd.append("profileImage", imageResult.data);
|
||||||
|
fd.append("deleteProfileImage", form.deleteProfileImage);
|
||||||
|
|
||||||
const res = await axios.post(`${BASE_URL}/auth/user/${user._id}`, fd, {
|
const res = await axios.post(`${BASE_URL}/auth/user/${user._id}`, fd, {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in new issue
Block a user