import { api } from './client'

export async function fetchFeedbacks(status = '') {
  const { data } = await api.get('/feedbacks', { params: status ? { status } : {} })
  return data
}

export async function fetchFeedbackStats() {
  const { data } = await api.get('/feedbacks', { params: { limit: 1, offset: 0 } })
  return data?.stats
}

export async function replyFeedback(feedbackId, reply) {
  const { data } = await api.post(`/feedbacks/${feedbackId}/reply`, { reply })
  return data
}

export async function closeFeedback(feedbackId) {
  const { data } = await api.post(`/feedbacks/${feedbackId}/close`)
  return data
}

export async function deleteFeedback(feedbackId) {
  const { data } = await api.delete(`/feedbacks/${feedbackId}`)
  return data
}
