diff options
author | Sebastian <sebasjm@gmail.com> | 2022-09-16 16:03:58 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-09-16 16:03:58 -0300 |
commit | 59d235e8d29159bc8caccf8bee6a2bca8b0b90dc (patch) | |
tree | 551261c860b1989dc0b1a05ddcfd53d20e561626 /packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts | |
parent | 6ddb2de84245ae3914c92b2b2eb7399e7f04500e (diff) | |
download | wallet-core-59d235e8d29159bc8caccf8bee6a2bca8b0b90dc.tar.xz |
redirect after success #7357
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts b/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts index e6397f2e9..03dfc8b18 100644 --- a/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts +++ b/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts @@ -21,34 +21,18 @@ import * as wxApi from "../../wxApi.js"; import { Props, State } from "./index.js"; export function useComponentState( - { amount: amountStr, onClose }: Props, + { amount: amountStr, onClose, onSuccess }: Props, api: typeof wxApi, ): State { const amount = Amounts.parseOrThrow(amountStr); const [subject, setSubject] = useState(""); - const [talerUri, setTalerUri] = useState(""); const [operationError, setOperationError] = useState< TalerErrorDetail | undefined >(undefined); - if (talerUri) { - return { - status: "created", - talerUri, - error: undefined, - cancel: { - onClick: onClose, - }, - copyToClipboard: { - onClick: async () => { - navigator.clipboard.writeText(talerUri); - }, - }, - }; - } - async function accept(): Promise<string> { + async function accept(): Promise<void> { try { const resp = await api.initiatePeerPushPayment({ amount: Amounts.stringify(amount), @@ -56,7 +40,7 @@ export function useComponentState( summary: subject, }, }); - return resp.talerUri; + onSuccess(resp.transactionId); } catch (e) { if (e instanceof TalerError) { setOperationError(e.errorDetail); @@ -77,10 +61,7 @@ export function useComponentState( onInput: async (e) => setSubject(e), }, create: { - onClick: async () => { - const uri = await accept(); - setTalerUri(uri); - }, + onClick: accept }, chosenAmount: amount, toBeReceived: amount, |