// investorDetails.service.js
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
// import { api } from "./api.service";
import { baseQuery } from "./token.serivce";

// const baseUrl = api?.defaults.baseURL;

// Define a service using a base URL and expected endpoints
export const banInvestorDetails = createApi({
  reducerPath: "banInvestorDetails",
  baseQuery: baseQuery,
  tagTypes: ["getBanInvestor", "getUnbanInvestor"],
  endpoints: (builder) => ({
    getInvestor: builder.query({
      query: () => `/investorDetails/admin`,
      providesTags: ["getBanInvestor"],
    }),

    getUnbanInvestor: builder.query({
      query: () => `/investorDetails/admin/getAllUnbanned`,
      providesTags: ["getBanInvestor"],
    }),

    getbanInvestor: builder.query({
      query: () => `/investorDetails/admin/getAllBanned`,
      providesTags: ["getBanInvestor"],
    }),

    updateUnban: builder.mutation({
      query: ({ id, data }) => ({
        url: `/investorDetails/admin/unBanById/${id}`,
        method: "PATCH",
        body: data,
      }),
      invalidatesTags: ["getBanInvestor"],
    }),

  }),
});

// Export hooks for usage in functional components
export const {
  useGetUnbanInvestorQuery,
  useGetInvestorQuery,
  useGetbanInvestorQuery,
  useUpdateUnbanMutation,
} = banInvestorDetails;
