diff options
author | Sebastian <sebasjm@gmail.com> | 2022-09-16 16:03:58 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-09-16 16:03:58 -0300 |
commit | 59d235e8d29159bc8caccf8bee6a2bca8b0b90dc (patch) | |
tree | 551261c860b1989dc0b1a05ddcfd53d20e561626 /packages/taler-wallet-webextension/src/cta/Tip | |
parent | 6ddb2de84245ae3914c92b2b2eb7399e7f04500e (diff) | |
download | wallet-core-59d235e8d29159bc8caccf8bee6a2bca8b0b90dc.tar.xz |
redirect after success #7357
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/Tip')
3 files changed, 30 insertions, 22 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Tip/index.ts b/packages/taler-wallet-webextension/src/cta/Tip/index.ts index 4bdad0808..157cf7d4e 100644 --- a/packages/taler-wallet-webextension/src/cta/Tip/index.ts +++ b/packages/taler-wallet-webextension/src/cta/Tip/index.ts @@ -32,6 +32,7 @@ import { export interface Props { talerTipUri?: string; onCancel: () => Promise<void>; + onSuccess: (tx: string) => Promise<void>; } export type State = diff --git a/packages/taler-wallet-webextension/src/cta/Tip/state.ts b/packages/taler-wallet-webextension/src/cta/Tip/state.ts index 333337e78..a3adafe53 100644 --- a/packages/taler-wallet-webextension/src/cta/Tip/state.ts +++ b/packages/taler-wallet-webextension/src/cta/Tip/state.ts @@ -21,7 +21,7 @@ import * as wxApi from "../../wxApi.js"; import { Props, State } from "./index.js"; export function useComponentState( - { talerTipUri, onCancel }: Props, + { talerTipUri, onCancel, onSuccess }: Props, api: typeof wxApi, ): State { const [tipIgnored, setTipIgnored] = useState(false); @@ -48,8 +48,11 @@ export function useComponentState( const { tip } = tipInfo.response; const doAccept = async (): Promise<void> => { - await api.acceptTip({ walletTipId: tip.walletTipId }); + const res = await api.acceptTip({ walletTipId: tip.walletTipId }); + + //FIX: this may not be seen since we are moving to the success also tipInfo.retry(); + 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 4895fcc7f..eeb39c8aa 100644 --- a/packages/taler-wallet-webextension/src/cta/Tip/test.ts +++ b/packages/taler-wallet-webextension/src/cta/Tip/test.ts @@ -34,6 +34,7 @@ describe("Tip CTA states", () => { onCancel: async () => { null; }, + onSuccess: async () => { null; }, }, { prepareTip: async () => ({}), @@ -74,16 +75,17 @@ describe("Tip CTA states", () => { onCancel: 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; }, @@ -134,15 +136,16 @@ describe("Tip CTA states", () => { onCancel: 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, ), @@ -188,16 +191,17 @@ describe("Tip CTA states", () => { onCancel: 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, ), |