web: make sure naming matches backend

This commit is contained in:
Jens Langhammer
2020-12-16 23:02:43 +01:00
parent 2d9efe035e
commit 3b7bba5a62
35 changed files with 64 additions and 62 deletions

31
web/src/api/Users.ts Normal file
View File

@ -0,0 +1,31 @@
import { DefaultClient, PBResponse } from "./Client";
let _globalMePromise: Promise<User>;
export class User {
pk: number;
username: string;
name: string;
is_superuser: boolean;
email: boolean;
avatar: string;
constructor() {
throw Error();
}
static me(): Promise<User> {
if (!_globalMePromise) {
_globalMePromise = DefaultClient.fetch<User>(["core", "users", "me"]);
}
return _globalMePromise;
}
static count(): Promise<number> {
return DefaultClient.fetch<PBResponse<User>>(["core", "users"], {
"page_size": 1
}).then(r => {
return r.pagination.count;
});
}
}