Initial commit
Build / run (push) Has been cancelled

This commit is contained in:
maher
2026-05-14 13:42:10 +02:00
commit 511fad8199
4595 changed files with 385164 additions and 0 deletions
@@ -0,0 +1,37 @@
import {useMutation} from '@tanstack/react-query';
import {apiClient} from '../../../http/query-client';
import {BackendResponse} from '../../../http/backend-response/backend-response';
import {toast} from '../../../ui/toast/toast';
import {message} from '../../../i18n/message';
import {Role} from '../../../auth/role';
import {showHttpErrorToast} from '../../../utils/http/show-http-error-toast';
interface Response extends BackendResponse {}
interface Payload {
userIds: number[];
}
export function useRemoveUsersFromRole(role: Role) {
return useMutation({
mutationFn: ({userIds}: Payload) =>
removeUsersFromRole({userIds, roleId: role.id}),
onSuccess: (response, payload) => {
toast(
message('Removed [one 1 user|other :count users] from “{role}“', {
values: {count: payload.userIds.length, role: role.name},
}),
);
},
onError: err => showHttpErrorToast(err),
});
}
function removeUsersFromRole({
roleId,
userIds,
}: Payload & {roleId: number}): Promise<Response> {
return apiClient
.post(`roles/${roleId}/remove-users`, {userIds})
.then(r => r.data);
}