Initial commit - Horux Despachos NL
This commit is contained in:
37
apps/web/lib/api/platform-staff.ts
Normal file
37
apps/web/lib/api/platform-staff.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
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 });
|
||||
}
|
||||
Reference in New Issue
Block a user