import { Model, UUID } from '@/api/admin/index'; import { Server } from '@/api/admin/server'; import http, { QueryBuilderParams, withQueryBuilderParams } from '@/api/http'; import { AdminTransformers } from '@/api/admin/transformers'; export interface User extends Model { id: number; uuid: UUID; externalId: string; username: string; email: string; language: string; adminRoleId: number | null; roleName: string; isRootAdmin: boolean; isUsingTwoFactor: boolean; avatarUrl: string; createdAt: Date; updatedAt: Date; relationships: { role: UserRole | null; servers?: Server[]; }; } export interface UserRole extends Model { id: string; name: string; description: string; } export const getUser = async (id: string | number): Promise => { const { data } = await http.get(`/api/application/users/${id}`); return AdminTransformers.toUser(data.data); }; export const searchUserAccounts = async (params: QueryBuilderParams<'username' | 'email'>): Promise => { const { data } = await http.get('/api/application/users', { params: withQueryBuilderParams(params), }); return data.data.map(AdminTransformers.toUser); };