aboutsummaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/hooks/backend.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/demobank-ui/src/hooks/backend.ts')
-rw-r--r--packages/demobank-ui/src/hooks/backend.ts23
1 files changed, 22 insertions, 1 deletions
diff --git a/packages/demobank-ui/src/hooks/backend.ts b/packages/demobank-ui/src/hooks/backend.ts
index e87bdd5fe..e0649f5fe 100644
--- a/packages/demobank-ui/src/hooks/backend.ts
+++ b/packages/demobank-ui/src/hooks/backend.ts
@@ -118,6 +118,7 @@ interface useBackendType {
sandboxAccountsFetcher: <T>(
args: [string, number, number, string],
) => Promise<HttpResponseOk<T>>;
+ sandboxCashoutFetcher: <T>(endpoint: string[]) => Promise<HttpResponseOk<T>>;
}
export function usePublicBackend(): useBackendType {
const { state } = useBackendContext();
@@ -176,12 +177,21 @@ export function usePublicBackend(): useBackendType {
},
[baseUrl],
);
+ const sandboxCashoutFetcher = useCallback(
+ function fetcherImpl<T>([endpoint, account]: string[]): Promise<
+ HttpResponseOk<T>
+ > {
+ return requestHandler<T>(baseUrl, endpoint);
+ },
+ [baseUrl],
+ );
return {
request,
fetcher,
paginatedFetcher,
multiFetcher,
sandboxAccountsFetcher,
+ sandboxCashoutFetcher,
};
}
@@ -225,7 +235,6 @@ export function useAuthenticatedBackend(): useBackendType {
function multiFetcherImpl<T>([endpoints]: string[][]): Promise<
HttpResponseOk<T>[]
> {
- console.log("list size", endpoints.length, endpoints);
return Promise.all(
endpoints.map((endpoint) =>
requestHandler<T>(baseUrl, endpoint, { basicAuth: creds }),
@@ -249,12 +258,24 @@ export function useAuthenticatedBackend(): useBackendType {
[baseUrl],
);
+ const sandboxCashoutFetcher = useCallback(
+ function fetcherImpl<T>([endpoint, account]: string[]): Promise<
+ HttpResponseOk<T>
+ > {
+ return requestHandler<T>(baseUrl, endpoint, {
+ basicAuth: creds,
+ params: { account },
+ });
+ },
+ [baseUrl, creds],
+ );
return {
request,
fetcher,
paginatedFetcher,
multiFetcher,
sandboxAccountsFetcher,
+ sandboxCashoutFetcher,
};
}