import api from "../axios";
import { API_ENDPOINTS } from "../endpoints";
import { ApiResponse } from "../types";
import { TFeedbackResponse } from "../types/Feedback";

export const feedbackService = {
  getFeedbacks: async (
    params: Record<string, any>,
  ): Promise<TFeedbackResponse> => {
    try {
      return (await api.get(API_ENDPOINTS.FEEDBACK.READ_ALL, { params })).data;
    } catch (error) {
      console.error("ERROR Caught in feedback service => getFeedbacks", error);
      throw error;
    }
  },
  getSingleFeedback: async (
    id: string,
  ): Promise<ApiResponse<TFeedbackResponse>> => {
    try {
      return (await api.get(API_ENDPOINTS.FEEDBACK.DETAILS(id))).data;
    } catch (error) {
      console.error(
        "ERROR Caught in feedback service => getSingleFeedback",
        error,
      );
      throw error;
    }
  },
};
