Skip to content

Commit

Permalink
fix: delete profile picture from localstorage only on successful api …
Browse files Browse the repository at this point in the history
…call
  • Loading branch information
SebassNoob committed Apr 24, 2024
1 parent 56e11b3 commit b82ebc8
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ const ChangeProfilePicture = () => {
const handleUpdate = (imageURL: string, file: File | null) => {
if (file === null) {
apiClient.delete('/user/profile_picture').then((response) => {
updateUser({ ...user, profile_picture: null });

if (response.status !== 204) {
notifications.show({
title: 'Failed to delete profile picture',
message: 'Please try again later.',
color: 'red',
});
} else {
updateUser({ ...user, profile_picture: null });
notifications.show({
title: 'Profile picture deleted',
message: 'Your profile picture has been deleted.',
Expand Down

0 comments on commit b82ebc8

Please sign in to comment.