Files
docmost-ryan/client/src/features/comment/services/comment-service.ts
Philipinho 4cb7a56f65 feat: comments
* create comment
* reply to comment thread
* edit comment
* delete comment
* resolve comment
2023-11-09 16:52:34 +00:00

32 lines
1.1 KiB
TypeScript

import api from '@/lib/api-client';
import { IComment, IResolveComment } from '@/features/comment/types/comment.types';
export async function createComment(data: Partial<IComment>): Promise<IComment> {
const req = await api.post<IComment>('/comments/create', data);
return req.data as IComment;
}
export async function resolveComment(data: IResolveComment): Promise<IComment> {
const req = await api.post<IComment>(`/comments/resolve`, data);
return req.data as IComment;
}
export async function updateComment(data: Partial<IComment>): Promise<IComment> {
const req = await api.post<IComment>(`/comments/update`, data);
return req.data as IComment;
}
export async function getCommentById(id: string): Promise<IComment> {
const req = await api.post<IComment>('/comments/view', { id });
return req.data as IComment;
}
export async function getPageComments(pageId: string): Promise<IComment[]> {
const req = await api.post<IComment[]>('/comments', { pageId });
return req.data as IComment[];
}
export async function deleteComment(id: string): Promise<void> {
await api.post('/comments/delete', { id });
}