feat: add global user administration for admin users
Backend: - Add getAllUsuarios() to get users from all tenants - Add updateUsuarioGlobal() to edit users and change their tenant - Add deleteUsuarioGlobal() for global user deletion - Add global admin check based on tenant RFC - Add new API routes: /usuarios/global/* Frontend: - Add UserListItem.tenantId and tenantName fields - Add /admin/usuarios page with full user management - Support filtering by tenant and search - Inline editing for name, role, and tenant assignment - Group users by company for better organization - Add "Admin Usuarios" menu item for admin navigation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,3 +19,18 @@ export async function updateUsuario(id: string, data: UserUpdate): Promise<UserL
|
||||
export async function deleteUsuario(id: string): Promise<void> {
|
||||
await apiClient.delete(`/usuarios/${id}`);
|
||||
}
|
||||
|
||||
// Funciones globales (admin global)
|
||||
export async function getAllUsuarios(): Promise<UserListItem[]> {
|
||||
const response = await apiClient.get<UserListItem[]>('/usuarios/global/all');
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function updateUsuarioGlobal(id: string, data: UserUpdate): Promise<UserListItem> {
|
||||
const response = await apiClient.patch<UserListItem>(`/usuarios/global/${id}`, data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function deleteUsuarioGlobal(id: string): Promise<void> {
|
||||
await apiClient.delete(`/usuarios/global/${id}`);
|
||||
}
|
||||
|
||||
@@ -38,3 +38,31 @@ export function useDeleteUsuario() {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Hooks globales (admin global)
|
||||
export function useAllUsuarios() {
|
||||
return useQuery({
|
||||
queryKey: ['usuarios', 'global'],
|
||||
queryFn: usuariosApi.getAllUsuarios,
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateUsuarioGlobal() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({ id, data }: { id: string; data: UserUpdate }) => usuariosApi.updateUsuarioGlobal(id, data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['usuarios'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteUsuarioGlobal() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (id: string) => usuariosApi.deleteUsuarioGlobal(id),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['usuarios'] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user