You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1008 B
34 lines
1008 B
import { Routes } from "../routes/Routes";
|
|
import { createApiHeaders } from "./util";
|
|
import { AdminUserDTO } from "../dto/AdminUserDTO";
|
|
import { ActiveUserViewModel } from "../../chat/viewmodel/ActiveUserViewModel";
|
|
import { JsonAPI } from "../../chat/singleton/JsonAPI";
|
|
|
|
export async function getOtherUsers(
|
|
authToken: string
|
|
): Promise<AdminUserDTO[]> {
|
|
const response = await fetch(Routes.Admin.getOtherUsers, {
|
|
method: "GET",
|
|
headers: createApiHeaders(authToken),
|
|
});
|
|
|
|
let data = (await response.json()) as AdminUserDTO[];
|
|
return data;
|
|
}
|
|
|
|
export async function getActiveUsers(
|
|
authToken: string
|
|
): Promise<ActiveUserViewModel[]> {
|
|
const response = await fetch(JsonAPI.ACTIVE_USERS_GET, {
|
|
method: "GET",
|
|
headers: createApiHeaders(authToken),
|
|
});
|
|
const data = await response.json();
|
|
const data2 = data.map((d: any) => {
|
|
if (d.lastActive == null) return d;
|
|
|
|
d.lastActive = new Date(d.lastActive);
|
|
return d;
|
|
}) as ActiveUserViewModel[];
|
|
return data2;
|
|
}
|