64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
// 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: ({ page, size, search }) => {
|
|
let baseURL = `/account/admin/history?search=${search || ""}`;
|
|
if (page !== undefined && size !== undefined) {
|
|
baseURL += `&page=${page}&size=${size}`; // Only add pagination if both are defined
|
|
}
|
|
return baseURL;
|
|
},
|
|
providesTags: ["getDrawalRequest"],
|
|
}),
|
|
}),
|
|
});
|
|
|
|
// Export hooks for usage in functional components
|
|
export const {
|
|
useGetDeleteRequestQuery,
|
|
useGetDeleteRequestByIdQuery,
|
|
useApproveDepositRequestMutation,
|
|
useGetDeleteHistoryQuery
|
|
|
|
} = deleteRequest;
|