mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-17 02:01:03 +10:00
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import api from "@/lib/api-client";
|
|
import { IGroup } from "@/features/group/types/group.types";
|
|
|
|
export async function getGroups(): Promise<any> {
|
|
// TODO: returns paginated. Fix type
|
|
const req = await api.post<any>("/groups");
|
|
return req.data;
|
|
}
|
|
|
|
export async function getGroupById(groupId: string): Promise<IGroup> {
|
|
const req = await api.post<IGroup>("/groups/info", { groupId });
|
|
return req.data as IGroup;
|
|
}
|
|
|
|
export async function getGroupMembers(groupId: string) {
|
|
const req = await api.post("/groups/members", { groupId });
|
|
return req.data;
|
|
}
|
|
|
|
export async function createGroup(data: Partial<IGroup>): Promise<IGroup> {
|
|
const req = await api.post<IGroup>("/groups/create", data);
|
|
return req.data;
|
|
}
|
|
|
|
export async function updateGroup(data: Partial<IGroup>): Promise<IGroup> {
|
|
const req = await api.post<IGroup>("/groups/update", data);
|
|
return req.data;
|
|
}
|
|
|
|
export async function deleteGroup(data: { groupId: string }): Promise<void> {
|
|
await api.post("/groups/delete", data);
|
|
}
|
|
|
|
export async function addGroupMember(data: {
|
|
groupId: string;
|
|
userIds: string[];
|
|
}): Promise<void> {
|
|
await api.post<IGroup>("/groups/members/add", data);
|
|
}
|
|
|
|
export async function removeGroupMember(data: {
|
|
groupId: string;
|
|
userId: string;
|
|
}): Promise<void> {
|
|
await api.post<IGroup>("/groups/members/remove", data);
|
|
}
|