aboutsummaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/hooks/circuit.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/demobank-ui/src/hooks/circuit.ts')
-rw-r--r--packages/demobank-ui/src/hooks/circuit.ts22
1 files changed, 9 insertions, 13 deletions
diff --git a/packages/demobank-ui/src/hooks/circuit.ts b/packages/demobank-ui/src/hooks/circuit.ts
index 0c306259b..2b0781465 100644
--- a/packages/demobank-ui/src/hooks/circuit.ts
+++ b/packages/demobank-ui/src/hooks/circuit.ts
@@ -218,7 +218,7 @@ export function useOnePendingCashouts(account: string) {
const pendingCashout = list.body.cashouts.find(
(c) => c.status === "pending",
);
- if (!pendingCashout) return opFixedSuccess(undefined);
+ if (!pendingCashout) return opFixedSuccess(list.httpResp, undefined);
const cashoutInfo = await api.getCashoutById(
{ username, token },
pendingCashout?.cashout_id,
@@ -226,7 +226,7 @@ export function useOnePendingCashouts(account: string) {
if (cashoutInfo.type !== "ok") {
return cashoutInfo;
}
- return opFixedSuccess({
+ return opFixedSuccess(list.httpResp, {
...cashoutInfo.body,
id: pendingCashout.cashout_id,
});
@@ -275,21 +275,17 @@ export function useCashouts(account: string) {
return list;
}
const all: Array<CashoutWithId | undefined> = await Promise.all(
- list.body.cashouts.map((c) => {
- return api
- .getCashoutById({ username, token }, c.cashout_id)
- .then((r) => {
- if (r.type === "fail") {
- return undefined;
- }
- return { ...r.body, id: c.cashout_id };
- });
+ list.body.cashouts.map(async (c) => {
+ const r = await api.getCashoutById({ username, token }, c.cashout_id);
+ if (r.type === "fail") {
+ return undefined;
+ }
+ return { ...r.body, id: c.cashout_id };
}),
);
const cashouts = all.filter(notUndefined);
- return { type: "ok" as const, body: { cashouts } };
+ return { type: "ok" as const, body: { cashouts }, httpResp: list.httpResp };
}
-
const { data, error } = useSWR<
| OperationOk<{ cashouts: CashoutWithId[] }>
| TalerCoreBankErrorsByMethod<"getAccountCashouts">,