summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/cta/InvoiceCreate
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-12-15 17:11:24 -0300
committerSebastian <sebasjm@gmail.com>2022-12-15 17:11:24 -0300
commitf93bd51499ed34844b666bf6d333227adf4368bf (patch)
treeed3cf0c38b7db54276436d1743a6085c94f71977 /packages/taler-wallet-webextension/src/cta/InvoiceCreate
parent8d8d71807df6b775e5b0335eb1b2526a56d42ac6 (diff)
downloadwallet-core-f93bd51499ed34844b666bf6d333227adf4368bf.tar.gz
wallet-core-f93bd51499ed34844b666bf6d333227adf4368bf.tar.bz2
wallet-core-f93bd51499ed34844b666bf6d333227adf4368bf.zip
wxApi from context and using the new testing sdk
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/InvoiceCreate')
-rw-r--r--packages/taler-wallet-webextension/src/cta/InvoiceCreate/index.ts3
-rw-r--r--packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts8
2 files changed, 5 insertions, 6 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/index.ts b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/index.ts
index 01dbb6d6d..0569e8e5f 100644
--- a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/index.ts
+++ b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/index.ts
@@ -22,7 +22,6 @@ import { ButtonHandler, TextFieldHandler } from "../../mui/handlers.js";
import { compose, StateViewMap } from "../../utils/index.js";
import { ExchangeSelectionPage } from "../../wallet/ExchangeSelection/index.js";
import { NoExchangesView } from "../../wallet/ExchangeSelection/views.js";
-import { wxApi } from "../../wxApi.js";
import { useComponentState } from "./state.js";
import { LoadingUriView, ReadyView } from "./views.js";
@@ -78,6 +77,6 @@ const viewMapping: StateViewMap<State> = {
export const InvoiceCreatePage = compose(
"InvoiceCreatePage",
- (p: Props) => useComponentState(p, wxApi),
+ (p: Props) => useComponentState(p),
viewMapping,
);
diff --git a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts
index 6007b5193..a26167f8e 100644
--- a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts
+++ b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts
@@ -23,17 +23,17 @@ import {
import { TalerError, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { isFuture, parse } from "date-fns";
import { useState } from "preact/hooks";
+import { useBackendContext } from "../../context/backend.js";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { useSelectedExchange } from "../../hooks/useSelectedExchange.js";
import { RecursiveState } from "../../utils/index.js";
-import { wxApi } from "../../wxApi.js";
import { Props, State } from "./index.js";
export function useComponentState(
{ amount: amountStr, onClose, onSuccess }: Props,
- api: typeof wxApi,
): RecursiveState<State> {
const amount = Amounts.parseOrThrow(amountStr);
+ const api = useBackendContext()
const hook = useAsyncAsHook(() =>
api.wallet.call(WalletApiOperation.ListExchanges, {}),
@@ -158,8 +158,8 @@ export function useComponentState(
subject === undefined
? undefined
: !subject
- ? "Can't be empty"
- : undefined,
+ ? "Can't be empty"
+ : undefined,
value: subject ?? "",
onInput: async (e) => setSubject(e),
},