mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-30 11:46:36 +08:00
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import { api } from './client'
|
|
import type { AccessLog, Setting, User } from '../types'
|
|
|
|
export const adminAPI = {
|
|
listUsers: () => api.get<User[]>('/admin/users').then((r) => r.data),
|
|
|
|
createUser: (payload: { username: string; password: string }) =>
|
|
api.post<User>('/admin/users', payload).then((r) => r.data),
|
|
|
|
updateUser: (id: string, payload: { username: string }) =>
|
|
api.patch<User>(`/admin/users/${id}`, payload).then((r) => r.data),
|
|
|
|
resetUserPassword: (id: string, password: string) =>
|
|
api.patch(`/admin/users/${id}/password`, { password }).then((r) => r.data),
|
|
|
|
setUserStatus: (id: string, isActive: boolean) =>
|
|
api.patch<User>(`/admin/users/${id}/status`, { is_active: isActive }).then((r) => r.data),
|
|
|
|
deleteUser: (id: string) => api.delete(`/admin/users/${id}`).then((r) => r.data),
|
|
|
|
listSettings: () => api.get<Setting[]>('/admin/settings').then((r) => r.data),
|
|
|
|
updateSetting: (key: string, value: string) =>
|
|
api.put('/admin/settings', { key, value }).then((r) => r.data),
|
|
|
|
recentLogs: () => api.get<AccessLog[]>('/admin/logs').then((r) => r.data),
|
|
}
|