Files
gitmost/apps/client/src/features/comment/services/comment-service.ts
Philipinho b91c3ede1e fixes
* fix comments
* fix page history
* fix aside width on smaller screens
2024-04-23 22:07:00 +01:00

42 lines
1.2 KiB
TypeScript

import api from "@/lib/api-client";
import {
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 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(commentId: string): Promise<IComment> {
const req = await api.post<IComment>("/comments/info", { commentId });
return req.data as IComment;
}
export async function getPageComments(
pageId: string,
): Promise<IPagination<IComment>> {
const req = await api.post("/comments", { pageId });
return req.data;
}
export async function deleteComment(commentId: string): Promise<void> {
await api.post("/comments/delete", { commentId });
}