refactor(client): use generated API client and hooks
Signed-off-by: Noa Virellia <noa@requiem.garden>
This commit is contained in:
@@ -1,22 +1,12 @@
|
||||
import { getUserInfoQueryKey, patchUserUpdateMutation } from '@/client/@tanstack/react-query.gen';
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { axiosClient } from '@/lib/axios';
|
||||
|
||||
interface UpdateUserPayload {
|
||||
avatar?: string;
|
||||
bio?: string;
|
||||
nickname?: string;
|
||||
subtitle?: string;
|
||||
username?: string;
|
||||
}
|
||||
|
||||
export function useUpdateUser() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (payload: UpdateUserPayload) => {
|
||||
return axiosClient.patch<{ status: string }>('/user/update', payload);
|
||||
},
|
||||
...patchUserUpdateMutation(),
|
||||
onSuccess: async () => {
|
||||
await queryClient.invalidateQueries({ queryKey: ['userInfo'] });
|
||||
await queryClient.invalidateQueries({ queryKey: getUserInfoQueryKey() });
|
||||
},
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user