nicolium: move some stuff away from actions

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2026-03-15 11:04:40 +01:00
parent d937e7c22f
commit a166bb5cf7
7 changed files with 44 additions and 41 deletions

View File

@@ -266,6 +266,28 @@ const useAdminUpdateTagsMutation = (accountId: string) => {
});
};
const useAdminSetRoleMutation = (accountId: string) => {
const client = useClient();
const queryClient = useQueryClient();
return useMutation({
mutationKey: ['admin', 'acounts', accountId, 'setRole'],
mutationFn: (role: 'user' | 'moderator' | 'admin') => {
switch (role) {
case 'user':
return client.admin.accounts.demoteToUser(accountId);
case 'moderator':
return client.admin.accounts.promoteToModerator(accountId);
case 'admin':
return client.admin.accounts.promoteToAdmin(accountId);
}
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: queryKeys.accounts.show(accountId) });
},
});
};
export {
useAdminAccount,
useAdminAccounts,
@@ -281,4 +303,5 @@ export {
useAdminTagUserMutation,
useAdminUntagUserMutation,
useAdminUpdateTagsMutation,
useAdminSetRoleMutation,
};