Added frontend api for Admin Panel
This commit is contained in:
parent
f8ccebc5ad
commit
1884a232f4
55
frontend/src/api/admin.ts
Normal file
55
frontend/src/api/admin.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import { Requests, Responses, UserRole } from 'dto';
|
||||
import { get_token, post_token } from './base';
|
||||
|
||||
export const get_users = (token: string): Promise<Responses.Admin.GetUsers> =>
|
||||
get_token('/api/admin/users', token);
|
||||
|
||||
export const set_role = (
|
||||
user: number,
|
||||
role: UserRole,
|
||||
token: string
|
||||
): Promise<Responses.Admin.SetUserRole> =>
|
||||
post_token<Requests.Admin.SetUserRole>(
|
||||
'/api/admin/set_role',
|
||||
{
|
||||
user,
|
||||
role
|
||||
},
|
||||
token
|
||||
);
|
||||
|
||||
export const logout = (
|
||||
user: number,
|
||||
token: string
|
||||
): Promise<Responses.Admin.LogoutAllUser> =>
|
||||
post_token<Requests.Admin.LogoutAll>(
|
||||
'/api/admin/logout',
|
||||
{
|
||||
user
|
||||
},
|
||||
token
|
||||
);
|
||||
|
||||
export const delete_user = (
|
||||
user: number,
|
||||
token: string
|
||||
): Promise<Responses.Admin.DeleteUser> =>
|
||||
post_token<Requests.Admin.DeleteUser>(
|
||||
'/api/admin/delete',
|
||||
{
|
||||
user
|
||||
},
|
||||
token
|
||||
);
|
||||
|
||||
export const disable_tfa = (
|
||||
user: number,
|
||||
token: string
|
||||
): Promise<Responses.Admin.DisableTfa> =>
|
||||
post_token<Requests.Admin.DisableTfa>(
|
||||
'/api/admin/disable_2fa',
|
||||
{
|
||||
user
|
||||
},
|
||||
token
|
||||
);
|
@ -4,4 +4,5 @@ export { isErrorResponse } from './base';
|
||||
export * as Auth from './auth';
|
||||
export * as FS from './fs';
|
||||
export * as User from './user';
|
||||
export * as Admin from './admin';
|
||||
export * from './util';
|
||||
|
Loading…
Reference in New Issue
Block a user