2021-08-07 00:28:12 +00:00
|
|
|
import { requests } from "../requests";
|
2021-08-07 23:12:25 +00:00
|
|
|
import { BaseCRUDAPI } from "./_base";
|
2021-08-07 00:28:12 +00:00
|
|
|
import { GroupInDB } from "~/types/api-types/user";
|
|
|
|
|
|
|
|
const prefix = "/api";
|
|
|
|
|
|
|
|
const routes = {
|
|
|
|
groups: `${prefix}/groups`,
|
|
|
|
groupsSelf: `${prefix}/groups/self`,
|
|
|
|
|
|
|
|
groupsId: (id: string | number) => `${prefix}/groups/${id}`,
|
|
|
|
};
|
|
|
|
|
|
|
|
export interface CreateGroup {
|
|
|
|
name: string;
|
|
|
|
}
|
|
|
|
|
2021-08-07 23:12:25 +00:00
|
|
|
export class GroupAPI extends BaseCRUDAPI<GroupInDB, CreateGroup> {
|
2021-08-07 00:28:12 +00:00
|
|
|
baseRoute = routes.groups;
|
|
|
|
itemRoute = routes.groupsId;
|
|
|
|
/** Returns the Group Data for the Current User
|
|
|
|
*/
|
|
|
|
async getCurrentUserGroup() {
|
|
|
|
return await requests.get(routes.groupsSelf);
|
|
|
|
}
|
|
|
|
}
|