import { request } from '@umijs/max';
import type {
  CommentItem,
  CommentListParams,
  CommentListResponse,
  CommentStatusUpdatePayload,
} from '@/pages/CommentManagement/data';

export async function queryCommentList(params?: CommentListParams) {
  return request<CommentListResponse>('/api/comments', {
    method: 'GET',
    params,
  });
}

export async function getCommentDetail(id: string) {
  return request<{ success: boolean; data: CommentItem }>(`/api/comments/${id}`, {
    method: 'GET',
  });
}

export async function updateCommentStatus(
  id: string,
  payload: CommentStatusUpdatePayload,
) {
  return request<{ success: boolean }>(`/api/comments/${id}/status`, {
    method: 'PUT',
    data: payload,
  });
}

export async function deleteComment(id: string) {
  return request<{ success: boolean }>(`/api/comments/${id}`, {
    method: 'DELETE',
  });
}
