aboutsummaryrefslogtreecommitdiff
path: root/jb-ui/src/models/cashoutRequests.ts
diff options
context:
space:
mode:
Diffstat (limited to 'jb-ui/src/models/cashoutRequests.ts')
-rw-r--r--jb-ui/src/models/cashoutRequests.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/jb-ui/src/models/cashoutRequests.ts b/jb-ui/src/models/cashoutRequests.ts
new file mode 100644
index 0000000..985b949
--- /dev/null
+++ b/jb-ui/src/models/cashoutRequests.ts
@@ -0,0 +1,32 @@
+import { createApi, fakeBaseQuery } from "@reduxjs/toolkit/query/react";
+import { WalletApi } from "@/api_fsb";
+import type { CashoutRequestSummary } from "@/api_fsb";
+
+const walletApi = new WalletApi();
+
+// /<product-id>/cashout/
+
+export const cashoutRequests = createApi({
+ reducerPath: "cashoutRequests",
+ baseQuery: fakeBaseQuery<string>(),
+ endpoints: (builder) => ({
+ getUserCashouts: builder.query<
+ CashoutRequestSummary[],
+ { bpid: string; productUserId: string }
+ >({
+ queryFn: async ({ bpid, productUserId }) => {
+ try {
+ const res = await walletApi.filterUserCashoutsProductIdCashoutGet(
+ bpid,
+ productUserId,
+ );
+ return { data: res.data.cashouts as CashoutRequestSummary[] };
+ } catch (e) {
+ return { error: e instanceof Error ? e.message : "Request failed" };
+ }
+ },
+ }),
+ }),
+});
+
+export const { useGetUserCashoutsQuery } = cashoutRequests;