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>
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { apiClient } from './client';
|
|
import type { UserListItem, UserInvite, UserUpdate } from '@horux/shared';
|
|
|
|
export async function getUsuarios(): Promise<UserListItem[]> {
|
|
const response = await apiClient.get<UserListItem[]>('/usuarios');
|
|
return response.data;
|
|
}
|
|
|
|
export async function inviteUsuario(data: UserInvite): Promise<UserListItem> {
|
|
const response = await apiClient.post<UserListItem>('/usuarios/invite', data);
|
|
return response.data;
|
|
}
|
|
|
|
export async function updateUsuario(id: string, data: UserUpdate): Promise<UserListItem> {
|
|
const response = await apiClient.patch<UserListItem>(`/usuarios/${id}`, data);
|
|
return response.data;
|
|
}
|
|
|
|
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}`);
|
|
}
|