38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { apiClient } from './client';
|
|
import type { PlatformRole } from '@horux/shared';
|
|
|
|
export interface PlatformStaffUser {
|
|
id: string;
|
|
email: string;
|
|
nombre: string;
|
|
active: boolean;
|
|
tenant: { id: string; nombre: string; rfc: string } | null;
|
|
roles: PlatformRole[];
|
|
}
|
|
|
|
export interface CandidateUser {
|
|
id: string;
|
|
email: string;
|
|
nombre: string;
|
|
active: boolean;
|
|
tenant: { id: string; nombre: string; rfc: string } | null;
|
|
}
|
|
|
|
export async function listStaff(): Promise<PlatformStaffUser[]> {
|
|
const response = await apiClient.get<PlatformStaffUser[]>('/platform-staff');
|
|
return response.data;
|
|
}
|
|
|
|
export async function searchUsers(q: string): Promise<CandidateUser[]> {
|
|
const response = await apiClient.get<CandidateUser[]>('/platform-staff/search', { params: { q } });
|
|
return response.data;
|
|
}
|
|
|
|
export async function grantRole(userId: string, role: PlatformRole): Promise<void> {
|
|
await apiClient.post('/platform-staff/grant', { userId, role });
|
|
}
|
|
|
|
export async function revokeRole(userId: string, role: PlatformRole): Promise<void> {
|
|
await apiClient.post('/platform-staff/revoke', { userId, role });
|
|
}
|