File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
apps/web/app/(org)/dashboard/settings/account Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,17 @@ export const Settings = ({
1818
1919 const { mutate : updateName , isPending : updateNamePending } = useMutation ( {
2020 mutationFn : async ( ) => {
21- await fetch ( "/api/settings/user/name" , {
21+ const res = await fetch ( "/api/settings/user/name" , {
2222 method : "POST" ,
23- headers : {
24- "Content-Type" : "application/json" ,
25- } ,
26- body : JSON . stringify ( { firstName, lastName } ) ,
23+ headers : { "Content-Type" : "application/json" } ,
24+ body : JSON . stringify ( {
25+ firstName : firstName . trim ( ) ,
26+ lastName : lastName . trim ( ) ? lastName . trim ( ) : null ,
27+ } ) ,
2728 } ) ;
29+ if ( ! res . ok ) {
30+ throw new Error ( "Failed to update name" ) ;
31+ }
2832 } ,
2933 onSuccess : ( ) => {
3034 toast . success ( "Name updated successfully" ) ;
You can’t perform that action at this time.
0 commit comments