/
afanasevn
/
MaxSystems
Обзор
Документация
Войти
/
afanasevn
/
MaxSystems
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
client/src/api/admin.ts
62 строки
1 KB
IBS\NAfanasev
Add project files.
18 июн 2026, 01:12
18 июн 2026, 01:12
b06aa39
Код
Авторство
О чём код?
import { apiDelete, apiGet, apiPost, apiPut } from './http' export type UserRole = | 'Manager' | 'LeadSpecialist' | 'Specialist' | 'Warehouse' | 'Dispatcher' | 'Contractor' | 'Admin' export type UserListItem = { id: string email: string name: string role: UserRole active: boolean leadWorksCount: number assignedWorksCount: number } export type RoleInfo = { role: UserRole title: string description: string } export type CreateUserPayload = { email: string name: string role: UserRole password: string active: boolean } export type UpdateUserPayload = { email: string name: string role: UserRole active: boolean password?: string } export async function fetchUsers(): Promise<UserListItem[]> { return apiGet<UserListItem[]>('/api/admin/users') } export async function fetchRoles(): Promise<RoleInfo[]> { return apiGet<RoleInfo[]>('/api/admin/roles') } export async function createUser(payload: CreateUserPayload): Promise<UserListItem> { return apiPost<UserListItem>('/api/admin/users', payload) } export async function updateUser(id: string, payload: UpdateUserPayload): Promise<UserListItem> { return apiPut<UserListItem>(`/api/admin/users/${id}`, payload) } export async function deleteUser(id: string): Promise<void> { return apiDelete(`/api/admin/users/${id}`) }