diff options
author | Sebastian <sebasjm@gmail.com> | 2023-01-17 16:01:04 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-01-17 16:01:28 -0300 |
commit | 420493b3e608f3b245ebae308a318883f9f605f7 (patch) | |
tree | 9d30255d66dcda7c7fabc190e3b372369a66540a /packages/taler-wallet-webextension/src/wallet/ManageAccount | |
parent | 252382a9375ea05f62389e33f111c3fa008d8fff (diff) | |
download | wallet-core-420493b3e608f3b245ebae308a318883f9f605f7.tar.xz |
use payto builder and prevent showing cancel for non-payment
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet/ManageAccount')
-rw-r--r-- | packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts | 2 | ||||
-rw-r--r-- | packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx | 22 |
2 files changed, 14 insertions, 10 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts b/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts index f7383d483..50e71c144 100644 --- a/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts +++ b/packages/taler-wallet-webextension/src/wallet/ManageAccount/state.ts @@ -128,7 +128,7 @@ export function useComponentState({ }), }, accountByType, - deleteAccount, + deleteAccount: pushAlertOnError(deleteAccount), onAccountAdded: { onClick: unableToAdd ? undefined : pushAlertOnError(addAccount), }, diff --git a/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx b/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx index e5be8d17d..75e1feca4 100644 --- a/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx +++ b/packages/taler-wallet-webextension/src/wallet/ManageAccount/views.tsx @@ -15,10 +15,12 @@ */ import { + buildPayto, KnownBankAccountsInfo, PaytoUriBitcoin, PaytoUriIBAN, PaytoUriTalerBank, + stringifyPaytoUri, } from "@gnu-taler/taler-util"; import { styled } from "@linaria/react"; import { Fragment, h, VNode } from "preact"; @@ -411,7 +413,8 @@ function BitcoinAddressAccount({ field }: { field: TextFieldHandler }): VNode { onChange={(v) => { setValue(v); if (!errors && field.onInput) { - field.onInput(`payto://bitcoin/${v}`); + const p = buildPayto("bitcoin", v, undefined); + field.onInput(stringifyPaytoUri(p)); } }} /> @@ -448,8 +451,9 @@ function TalerBankAddressAccount({ disabled={!field.onInput} onChange={(v) => { setHost(v); - if (!errors && field.onInput) { - field.onInput(`payto://x-taler-bank/${v}/${account}`); + if (!errors && field.onInput && account) { + const p = buildPayto("x-taler-bank", v, account); + field.onInput(stringifyPaytoUri(p)); } }} /> @@ -462,8 +466,9 @@ function TalerBankAddressAccount({ error={account !== undefined ? errors?.account : undefined} onChange={(v) => { setAccount(v || ""); - if (!errors && field.onInput) { - field.onInput(`payto://x-taler-bank/${host}/${v}`); + if (!errors && field.onInput && host) { + const p = buildPayto("x-taler-bank", host, v); + field.onInput(stringifyPaytoUri(p)); } }} /> @@ -500,10 +505,9 @@ function IbanAddressAccount({ field }: { field: TextFieldHandler }): VNode { name: string, ): void { if (!errors && field.onInput) { - const path = bic === undefined ? iban : `${bic}/${iban}`; - field.onInput( - `payto://iban/${path}?receiver-name=${encodeURIComponent(name)}`, - ); + const p = buildPayto("iban", iban, bic); + p.params["receiver-name"] = name; + field.onInput(stringifyPaytoUri(p)); } } return ( |