feat: refactor update-current-user mutation with the REST API endpoint
This commit is contained in:
19
packages/web/src/hooks/useUpdateCurrentUser.js
Normal file
19
packages/web/src/hooks/useUpdateCurrentUser.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useUpdateCurrentUser(userId) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const query = useMutation({
|
||||
mutationFn: async (payload) => {
|
||||
const { data } = await api.patch(`/v1/users/${userId}`, payload);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['users', 'me'] });
|
||||
},
|
||||
});
|
||||
|
||||
return query;
|
||||
}
|
14
packages/web/src/hooks/useUpdateCurrentUserPassword.js
Normal file
14
packages/web/src/hooks/useUpdateCurrentUserPassword.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import api from 'helpers/api';
|
||||
|
||||
export default function useUpdateCurrentUserPassword(userId) {
|
||||
const query = useMutation({
|
||||
mutationFn: async (payload) => {
|
||||
const { data } = await api.patch(`/v1/users/${userId}/password`, payload);
|
||||
|
||||
return data;
|
||||
},
|
||||
});
|
||||
|
||||
return query;
|
||||
}
|
Reference in New Issue
Block a user