mirror of
https://github.com/docmost/docmost.git
synced 2026-06-11 02:36:56 +08:00
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import api from "@/lib/api-client";
|
|
import {
|
|
ICommentParams,
|
|
IComment,
|
|
IResolveComment,
|
|
} from "@/features/comment/types/comment.types";
|
|
import { IPagination } from "@/lib/types.ts";
|
|
|
|
export async function createComment(
|
|
data: Partial<IComment>,
|
|
): Promise<IComment> {
|
|
const req = await api.post<IComment>("/comments/create", data);
|
|
return req.data;
|
|
}
|
|
|
|
export async function resolveComment(data: IResolveComment): Promise<IComment> {
|
|
const req = await api.post<IComment>(`/comments/resolve`, data);
|
|
return req.data;
|
|
}
|
|
|
|
export async function updateComment(
|
|
data: Partial<IComment>,
|
|
): Promise<IComment> {
|
|
const req = await api.post<IComment>(`/comments/update`, data);
|
|
return req.data;
|
|
}
|
|
|
|
export async function getCommentById(commentId: string): Promise<IComment> {
|
|
const req = await api.post<IComment>("/comments/info", { commentId });
|
|
return req.data;
|
|
}
|
|
|
|
export async function getPageComments(
|
|
data: ICommentParams,
|
|
): Promise<IPagination<IComment>> {
|
|
const req = await api.post("/comments", data);
|
|
return req.data;
|
|
}
|
|
|
|
export async function deleteComment(commentId: string): Promise<void> {
|
|
await api.post("/comments/delete", { commentId });
|
|
}
|
|
|
|
export type CreateReadOnlyCommentData = {
|
|
pageId: string;
|
|
content: string;
|
|
selection?: string;
|
|
yjsSelection: {
|
|
anchor: any;
|
|
head: any;
|
|
};
|
|
};
|
|
|
|
export async function createReadOnlyComment(
|
|
data: CreateReadOnlyCommentData,
|
|
): Promise<IComment> {
|
|
const req = await api.post<IComment>("/comments/create-readonly", data);
|
|
return req.data;
|
|
}
|