From b43c476590508b5b3b10a5c2da34ac30f1fbdf57 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 28 Jun 2021 11:38:29 -0300 Subject: handler transaction error on details and added retry button --- .../src/popup/Transaction.stories.tsx | 54 ++++++++++++++++++++++ .../src/popup/Transaction.tsx | 37 +++++++++++---- .../src/popupEntryPoint.tsx | 5 +- packages/taler-wallet-webextension/src/wxApi.ts | 14 +++++- 4 files changed, 98 insertions(+), 12 deletions(-) (limited to 'packages/taler-wallet-webextension/src') diff --git a/packages/taler-wallet-webextension/src/popup/Transaction.stories.tsx b/packages/taler-wallet-webextension/src/popup/Transaction.stories.tsx index 48f945783..00108aac6 100644 --- a/packages/taler-wallet-webextension/src/popup/Transaction.stories.tsx +++ b/packages/taler-wallet-webextension/src/popup/Transaction.stories.tsx @@ -32,6 +32,11 @@ import { TransactionView as TestedComponent } from './Transaction'; export default { title: 'popup/transaction/details', component: TestedComponent, + argTypes: { + onRetry: { action: 'onRetry' }, + onDelete: { action: 'onDelete' }, + onBack: { action: 'onBack' }, + } }; const commonTransaction = { @@ -105,6 +110,13 @@ const exampleData = { } as TransactionRefund, } +const transactionError = { + code: 2000, + details: "details", + hint: "this is a hint for the error", + message: 'message' +} + function createExample(Component: FunctionalComponent, props: Partial) { const r = (args: any) => r.args = props @@ -117,6 +129,13 @@ export const Withdraw = createExample(TestedComponent, { transaction: exampleData.withdraw }); +export const WithdrawError = createExample(TestedComponent, { + transaction: { + ...exampleData.withdraw, + error: transactionError, + }, +}); + export const WithdrawPending = createExample(TestedComponent, { transaction: { ...exampleData.withdraw, pending: true }, }); @@ -126,6 +145,13 @@ export const Payment = createExample(TestedComponent, { transaction: exampleData.payment }); +export const PaymentError = createExample(TestedComponent, { + transaction: { + ...exampleData.payment, + error: transactionError + }, +}); + export const PaymentWithoutFee = createExample(TestedComponent, { transaction: { ...exampleData.payment, @@ -191,6 +217,13 @@ export const Deposit = createExample(TestedComponent, { transaction: exampleData.deposit }); +export const DepositError = createExample(TestedComponent, { + transaction: { + ...exampleData.deposit, + error: transactionError + }, +}); + export const DepositPending = createExample(TestedComponent, { transaction: { ...exampleData.deposit, pending: true } }); @@ -199,10 +232,24 @@ export const Refresh = createExample(TestedComponent, { transaction: exampleData.refresh }); +export const RefreshError = createExample(TestedComponent, { + transaction: { + ...exampleData.refresh, + error: transactionError + }, +}); + export const Tip = createExample(TestedComponent, { transaction: exampleData.tip }); +export const TipError = createExample(TestedComponent, { + transaction: { + ...exampleData.tip, + error: transactionError + }, +}); + export const TipPending = createExample(TestedComponent, { transaction: { ...exampleData.tip, pending: true } }); @@ -211,6 +258,13 @@ export const Refund = createExample(TestedComponent, { transaction: exampleData.refund }); +export const RefundError = createExample(TestedComponent, { + transaction: { + ...exampleData.refund, + error: transactionError + }, +}); + export const RefundPending = createExample(TestedComponent, { transaction: { ...exampleData.refund, pending: true } }); diff --git a/packages/taler-wallet-webextension/src/popup/Transaction.tsx b/packages/taler-wallet-webextension/src/popup/Transaction.tsx index 12245e5be..7a66d7a0e 100644 --- a/packages/taler-wallet-webextension/src/popup/Transaction.tsx +++ b/packages/taler-wallet-webextension/src/popup/Transaction.tsx @@ -44,16 +44,18 @@ export function TransactionPage({ tid }: { tid: string; }): JSX.Element { return wxApi.deleteTransaction(tid).then(_ => history.go(-1))} + onRetry={() => wxApi.retryTransaction(tid).then(_ => history.go(-1))} onBack={() => { history.go(-1); }} />; } export interface WalletTransactionProps { transaction?: Transaction, onDelete: () => void, + onRetry: () => void, onBack: () => void, } -export function TransactionView({ transaction, onDelete, onBack }: WalletTransactionProps) { +export function TransactionView({ transaction, onDelete, onRetry, onBack }: WalletTransactionProps) { if (!transaction) { return
Loading ...
; } @@ -62,17 +64,28 @@ export function TransactionView({ transaction, onDelete, onBack }: WalletTransac return
- + {transaction?.error ? : null } +
} - function Pending() { + function Status() { + if (transaction?.error) { + return (failed) + } if (!transaction?.pending) return null return (pending...) } + function Error() { + if (!transaction?.error) return null + return
+

{transaction.error.hint}

+
+ } + const Fee = ({ value }: { value: AmountJson }) => Amounts.isNonZero(value) ? (fee {Amounts.stringify(value)}) : null @@ -88,7 +101,8 @@ export function TransactionView({ transaction, onDelete, onBack }: WalletTransac From {transaction.exchangeBaseUrl} -

Withdraw

+ +

Withdraw

{transaction.amountEffective}