import { createApi } from "@reduxjs/toolkit/query/react";
import baseQueryWithReauth from "./baseQuery";

export const faqApi = createApi({
  reducerPath: "faqApi",
  baseQuery: baseQueryWithReauth,
  tagTypes: ["Faq", "FaqTags"],
  endpoints: (builder) => ({
    
    // GET FAQs LIST
    getFaqs: builder.query({
      query: ({ limit = 10, offset = 0, search_term, content_status, content_category_xid }) => ({
        url: "admin/faq/list",
        params: {
          limit,
          offset,
          search_term,
          content_status,
          content_category_xid,
        },
      }),
      providesTags: ["Faq"],
    }),

    // GET category TAGS LIST
    getFaqCategories: builder.query({
      query: ({ limit = 10, offset = 0, search_query }) => ({
        url: "admin/prepopulate/content-categories/list",
        params: {
          limit,
          offset,
          search_query,
        },
      }),
      providesTags: ["FaqTags"],
    }),

  }),
});

export const {
  useGetFaqsQuery,
  useGetFaqCategoriesQuery,
} = faqApi;