import type { Comment, PaginationResponse } from '~/types/models' export function useComments() { const { get, post, put, delete: deleteRequest } = useApi() const fetchComments = async (articleId: number, status = 'approved'): Promise => { const response = await get>( `/articles/${articleId}/comments?status=${status}`, ) return response.items } const createComment = async ( articleId: number, content: string, parentId?: number, ): Promise => { return await post(`/articles/${articleId}/comments`, { content, parentId, }) } const updateCommentStatus = async ( commentId: number, status: 'approved' | 'rejected', ): Promise => { return await put(`/admin/comments/${commentId}/status`, { status }) } const deleteComment = async (commentId: number): Promise => { await deleteRequest(`/admin/comments/${commentId}`) } return { fetchComments, createComment, updateCommentStatus, deleteComment, } }