// 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 deleteRequest = createApi({
  reducerPath: "deleteRequest",
  baseQuery: baseQuery,
  tagTypes: ["getDeleteRequest", "getDeleteHistory"],
  endpoints: (builder) => ({


    getDeleteRequest: builder.query({
      query: () => `/account/admin/pending-request`,
      providesTags: ["getDepositRequest"],
    }),

    getDeleteRequestById: builder.query({
      query: (id) => `/account/admin/detail/${id}`,
    }),

    approveDepositRequest: builder.mutation({
      query: ({ id, data }) => ({
        url: `/account/admin/approved-request/${id}`,
        method: "PATCH",
        body: data,
      }),
      invalidatesTags: ["getDeleteRequest", "getDeleteHistory"],
    }),

    deleteReject: builder.mutation({
      query: ({ id, data }) => ({
        url: `/deposit/admin/rejected/${id}`,
        method: "PATCH",
        body: data,
      }),
      invalidatesTags: ["getDeleteRequest", "getDeleteHistory"],
    }),

    getDeleteHistory: builder.query({
      query: () => `/account/admin/history`,
      providesTags: ["getDeleteHistory"],
    }),
  }),
});

// Export hooks for usage in functional components
export const {
  useGetDeleteRequestQuery,
  useGetDeleteRequestByIdQuery,
  useApproveDepositRequestMutation,
  useGetDeleteHistoryQuery

} = deleteRequest;
