30 lines
984 B
TypeScript
30 lines
984 B
TypeScript
import axios from 'axios';
|
|
import { API_URL_USER } from '@/shared/api/api-url-user';
|
|
import { resultify } from '@/shared/lib/resultify';
|
|
import { NiceAxiosError } from '@/shared/@types/error';
|
|
import {
|
|
UserUpdatePermissionsParams,
|
|
UserUpdatePermissionsResponse
|
|
} from '../model/types';
|
|
import {
|
|
useMutation,
|
|
UseMutationOptions
|
|
} from '@tanstack/react-query';
|
|
|
|
export const userUpdatePermissions = (params: UserUpdatePermissionsParams) => {
|
|
return resultify(
|
|
axios.post<UserUpdatePermissionsResponse>(API_URL_USER.updatePermissions(), params),
|
|
);
|
|
};
|
|
|
|
export const useUserUpdatePermissionsMutation = (options?: UseMutationOptions<UserUpdatePermissionsResponse, NiceAxiosError, UserUpdatePermissionsParams>) => {
|
|
const mutation = useMutation<UserUpdatePermissionsResponse, NiceAxiosError, UserUpdatePermissionsParams>({
|
|
...options,
|
|
mutationFn: (params: UserUpdatePermissionsParams) => userUpdatePermissions(params),
|
|
});
|
|
|
|
return {
|
|
...mutation,
|
|
};
|
|
};
|