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

export const contactUsApi = createApi({
  reducerPath: "contactUsApi",
  baseQuery: baseQueryWithReauth,
  tagTypes: ["LeadCategories", "Leads"],
  endpoints: (builder) => ({

    // GET Lead Categories
    getLeadCategories: builder.query({
      query: ({ limit = 10, offset = 0, status = "active" }) => ({
        url: "admin/prepopulate/lead-categories/list",
        params: {
          limit,
          offset,
          status,
        },
      }),
      providesTags: ["LeadCategories"],
    }),

    // CREATE Lead
    createLead: builder.mutation({
      query: (body) => ({
        url: "admin/leads/create",
        method: "POST",
        body,
      }),
      invalidatesTags: ["Leads"],
    }),

  }),
});

export const {
  useGetLeadCategoriesQuery,
  useCreateLeadMutation,
} = contactUsApi;