@@ -89,10 +89,7 @@ export const Settings = ({
8989 return ( ) => window . removeEventListener ( "beforeunload" , handleBeforeUnload ) ;
9090 } , [ hasChanges ] ) ;
9191
92- const {
93- mutate : uploadProfileImageMutation ,
94- isPending : isUploadingProfileImage ,
95- } = useMutation ( {
92+ const uploadProfileImageMutation = useMutation ( {
9693 mutationFn : async ( file : File ) => {
9794 const formData = new FormData ( ) ;
9895 formData . append ( "image" , file ) ;
@@ -116,10 +113,7 @@ export const Settings = ({
116113 } ,
117114 } ) ;
118115
119- const {
120- mutate : removeProfileImageMutation ,
121- isPending : isRemovingProfileImage ,
122- } = useMutation ( {
116+ const removeProfileImageMutation = useMutation ( {
123117 mutationFn : removeProfileImage ,
124118 onSuccess : ( result ) => {
125119 if ( result . success ) {
@@ -140,21 +134,22 @@ export const Settings = ({
140134 } ) ;
141135
142136 const isProfileImageMutating =
143- isUploadingProfileImage || isRemovingProfileImage ;
137+ uploadProfileImageMutation . isPending ||
138+ removeProfileImageMutation . isPending ;
144139
145140 const handleProfileImageChange = ( file : File | null ) => {
146141 if ( ! file || isProfileImageMutating ) {
147142 return ;
148143 }
149- uploadProfileImageMutation ( file ) ;
144+ uploadProfileImageMutation . mutate ( file ) ;
150145 } ;
151146
152147 const handleProfileImageRemove = ( ) => {
153148 if ( isProfileImageMutating ) {
154149 return ;
155150 }
156151 setProfileImageOverride ( null ) ;
157- removeProfileImageMutation ( ) ;
152+ removeProfileImageMutation . mutate ( ) ;
158153 } ;
159154
160155 return (
@@ -177,8 +172,8 @@ export const Settings = ({
177172 onChange = { handleProfileImageChange }
178173 onRemove = { handleProfileImageRemove }
179174 disabled = { isProfileImageMutating }
180- isUploading = { isUploadingProfileImage }
181- isRemoving = { isRemovingProfileImage }
175+ isUploading = { uploadProfileImageMutation . isPending }
176+ isRemoving = { removeProfileImageMutation . isPending }
182177 />
183178 </ Card >
184179 < Card className = "space-y-4" >
0 commit comments