use payto builder and prevent showing cancel for non-payment
This commit is contained in:
parent
252382a937
commit
420493b3e6
@ -147,7 +147,7 @@ export function useComponentState({
|
||||
initialValue ?? ({} as any),
|
||||
);
|
||||
const amountStr = Amounts.stringify(amount);
|
||||
const depositPaytoUri = `payto://${currentAccount.targetType}/${currentAccount.targetPath}`;
|
||||
const depositPaytoUri = stringifyPaytoUri(currentAccount);
|
||||
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
const hook = useAsyncAsHook(async () => {
|
||||
|
@ -128,7 +128,7 @@ export function useComponentState({
|
||||
}),
|
||||
},
|
||||
accountByType,
|
||||
deleteAccount,
|
||||
deleteAccount: pushAlertOnError(deleteAccount),
|
||||
onAccountAdded: {
|
||||
onClick: unableToAdd ? undefined : pushAlertOnError(addAccount),
|
||||
},
|
||||
|
@ -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 (
|
||||
|
@ -202,20 +202,24 @@ function TransactionTemplate({
|
||||
const SHOWING_RETRY_THRESHOLD_SECS = 30;
|
||||
|
||||
const showSend = false;
|
||||
// (transaction.type === TransactionType.PeerPullCredit ||
|
||||
// transaction.type === TransactionType.PeerPushDebit) &&
|
||||
// !transaction.info.completed;
|
||||
const showRetry =
|
||||
transaction.error !== undefined ||
|
||||
transaction.timestamp.t_s === "never" ||
|
||||
(transaction.extendedStatus === ExtendedStatus.Pending &&
|
||||
differenceInSeconds(new Date(), transaction.timestamp.t_s * 1000) >
|
||||
SHOWING_RETRY_THRESHOLD_SECS);
|
||||
const hasCancelTransactionImplemented =
|
||||
transaction.type === TransactionType.Payment;
|
||||
|
||||
const transactionStillActive =
|
||||
transaction.extendedStatus !== ExtendedStatus.Aborted &&
|
||||
transaction.extendedStatus !== ExtendedStatus.Done &&
|
||||
transaction.extendedStatus !== ExtendedStatus.Failed;
|
||||
|
||||
// show retry if there is an error in an active state, or after some time
|
||||
// if it is not aborting
|
||||
const showRetry =
|
||||
transactionStillActive &&
|
||||
(transaction.error !== undefined ||
|
||||
(transaction.extendedStatus !== ExtendedStatus.Aborting &&
|
||||
(transaction.timestamp.t_s === "never" ||
|
||||
differenceInSeconds(new Date(), transaction.timestamp.t_s * 1000) >
|
||||
SHOWING_RETRY_THRESHOLD_SECS)));
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<section style={{ padding: 8, textAlign: "center" }}>
|
||||
@ -353,6 +357,7 @@ function TransactionTemplate({
|
||||
</Button>
|
||||
) : null}
|
||||
{transactionStillActive ? (
|
||||
hasCancelTransactionImplemented ? (
|
||||
<Button
|
||||
variant="contained"
|
||||
color="error"
|
||||
@ -360,6 +365,7 @@ function TransactionTemplate({
|
||||
>
|
||||
<i18n.Translate>Cancel</i18n.Translate>
|
||||
</Button>
|
||||
) : undefined
|
||||
) : (
|
||||
<Button
|
||||
variant="contained"
|
||||
|
Loading…
Reference in New Issue
Block a user