diff options
author | Sebastian <sebasjm@gmail.com> | 2022-09-16 16:04:41 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-09-16 16:04:41 -0300 |
commit | e14310825437c5de93c07c570639d2a09fc4826b (patch) | |
tree | 6d63ed9d62bdb21fdbf41e8c5d30fcc08bb9326f | |
parent | 59d235e8d29159bc8caccf8bee6a2bca8b0b90dc (diff) |
pretty
22 files changed, 309 insertions, 267 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Deposit/index.ts b/packages/taler-wallet-webextension/src/cta/Deposit/index.ts index d6433b18c..0246b6f7c 100644 --- a/packages/taler-wallet-webextension/src/cta/Deposit/index.ts +++ b/packages/taler-wallet-webextension/src/cta/Deposit/index.ts @@ -30,10 +30,7 @@ export interface Props { onSuccess: (tx: string) => Promise<void>; } -export type State = - | State.Loading - | State.LoadingUriError - | State.Ready; +export type State = State.Loading | State.LoadingUriError | State.Ready; export namespace State { export interface Loading { diff --git a/packages/taler-wallet-webextension/src/cta/Deposit/state.ts b/packages/taler-wallet-webextension/src/cta/Deposit/state.ts index b6861cb4b..5662a24c8 100644 --- a/packages/taler-wallet-webextension/src/cta/Deposit/state.ts +++ b/packages/taler-wallet-webextension/src/cta/Deposit/state.ts @@ -24,7 +24,6 @@ export function useComponentState( { talerDepositUri, amountStr, cancel, onSuccess }: Props, api: typeof wxApi, ): State { - const info = useAsyncAsHook(async () => { if (!talerDepositUri) throw Error("ERROR_NO-URI-FOR-DEPOSIT"); if (!amountStr) throw Error("ERROR_NO-AMOUNT-FOR-DEPOSIT"); diff --git a/packages/taler-wallet-webextension/src/cta/Deposit/test.ts b/packages/taler-wallet-webextension/src/cta/Deposit/test.ts index 5d5c5cecb..b6e63a796 100644 --- a/packages/taler-wallet-webextension/src/cta/Deposit/test.ts +++ b/packages/taler-wallet-webextension/src/cta/Deposit/test.ts @@ -35,7 +35,9 @@ describe("Deposit CTA states", () => { cancel: async () => { null; }, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { prepareRefund: async () => ({}), @@ -76,14 +78,16 @@ describe("Deposit CTA states", () => { cancel: async () => { null; }, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { prepareDeposit: async () => - ({ - effectiveDepositAmount: Amounts.parseOrThrow("EUR:1"), - totalDepositCost: Amounts.parseOrThrow("EUR:1.2"), - } as PrepareDepositResponse as any), + ({ + effectiveDepositAmount: Amounts.parseOrThrow("EUR:1"), + totalDepositCost: Amounts.parseOrThrow("EUR:1.2"), + } as PrepareDepositResponse as any), createDepositGroup: async () => ({}), } as any, ), diff --git a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/index.ts b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/index.ts index f7d6fbe63..8beac2cb2 100644 --- a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/index.ts +++ b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/index.ts @@ -29,10 +29,7 @@ export interface Props { onSuccess: (tx: string) => Promise<void>; } -export type State = - | State.Loading - | State.LoadingUriError - | State.Ready; +export type State = State.Loading | State.LoadingUriError | State.Ready; export namespace State { export interface Loading { diff --git a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts index a338387de..6b4f54504 100644 --- a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts +++ b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts @@ -87,7 +87,7 @@ export function useComponentState( invalid: !subject || Amounts.isZero(amount), exchangeUrl: selected.exchangeBaseUrl, create: { - onClick: accept + onClick: accept, }, cancel: { onClick: onClose, diff --git a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/views.tsx b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/views.tsx index 693c07713..209fb31e5 100644 --- a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/views.tsx +++ b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/views.tsx @@ -45,7 +45,6 @@ export function LoadingUriView({ error }: State.LoadingUriError): VNode { ); } - export function ReadyView({ invalid, exchangeUrl, diff --git a/packages/taler-wallet-webextension/src/cta/Payment/index.ts b/packages/taler-wallet-webextension/src/cta/Payment/index.ts index 1dd84fd7e..8e446722e 100644 --- a/packages/taler-wallet-webextension/src/cta/Payment/index.ts +++ b/packages/taler-wallet-webextension/src/cta/Payment/index.ts @@ -85,7 +85,6 @@ export namespace State { payStatus: PreparePayResultAlreadyConfirmed; balance: AmountJson; } - } const viewMapping: StateViewMap<State> = { diff --git a/packages/taler-wallet-webextension/src/cta/Payment/stories.tsx b/packages/taler-wallet-webextension/src/cta/Payment/stories.tsx index 6946f6906..c499dc285 100644 --- a/packages/taler-wallet-webextension/src/cta/Payment/stories.tsx +++ b/packages/taler-wallet-webextension/src/cta/Payment/stories.tsx @@ -333,5 +333,3 @@ export const AlreadyConfirmedByOther = createExample(BaseView, { paid: false, }, }); - - diff --git a/packages/taler-wallet-webextension/src/cta/Payment/test.ts b/packages/taler-wallet-webextension/src/cta/Payment/test.ts index 91d2d825d..f4ce5afb3 100644 --- a/packages/taler-wallet-webextension/src/cta/Payment/test.ts +++ b/packages/taler-wallet-webextension/src/cta/Payment/test.ts @@ -75,7 +75,9 @@ describe("Payment CTA states", () => { talerPayUri: undefined, cancel: nullFunction, goToWalletManualWithdraw: nullFunction, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { onUpdateNotification: nullFunction, @@ -111,19 +113,21 @@ describe("Payment CTA states", () => { talerPayUri: "taller://pay", cancel: nullFunction, goToWalletManualWithdraw: nullFunction, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { onUpdateNotification: nullFunction, preparePay: async () => - ({ - amountRaw: "USD:10", - status: PreparePayResultType.InsufficientBalance, - } as Partial<PreparePayResult>), + ({ + amountRaw: "USD:10", + status: PreparePayResultType.InsufficientBalance, + } as Partial<PreparePayResult>), getBalance: async () => - ({ - balances: [], - } as Partial<BalancesResponse>), + ({ + balances: [], + } as Partial<BalancesResponse>), } as Partial<typeof wxApi> as any, ), ); @@ -154,23 +158,25 @@ describe("Payment CTA states", () => { talerPayUri: "taller://pay", cancel: nullFunction, goToWalletManualWithdraw: nullFunction, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { onUpdateNotification: nullFunction, preparePay: async () => - ({ - amountRaw: "USD:10", - status: PreparePayResultType.InsufficientBalance, - } as Partial<PreparePayResult>), + ({ + amountRaw: "USD:10", + status: PreparePayResultType.InsufficientBalance, + } as Partial<PreparePayResult>), getBalance: async () => - ({ - balances: [ - { - available: "USD:5", - }, - ], - } as Partial<BalancesResponse>), + ({ + balances: [ + { + available: "USD:5", + }, + ], + } as Partial<BalancesResponse>), } as Partial<typeof wxApi> as any, ), ); @@ -201,24 +207,26 @@ describe("Payment CTA states", () => { talerPayUri: "taller://pay", cancel: nullFunction, goToWalletManualWithdraw: nullFunction, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { onUpdateNotification: nullFunction, preparePay: async () => - ({ - amountRaw: "USD:10", - amountEffective: "USD:10", - status: PreparePayResultType.PaymentPossible, - } as Partial<PreparePayResult>), + ({ + amountRaw: "USD:10", + amountEffective: "USD:10", + status: PreparePayResultType.PaymentPossible, + } as Partial<PreparePayResult>), getBalance: async () => - ({ - balances: [ - { - available: "USD:15", - }, - ], - } as Partial<BalancesResponse>), + ({ + balances: [ + { + available: "USD:15", + }, + ], + } as Partial<BalancesResponse>), } as Partial<typeof wxApi> as any, ), ); @@ -251,24 +259,26 @@ describe("Payment CTA states", () => { talerPayUri: "taller://pay", cancel: nullFunction, goToWalletManualWithdraw: nullFunction, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { onUpdateNotification: nullFunction, preparePay: async () => - ({ - amountRaw: "USD:9", - amountEffective: "USD:10", - status: PreparePayResultType.PaymentPossible, - } as Partial<PreparePayResult>), + ({ + amountRaw: "USD:9", + amountEffective: "USD:10", + status: PreparePayResultType.PaymentPossible, + } as Partial<PreparePayResult>), getBalance: async () => - ({ - balances: [ - { - available: "USD:15", - }, - ], - } as Partial<BalancesResponse>), + ({ + balances: [ + { + available: "USD:15", + }, + ], + } as Partial<BalancesResponse>), } as Partial<typeof wxApi> as any, ), ); @@ -301,29 +311,31 @@ describe("Payment CTA states", () => { talerPayUri: "taller://pay", cancel: nullFunction, goToWalletManualWithdraw: nullFunction, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { onUpdateNotification: nullFunction, preparePay: async () => - ({ - amountRaw: "USD:9", - amountEffective: "USD:10", - status: PreparePayResultType.PaymentPossible, - } as Partial<PreparePayResult>), + ({ + amountRaw: "USD:9", + amountEffective: "USD:10", + status: PreparePayResultType.PaymentPossible, + } as Partial<PreparePayResult>), getBalance: async () => - ({ - balances: [ - { - available: "USD:15", - }, - ], - } as Partial<BalancesResponse>), + ({ + balances: [ + { + available: "USD:15", + }, + ], + } as Partial<BalancesResponse>), confirmPay: async () => - ({ - type: ConfirmPayResultType.Done, - contractTerms: {}, - } as Partial<ConfirmPayResult>), + ({ + type: ConfirmPayResultType.Done, + contractTerms: {}, + } as Partial<ConfirmPayResult>), } as Partial<typeof wxApi> as any, ), ); @@ -370,29 +382,31 @@ describe("Payment CTA states", () => { talerPayUri: "taller://pay", cancel: nullFunction, goToWalletManualWithdraw: nullFunction, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { onUpdateNotification: nullFunction, preparePay: async () => - ({ - amountRaw: "USD:9", - amountEffective: "USD:10", - status: PreparePayResultType.PaymentPossible, - } as Partial<PreparePayResult>), + ({ + amountRaw: "USD:9", + amountEffective: "USD:10", + status: PreparePayResultType.PaymentPossible, + } as Partial<PreparePayResult>), getBalance: async () => - ({ - balances: [ - { - available: "USD:15", - }, - ], - } as Partial<BalancesResponse>), + ({ + balances: [ + { + available: "USD:15", + }, + ], + } as Partial<BalancesResponse>), confirmPay: async () => - ({ - type: ConfirmPayResultType.Pending, - lastError: { code: 1 }, - } as Partial<ConfirmPayResult>), + ({ + type: ConfirmPayResultType.Pending, + lastError: { code: 1 }, + } as Partial<ConfirmPayResult>), } as Partial<typeof wxApi> as any, ), ); @@ -454,24 +468,26 @@ describe("Payment CTA states", () => { talerPayUri: "taller://pay", cancel: nullFunction, goToWalletManualWithdraw: nullFunction, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { onUpdateNotification: subscriptions.saveSubscription, preparePay: async () => - ({ - amountRaw: "USD:9", - amountEffective: "USD:10", - status: PreparePayResultType.PaymentPossible, - } as Partial<PreparePayResult>), + ({ + amountRaw: "USD:9", + amountEffective: "USD:10", + status: PreparePayResultType.PaymentPossible, + } as Partial<PreparePayResult>), getBalance: async () => - ({ - balances: [ - { - available: Amounts.stringify(availableBalance), - }, - ], - } as Partial<BalancesResponse>), + ({ + balances: [ + { + available: Amounts.stringify(availableBalance), + }, + ], + } as Partial<BalancesResponse>), } as Partial<typeof wxApi> as any, ), ); diff --git a/packages/taler-wallet-webextension/src/cta/Payment/views.tsx b/packages/taler-wallet-webextension/src/cta/Payment/views.tsx index a2e52269c..7646e4bf1 100644 --- a/packages/taler-wallet-webextension/src/cta/Payment/views.tsx +++ b/packages/taler-wallet-webextension/src/cta/Payment/views.tsx @@ -166,14 +166,14 @@ export function BaseView(state: SupportedStates): VNode { /> )} </section> - <ButtonsSection - amount={state.amount} - balance={state.balance} - payStatus={state.payStatus} - uri={state.uri} - payHandler={state.status === "ready" ? state.payHandler : undefined} - goToWalletManualWithdraw={state.goToWalletManualWithdraw} - /> + <ButtonsSection + amount={state.amount} + balance={state.balance} + payStatus={state.payStatus} + uri={state.uri} + payHandler={state.status === "ready" ? state.payHandler : undefined} + goToWalletManualWithdraw={state.goToWalletManualWithdraw} + /> <section> <Link upperCased onClick={state.cancel}> <i18n.Translate>Cancel</i18n.Translate> diff --git a/packages/taler-wallet-webextension/src/cta/Refund/stories.tsx b/packages/taler-wallet-webextension/src/cta/Refund/stories.tsx index d74120dff..f95bfc693 100644 --- a/packages/taler-wallet-webextension/src/cta/Refund/stories.tsx +++ b/packages/taler-wallet-webextension/src/cta/Refund/stories.tsx @@ -22,11 +22,7 @@ import { Amounts } from "@gnu-taler/taler-util"; import beer from "../../../static-dev/beer.png"; import { createExample } from "../../test-utils.js"; -import { - IgnoredView, - InProgressView, - ReadyView, -} from "./views.js"; +import { IgnoredView, InProgressView, ReadyView } from "./views.js"; export default { title: "cta/refund", }; diff --git a/packages/taler-wallet-webextension/src/cta/Refund/test.ts b/packages/taler-wallet-webextension/src/cta/Refund/test.ts index 09470b7f6..3111a85c6 100644 --- a/packages/taler-wallet-webextension/src/cta/Refund/test.ts +++ b/packages/taler-wallet-webextension/src/cta/Refund/test.ts @@ -40,7 +40,9 @@ describe("Refund CTA states", () => { cancel: async () => { null; }, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { prepareRefund: async () => ({}), @@ -80,26 +82,28 @@ describe("Refund CTA states", () => { cancel: async () => { null; }, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { prepareRefund: async () => - ({ - effectivePaid: "EUR:2", - awaiting: "EUR:2", - gone: "EUR:0", - granted: "EUR:0", - pending: false, - proposalId: "1", - info: { - contractTermsHash: "123", - merchant: { - name: "the merchant name", + ({ + effectivePaid: "EUR:2", + awaiting: "EUR:2", + gone: "EUR:0", + granted: "EUR:0", + pending: false, + proposalId: "1", + info: { + contractTermsHash: "123", + merchant: { + name: "the merchant name", + }, + orderId: "orderId1", + summary: "the summary", }, - orderId: "orderId1", - summary: "the summary", - }, - } as PrepareRefundResult as any), + } as PrepareRefundResult as any), applyRefund: async () => ({}), onUpdateNotification: async () => ({}), } as any, @@ -138,26 +142,28 @@ describe("Refund CTA states", () => { cancel: async () => { null; }, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { prepareRefund: async () => - ({ - effectivePaid: "EUR:2", - awaiting: "EUR:2", - gone: "EUR:0", - granted: "EUR:0", - pending: false, - proposalId: "1", - info: { - contractTermsHash: "123", - merchant: { - name: "the merchant name", + ({ + effectivePaid: "EUR:2", + awaiting: "EUR:2", + gone: "EUR:0", + granted: "EUR:0", + pending: false, + proposalId: "1", + info: { + contractTermsHash: "123", + merchant: { + name: "the merchant name", + }, + orderId: "orderId1", + summary: "the summary", }, - orderId: "orderId1", - summary: "the summary", - }, - } as PrepareRefundResult as any), + } as PrepareRefundResult as any), applyRefund: async () => ({}), onUpdateNotification: async () => ({}), } as any, @@ -223,27 +229,28 @@ describe("Refund CTA states", () => { cancel: async () => { null; }, - onSuccess: async () => { null; }, - + onSuccess: async () => { + null; + }, }, { prepareRefund: async () => - ({ - awaiting: Amounts.stringify(awaiting), - effectivePaid: "EUR:2", - gone: "EUR:0", - granted: Amounts.stringify(granted), - pending, - proposalId: "1", - info: { - contractTermsHash: "123", - merchant: { - name: "the merchant name", + ({ + awaiting: Amounts.stringify(awaiting), + effectivePaid: "EUR:2", + gone: "EUR:0", + granted: Amounts.stringify(granted), + pending, + proposalId: "1", + info: { + contractTermsHash: "123", + merchant: { + name: "the merchant name", + }, + orderId: "orderId1", + summary: "the summary", }, - orderId: "orderId1", - summary: "the summary", - }, - } as PrepareRefundResult as any), + } as PrepareRefundResult as any), applyRefund: async () => ({}), onUpdateNotification: subscriptions.saveSubscription, } as any, diff --git a/packages/taler-wallet-webextension/src/cta/Tip/state.ts b/packages/taler-wallet-webextension/src/cta/Tip/state.ts index a3adafe53..f6721d504 100644 --- a/packages/taler-wallet-webextension/src/cta/Tip/state.ts +++ b/packages/taler-wallet-webextension/src/cta/Tip/state.ts @@ -52,7 +52,7 @@ export function useComponentState( //FIX: this may not be seen since we are moving to the success also tipInfo.retry(); - onSuccess(res.transactionId) + onSuccess(res.transactionId); }; const baseInfo = { diff --git a/packages/taler-wallet-webextension/src/cta/Tip/test.ts b/packages/taler-wallet-webextension/src/cta/Tip/test.ts index eeb39c8aa..47d9aa8db 100644 --- a/packages/taler-wallet-webextension/src/cta/Tip/test.ts +++ b/packages/taler-wallet-webextension/src/cta/Tip/test.ts @@ -34,7 +34,9 @@ describe("Tip CTA states", () => { onCancel: async () => { null; }, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { prepareTip: async () => ({}), @@ -75,17 +77,19 @@ describe("Tip CTA states", () => { onCancel: async () => { null; }, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { prepareTip: async () => - ({ - accepted: tipAccepted, - exchangeBaseUrl: "exchange url", - merchantBaseUrl: "merchant url", - tipAmountEffective: "EUR:1", - walletTipId: "tip_id", - } as PrepareTipResult as any), + ({ + accepted: tipAccepted, + exchangeBaseUrl: "exchange url", + merchantBaseUrl: "merchant url", + tipAmountEffective: "EUR:1", + walletTipId: "tip_id", + } as PrepareTipResult as any), acceptTip: async () => { tipAccepted = true; }, @@ -136,16 +140,18 @@ describe("Tip CTA states", () => { onCancel: async () => { null; }, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { prepareTip: async () => - ({ - exchangeBaseUrl: "exchange url", - merchantBaseUrl: "merchant url", - tipAmountEffective: "EUR:1", - walletTipId: "tip_id", - } as PrepareTipResult as any), + ({ + exchangeBaseUrl: "exchange url", + merchantBaseUrl: "merchant url", + tipAmountEffective: "EUR:1", + walletTipId: "tip_id", + } as PrepareTipResult as any), acceptTip: async () => ({}), } as any, ), @@ -191,17 +197,19 @@ describe("Tip CTA states", () => { onCancel: async () => { null; }, - onSuccess: async () => { null; }, + onSuccess: async () => { + null; + }, }, { prepareTip: async () => - ({ - accepted: true, - exchangeBaseUrl: "exchange url", - merchantBaseUrl: "merchant url", - tipAmountEffective: "EUR:1", - walletTipId: "tip_id", - } as PrepareTipResult as any), + ({ + accepted: true, + exchangeBaseUrl: "exchange url", + merchantBaseUrl: "merchant url", + tipAmountEffective: "EUR:1", + walletTipId: "tip_id", + } as PrepareTipResult as any), acceptTip: async () => ({}), } as any, ), diff --git a/packages/taler-wallet-webextension/src/cta/TransferCreate/index.ts b/packages/taler-wallet-webextension/src/cta/TransferCreate/index.ts index 5097380f6..820bffdea 100644 --- a/packages/taler-wallet-webextension/src/cta/TransferCreate/index.ts +++ b/packages/taler-wallet-webextension/src/cta/TransferCreate/index.ts @@ -29,10 +29,7 @@ export interface Props { onSuccess: (tx: string) => Promise<void>; } -export type State = - | State.Loading - | State.LoadingUriError - | State.Ready; +export type State = State.Loading | State.LoadingUriError | State.Ready; export namespace State { export interface Loading { diff --git a/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts b/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts index 03dfc8b18..d4ba18c12 100644 --- a/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts +++ b/packages/taler-wallet-webextension/src/cta/TransferCreate/state.ts @@ -31,7 +31,6 @@ export function useComponentState( TalerErrorDetail | undefined >(undefined); - async function accept(): Promise<void> { try { const resp = await api.initiatePeerPushPayment({ @@ -61,7 +60,7 @@ export function useComponentState( onInput: async (e) => setSubject(e), }, create: { - onClick: accept + onClick: accept, }, chosenAmount: amount, toBeReceived: amount, diff --git a/packages/taler-wallet-webextension/src/cta/TransferCreate/views.tsx b/packages/taler-wallet-webextension/src/cta/TransferCreate/views.tsx index 297ae4837..c6cff28ee 100644 --- a/packages/taler-wallet-webextension/src/cta/TransferCreate/views.tsx +++ b/packages/taler-wallet-webextension/src/cta/TransferCreate/views.tsx @@ -38,7 +38,6 @@ export function LoadingUriView({ error }: State.LoadingUriError): VNode { ); } - export function ReadyView({ subject, toBeReceived, diff --git a/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts b/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts index c6cc13b6c..0095910b5 100644 --- a/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts +++ b/packages/taler-wallet-webextension/src/cta/TransferPickup/state.ts @@ -68,7 +68,7 @@ export function useComponentState( const resp = await api.acceptPeerPushPayment({ peerPushPaymentIncomingId, }); - onSuccess(resp.transactionId) + onSuccess(resp.transactionId); } catch (e) { if (e instanceof TalerError) { setOperationError(e.errorDetail); diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts index fca69a669..1256bf469 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts +++ b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts @@ -40,8 +40,8 @@ export function useComponentStateFromParams( // get the first exchange with the currency as the default one const exchange = exchangeHookDep ? exchangeHookDep.exchanges.find( - (e) => e.currency === chosenAmount.currency, - ) + (e) => e.currency === chosenAmount.currency, + ) : undefined; /** * For the exchange selected, bring the status of the terms of service @@ -152,8 +152,8 @@ export function useComponentStateFromParams( const { state: termsState } = (!terms ? undefined : terms.hasError - ? undefined - : terms.response) || { state: undefined }; + ? undefined + : terms.response) || { state: undefined }; async function onAccept(accepted: boolean): Promise<void> { if (!termsState || !exchange) return; @@ -190,10 +190,10 @@ export function useComponentStateFromParams( //TODO: calculate based on exchange info const ageRestriction = ageRestrictionEnabled ? { - list: ageRestrictionOptions, - value: String(ageRestricted), - onChange: async (v: string) => setAgeRestricted(parseInt(v, 10)), - } + list: ageRestrictionOptions, + value: String(ageRestricted), + onChange: async (v: string) => setAgeRestricted(parseInt(v, 10)), + } : undefined; return { @@ -214,12 +214,12 @@ export function useComponentStateFromParams( tosProps: !termsState ? undefined : { - onAccept, - onReview: setReviewing, - reviewed: reviewed, - reviewing: reviewing, - terms: termsState, - }, + onAccept, + onReview: setReviewing, + reviewed: reviewed, + reviewing: reviewing, + terms: termsState, + }, mustAcceptFirst, cancel, }; @@ -339,9 +339,8 @@ export function useComponentStateFromURI( if (res.confirmTransferUrl) { document.location.href = res.confirmTransferUrl; } else { - onSuccess(res.transactionId) + onSuccess(res.transactionId); } - } catch (e) { if (e instanceof TalerError) { setWithdrawError(e); @@ -372,8 +371,8 @@ export function useComponentStateFromURI( const { state: termsState } = (!terms ? undefined : terms.hasError - ? undefined - : terms.response) || { state: undefined }; + ? undefined + : terms.response) || { state: undefined }; async function onAccept(accepted: boolean): Promise<void> { if (!termsState || !thisExchange) return; @@ -410,10 +409,10 @@ export function useComponentStateFromURI( //TODO: calculate based on exchange info const ageRestriction = ageRestrictionEnabled ? { - list: ageRestrictionOptions, - value: String(ageRestricted), - onChange: async (v: string) => setAgeRestricted(parseInt(v, 10)), - } + list: ageRestrictionOptions, + value: String(ageRestricted), + onChange: async (v: string) => setAgeRestricted(parseInt(v, 10)), + } : undefined; return { @@ -435,12 +434,12 @@ export function useComponentStateFromURI( tosProps: !termsState ? undefined : { - onAccept, - onReview: setReviewing, - reviewed: reviewed, - reviewing: reviewing, - terms: termsState, - }, + onAccept, + onReview: setReviewing, + reviewed: reviewed, + reviewing: reviewing, + terms: termsState, + }, mustAcceptFirst, cancel, }; diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts index a0c24a6bb..f614c1c8c 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts +++ b/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts @@ -68,7 +68,9 @@ describe("Withdraw CTA states", () => { cancel: async () => { null; }, - onSuccess: async () => { null }, + onSuccess: async () => { + null; + }, }, { listExchanges: async () => ({ exchanges }), @@ -109,7 +111,9 @@ describe("Withdraw CTA states", () => { cancel: async () => { null; }, - onSuccess: async () => { null }, + onSuccess: async () => { + null; + }, }, { listExchanges: async () => ({ exchanges }), @@ -152,7 +156,9 @@ describe("Withdraw CTA states", () => { cancel: async () => { null; }, - onSuccess: async () => { null }, + onSuccess: async () => { + null; + }, }, { listExchanges: async () => ({ exchanges }), @@ -163,10 +169,10 @@ describe("Withdraw CTA states", () => { }), getExchangeWithdrawalInfo: async (): Promise<ExchangeWithdrawDetails> => - ({ - withdrawalAmountRaw: "ARS:2", - withdrawalAmountEffective: "ARS:2", - } as any), + ({ + withdrawalAmountRaw: "ARS:2", + withdrawalAmountEffective: "ARS:2", + } as any), getExchangeTos: async (): Promise<GetExchangeTosResult> => ({ contentType: "text", content: "just accept", @@ -227,7 +233,9 @@ describe("Withdraw CTA states", () => { cancel: async () => { null; }, - onSuccess: async () => { null }, + onSuccess: async () => { + null; + }, }, { listExchanges: async () => ({ exchanges }), @@ -238,10 +246,10 @@ describe("Withdraw CTA states", () => { }), getExchangeWithdrawalInfo: async (): Promise<ExchangeWithdrawDetails> => - ({ - withdrawalAmountRaw: "ARS:2", - withdrawalAmountEffective: "ARS:2", - } as any), + ({ + withdrawalAmountRaw: "ARS:2", + withdrawalAmountEffective: "ARS:2", + } as any), getExchangeTos: async (): Promise<GetExchangeTosResult> => ({ contentType: "text", content: "just accept", diff --git a/packages/taler-wallet-webextension/src/wallet/Application.tsx b/packages/taler-wallet-webextension/src/wallet/Application.tsx index d2cbf440f..1ff29726b 100644 --- a/packages/taler-wallet-webextension/src/wallet/Application.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Application.tsx @@ -249,49 +249,65 @@ export function Application(): VNode { redirectTo(Pages.ctaWithdrawManual({ amount })) } cancel={() => redirectTo(Pages.balance)} - onSuccess={(tid:string) => redirectTo(Pages.balanceTransaction({ tid }))} + onSuccess={(tid: string) => + redirectTo(Pages.balanceTransaction({ tid })) + } /> <Route path={Pages.ctaRefund} component={RefundPage} cancel={() => redirectTo(Pages.balance)} - onSuccess={(tid:string) => redirectTo(Pages.balanceTransaction({ tid }))} + onSuccess={(tid: string) => + redirectTo(Pages.balanceTransaction({ tid })) + } /> <Route path={Pages.ctaTips} component={TipPage} onCancel={() => redirectTo(Pages.balance)} - onSuccess={(tid:string) => redirectTo(Pages.balanceTransaction({ tid }))} + onSuccess={(tid: string) => + redirectTo(Pages.balanceTransaction({ tid })) + } /> <Route path={Pages.ctaWithdraw} component={WithdrawPageFromURI} cancel={() => redirectTo(Pages.balance)} - onSuccess={(tid:string) => redirectTo(Pages.balanceTransaction({ tid }))} + onSuccess={(tid: string) => + redirectTo(Pages.balanceTransaction({ tid })) + } /> <Route path={Pages.ctaWithdrawManual.pattern} component={WithdrawPageFromParams} cancel={() => redirectTo(Pages.balance)} - onSuccess={(tid:string) => redirectTo(Pages.balanceTransaction({ tid }))} + onSuccess={(tid: string) => + redirectTo(Pages.balanceTransaction({ tid })) + } /> <Route path={Pages.ctaDeposit} component={DepositPageCTA} cancel={() => redirectTo(Pages.balance)} - onSuccess={(tid:string) => redirectTo(Pages.balanceTransaction({ tid }))} + onSuccess={(tid: string) => + redirectTo(Pages.balanceTransaction({ tid })) + } /> <Route path={Pages.ctaInvoiceCreate.pattern} component={InvoiceCreatePage} onClose={() => redirectTo(Pages.balance)} - onSuccess={(tid:string) => redirectTo(Pages.balanceTransaction({ tid }))} + onSuccess={(tid: string) => + redirectTo(Pages.balanceTransaction({ tid })) + } /> <Route path={Pages.ctaTransferCreate.pattern} component={TransferCreatePage} onClose={() => redirectTo(Pages.balance)} - onSuccess={(tid:string) => redirectTo(Pages.balanceTransaction({ tid }))} + onSuccess={(tid: string) => + redirectTo(Pages.balanceTransaction({ tid })) + } /> <Route path={Pages.ctaInvoicePay} @@ -300,13 +316,17 @@ export function Application(): VNode { redirectTo(Pages.ctaWithdrawManual({ amount })) } onClose={() => redirectTo(Pages.balance)} - onSuccess={(tid:string) => redirectTo(Pages.balanceTransaction({ tid }))} + onSuccess={(tid: string) => + redirectTo(Pages.balanceTransaction({ tid })) + } /> <Route path={Pages.ctaTransferPickup} component={TransferPickupPage} onClose={() => redirectTo(Pages.balance)} - onSuccess={(tid:string) => redirectTo(Pages.balanceTransaction({ tid }))} + onSuccess={(tid: string) => + redirectTo(Pages.balanceTransaction({ tid })) + } /> {/** diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx index 8318677e3..8e479f988 100644 --- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx @@ -634,7 +634,7 @@ export function TransactionView({ text={transaction.exchangeBaseUrl} kind="neutral" /> - {transaction.pending && ( /** pending is not-pay */ + {transaction.pending /** pending is not-pay */ && ( <Part title={<i18n.Translate>URI</i18n.Translate>} text={<ShowQrWithCopy text={transaction.talerUri} />} @@ -720,13 +720,13 @@ export function TransactionView({ text={transaction.exchangeBaseUrl} kind="neutral" /> - {/* {transaction.pending && ( //pending is not-received + {/* {transaction.pending && ( //pending is not-received )} */} - <Part - title={<i18n.Translate>URI</i18n.Translate>} - text={<ShowQrWithCopy text={transaction.talerUri} />} - kind="neutral" - /> + <Part + title={<i18n.Translate>URI</i18n.Translate>} + text={<ShowQrWithCopy text={transaction.talerUri} />} + kind="neutral" + /> <Part title={<i18n.Translate>Details</i18n.Translate>} text={ |