From f281803f1e555b8e8c1e76612b1f6b7128033cd6 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 10 May 2023 13:35:18 -0300 Subject: compile again after DD37 impl --- .../src/wallet/History.stories.tsx | 8 ++- .../src/wallet/Transaction.stories.tsx | 61 +++++++++++++++------- .../src/wallet/Transaction.tsx | 38 +++++++------- 3 files changed, 68 insertions(+), 39 deletions(-) (limited to 'packages/taler-wallet-webextension/src/wallet') diff --git a/packages/taler-wallet-webextension/src/wallet/History.stories.tsx b/packages/taler-wallet-webextension/src/wallet/History.stories.tsx index d27224a77..1c5ba61c3 100644 --- a/packages/taler-wallet-webextension/src/wallet/History.stories.tsx +++ b/packages/taler-wallet-webextension/src/wallet/History.stories.tsx @@ -26,6 +26,7 @@ import { TalerProtocolTimestamp, TransactionCommon, TransactionDeposit, + TransactionMajorState, TransactionPayment, TransactionPeerPullCredit, TransactionPeerPullDebit, @@ -52,6 +53,9 @@ const commonTransaction = (): TransactionCommon => amountRaw: "USD:10", amountEffective: "USD:9", pending: false, + txState: { + major: TransactionMajorState.Done, + }, timestamp: TalerProtocolTimestamp.fromSeconds( new Date().getTime() / 1000 - count++ * 60 * 60 * 7, ), @@ -237,7 +241,9 @@ export const OneTransactionPending = tests.createExample(TestedComponent, { transactions: [ { ...exampleData.withdraw, - pending: true, + txState: { + major: TransactionMajorState.Pending, + }, }, ], balances: [ diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx index 71f8cfe1a..78b741b51 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.stories.tsx @@ -21,7 +21,6 @@ import { AbsoluteTime, - ExtendedStatus, PaymentStatus, RefreshReason, TalerProtocolTimestamp, @@ -56,19 +55,20 @@ export default { }, }; -const commonTransaction = { +const commonTransaction: TransactionCommon = { + error: undefined, amountRaw: "KUDOS:11", amountEffective: "KUDOS:9.2", - extendedStatus: ExtendedStatus.Done, - pending: undefined as any as boolean, //deprecated + txState: { + major: TransactionMajorState.Done, + }, timestamp: TalerProtocolTimestamp.now(), transactionId: "txn:deposit:12", - frozen: undefined as any as boolean, //deprecated type: TransactionType.Deposit, - txState: { - major: TransactionMajorState.Unknown, - }, -} as TransactionCommon; +} as Omit< + Omit, "frozen">, + "pending" +> as TransactionCommon; import merchantIcon from "../../static-dev/merchant-icon.jpeg"; @@ -262,7 +262,9 @@ export const WithdrawFiveMinutesAgoAndPending = tests.createExample( timestamp: TalerProtocolTimestamp.fromSeconds( new Date().getTime() / 1000 - 60 * 5, ), - extendedStatus: ExtendedStatus.Pending, + txState: { + major: TransactionMajorState.Pending, + }, }, }), ); @@ -302,7 +304,9 @@ export const WithdrawPendingManual = tests.createExample( exchangePaytoUris: ["payto://iban/ES8877998399652238"], reservePub: "A05AJGMFNSK4Q62NXR2FKNDB1J4EXTYQTE7VA4M9GZQ4TR06YBNG", } as WithdrawalDetails, - extendedStatus: ExtendedStatus.Pending, + txState: { + major: TransactionMajorState.Pending, + }, }, }), ); @@ -319,7 +323,9 @@ export const WithdrawPendingTalerBankUnconfirmed = tests.createExample( reservePub: "A05AJGMFNSK4Q62NXR2FKNDB1J4EXTYQTE7VA4M9GZQ4TR06YBNG", bankConfirmationUrl: "http://bank.demo.taler.net", }, - extendedStatus: ExtendedStatus.Pending, + txState: { + major: TransactionMajorState.Pending, + }, }, }, ); @@ -335,7 +341,9 @@ export const WithdrawPendingTalerBankConfirmed = tests.createExample( reserveIsReady: false, reservePub: "A05AJGMFNSK4Q62NXR2FKNDB1J4EXTYQTE7VA4M9GZQ4TR06YBNG", }, - extendedStatus: ExtendedStatus.Pending, + txState: { + major: TransactionMajorState.Pending, + }, }, }, ); @@ -461,7 +469,9 @@ export const PaymentWithoutFee = tests.createExample(TestedComponent, { export const PaymentPending = tests.createExample(TestedComponent, { transaction: { ...exampleData.payment, - extendedStatus: ExtendedStatus.Pending, + txState: { + major: TransactionMajorState.Pending, + }, }, }); @@ -561,7 +571,9 @@ export const DepositError = tests.createExample(TestedComponent, { export const DepositPending = tests.createExample(TestedComponent, { transaction: { ...exampleData.deposit, - extendedStatus: ExtendedStatus.Pending, + txState: { + major: TransactionMajorState.Pending, + }, }, }); @@ -588,7 +600,12 @@ export const TipError = tests.createExample(TestedComponent, { }); export const TipPending = tests.createExample(TestedComponent, { - transaction: { ...exampleData.tip, extendedStatus: ExtendedStatus.Pending }, + transaction: { + ...exampleData.tip, + txState: { + major: TransactionMajorState.Pending, + }, + }, }); export const Refund = tests.createExample(TestedComponent, { @@ -605,7 +622,9 @@ export const RefundError = tests.createExample(TestedComponent, { export const RefundPending = tests.createExample(TestedComponent, { transaction: { ...exampleData.refund, - extendedStatus: ExtendedStatus.Pending, + txState: { + major: TransactionMajorState.Pending, + }, }, }); @@ -616,7 +635,9 @@ export const InvoiceCreditComplete = tests.createExample(TestedComponent, { export const InvoiceCreditIncomplete = tests.createExample(TestedComponent, { transaction: { ...exampleData.pull_credit, - extendedStatus: ExtendedStatus.Pending, + txState: { + major: TransactionMajorState.Pending, + }, }, }); @@ -634,6 +655,8 @@ export const TransferDebitComplete = tests.createExample(TestedComponent, { export const TransferDebitIncomplete = tests.createExample(TestedComponent, { transaction: { ...exampleData.push_debit, - extendedStatus: ExtendedStatus.Pending, + txState: { + major: TransactionMajorState.Pending, + }, }, }); diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx index 8c2839324..cd240ffea 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx @@ -18,7 +18,6 @@ import { AbsoluteTime, AmountJson, Amounts, - ExtendedStatus, Location, MerchantInfo, NotificationType, @@ -29,6 +28,7 @@ import { TalerProtocolTimestamp, Transaction, TransactionDeposit, + TransactionMajorState, TransactionType, TranslatedString, WithdrawalType, @@ -136,9 +136,9 @@ export function TransactionPage({ }); goToWalletHistory(currency); }} - onRefund={async (purchaseId) => { - await api.wallet.call(WalletApiOperation.ApplyRefundFromPurchaseId, { - purchaseId, + onRefund={async (transactionId) => { + await api.wallet.call(WalletApiOperation.StartRefundQuery, { + transactionId, }); }} onBack={() => goToWalletHistory(currency)} @@ -186,7 +186,7 @@ function TransactionTemplate({ async function doCheckBeforeForget(): Promise { if ( - transaction.extendedStatus === ExtendedStatus.Pending && + transaction.txState.major === TransactionMajorState.Pending && transaction.type === TransactionType.Withdrawal ) { setConfirmBeforeForget(true); @@ -206,16 +206,16 @@ function TransactionTemplate({ transaction.type === TransactionType.Payment; const transactionStillActive = - transaction.extendedStatus !== ExtendedStatus.Aborted && - transaction.extendedStatus !== ExtendedStatus.Done && - transaction.extendedStatus !== ExtendedStatus.Failed; + transaction.txState.major !== TransactionMajorState.Aborted && + transaction.txState.major !== TransactionMajorState.Done && + transaction.txState.major !== TransactionMajorState.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.txState.major === TransactionMajorState.Aborting && (transaction.timestamp.t_s === "never" || differenceInSeconds(new Date(), transaction.timestamp.t_s * 1000) > SHOWING_RETRY_THRESHOLD_SECS))); @@ -252,7 +252,7 @@ function TransactionTemplate({ /> ) ) : undefined} - {transaction.extendedStatus === ExtendedStatus.Pending && ( + {transaction.txState.major === TransactionMajorState.Pending && ( This transaction is not completed @@ -417,9 +417,10 @@ export function TransactionView({ {transaction.exchangeBaseUrl} - {transaction.extendedStatus !== - ExtendedStatus.Pending ? undefined : transaction.withdrawalDetails - .type === WithdrawalType.ManualTransfer ? ( + {/**FIXME: DD37 check if this holds */} + {transaction.txState.major === + TransactionMajorState.Pending ? undefined : transaction + .withdrawalDetails.type === WithdrawalType.ManualTransfer ? ( //manual withdrawal - {transaction.info.summary} + {"transaction.info.summary"} - {transaction.info.orderId} + {"transaction.info.orderId"} } kind="neutral" /> - {transaction.extendedStatus === - ExtendedStatus.Pending /** pending is not-pay */ && + {transaction.txState.major === TransactionMajorState.Pending && !transaction.error && (