summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/wallet/Application.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet/Application.tsx')
-rw-r--r--packages/taler-wallet-webextension/src/wallet/Application.tsx65
1 files changed, 38 insertions, 27 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/Application.tsx b/packages/taler-wallet-webextension/src/wallet/Application.tsx
index 4a5ef30eb..2b03bb947 100644
--- a/packages/taler-wallet-webextension/src/wallet/Application.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Application.tsx
@@ -20,7 +20,11 @@
* @author sebasjm
*/
-import { TranslatedString } from "@gnu-taler/taler-util";
+import {
+ TalerUriAction,
+ TranslatedString,
+ parseTalerUri,
+} from "@gnu-taler/taler-util";
import { createHashHistory } from "history";
import { ComponentChildren, Fragment, h, VNode } from "preact";
import { route, Route, Router } from "preact-router";
@@ -55,7 +59,12 @@ import {
WithdrawPageFromParams,
WithdrawPageFromURI,
} from "../cta/Withdraw/index.js";
-import { Pages, WalletNavBar, WalletNavBarOptions } from "../NavigationBar.js";
+import {
+ Pages,
+ WalletNavBar,
+ WalletNavBarOptions,
+ getPathnameForTalerURI,
+} from "../NavigationBar.js";
import { platform } from "../platform/foreground.js";
import CloseIcon from "../svg/close_24px.svg";
import { AddBackupProviderPage } from "./AddBackupProvider/index.js";
@@ -286,11 +295,21 @@ export function Application(): VNode {
* CALL TO ACTION
*/}
<Route
+ path={Pages.defaultCta.pattern}
+ component={({ uri }: { uri: string }) => {
+ const path = getPathnameForTalerURI(uri);
+ if (!path) {
+ return <Redirect to={Pages.balance} />;
+ }
+ return <Redirect to={path} />;
+ }}
+ />
+ <Route
path={Pages.ctaPay}
- component={({ talerPayUri }: { talerPayUri: string }) => (
+ component={({ talerUri }: { talerUri: string }) => (
<CallToActionTemplate title={i18n.str`Digital cash payment`}>
<PaymentPage
- talerPayUri={decodeURIComponent(talerPayUri)}
+ talerPayUri={decodeURIComponent(talerUri)}
goToWalletManualWithdraw={(amount?: string) =>
redirectTo(Pages.receiveCash({ amount }))
}
@@ -304,14 +323,10 @@ export function Application(): VNode {
/>
<Route
path={Pages.ctaPayTemplate}
- component={({
- talerPayTemplateUri,
- }: {
- talerPayTemplateUri: string;
- }) => (
+ component={({ talerUri }: { talerUri: string }) => (
<CallToActionTemplate title={i18n.str`Digital cash payment`}>
<PaymentTemplatePage
- talerTemplateUri={decodeURIComponent(talerPayTemplateUri)}
+ talerTemplateUri={decodeURIComponent(talerUri)}
goToWalletManualWithdraw={(amount?: string) =>
redirectTo(Pages.receiveCash({ amount }))
}
@@ -325,10 +340,10 @@ export function Application(): VNode {
/>
<Route
path={Pages.ctaRefund}
- component={({ talerRefundUri }: { talerRefundUri: string }) => (
+ component={({ talerUri }: { talerUri: string }) => (
<CallToActionTemplate title={i18n.str`Digital cash refund`}>
<RefundPage
- talerRefundUri={decodeURIComponent(talerRefundUri)}
+ talerRefundUri={decodeURIComponent(talerUri)}
cancel={() => redirectTo(Pages.balance)}
onSuccess={(tid: string) =>
redirectTo(Pages.balanceTransaction({ tid }))
@@ -339,10 +354,10 @@ export function Application(): VNode {
/>
<Route
path={Pages.ctaTips}
- component={({ talerTipUri }: { talerTipUri: string }) => (
+ component={({ talerUri }: { talerUri: string }) => (
<CallToActionTemplate title={i18n.str`Digital cash tip`}>
<TipPage
- talerTipUri={decodeURIComponent(talerTipUri)}
+ talerTipUri={decodeURIComponent(talerUri)}
onCancel={() => redirectTo(Pages.balance)}
onSuccess={(tid: string) =>
redirectTo(Pages.balanceTransaction({ tid }))
@@ -353,14 +368,10 @@ export function Application(): VNode {
/>
<Route
path={Pages.ctaWithdraw}
- component={({
- talerWithdrawUri,
- }: {
- talerWithdrawUri: string;
- }) => (
+ component={({ talerUri }: { talerUri: string }) => (
<CallToActionTemplate title={i18n.str`Digital cash withdrawal`}>
<WithdrawPageFromURI
- talerWithdrawUri={decodeURIComponent(talerWithdrawUri)}
+ talerWithdrawUri={decodeURIComponent(talerUri)}
cancel={() => redirectTo(Pages.balance)}
onSuccess={(tid: string) =>
redirectTo(Pages.balanceTransaction({ tid }))
@@ -387,15 +398,15 @@ export function Application(): VNode {
path={Pages.ctaDeposit}
component={({
amount,
- talerDepositUri,
+ talerUri,
}: {
amount: string;
- talerDepositUri: string;
+ talerUri: string;
}) => (
<CallToActionTemplate title={i18n.str`Digital cash deposit`}>
<DepositPageCTA
amountStr={amount}
- talerDepositUri={decodeURIComponent(talerDepositUri)}
+ talerDepositUri={decodeURIComponent(talerUri)}
cancel={() => redirectTo(Pages.balance)}
onSuccess={(tid: string) =>
redirectTo(Pages.balanceTransaction({ tid }))
@@ -434,10 +445,10 @@ export function Application(): VNode {
/>
<Route
path={Pages.ctaInvoicePay}
- component={({ talerPayPullUri }: { talerPayPullUri: string }) => (
+ component={({ talerUri }: { talerUri: string }) => (
<CallToActionTemplate title={i18n.str`Digital cash invoice`}>
<InvoicePayPage
- talerPayPullUri={decodeURIComponent(talerPayPullUri)}
+ talerPayPullUri={decodeURIComponent(talerUri)}
goToWalletManualWithdraw={(amount?: string) =>
redirectTo(Pages.receiveCash({ amount }))
}
@@ -451,10 +462,10 @@ export function Application(): VNode {
/>
<Route
path={Pages.ctaTransferPickup}
- component={({ talerPayPushUri }: { talerPayPushUri: string }) => (
+ component={({ talerUri }: { talerUri: string }) => (
<CallToActionTemplate title={i18n.str`Digital cash transfer`}>
<TransferPickupPage
- talerPayPushUri={decodeURIComponent(talerPayPushUri)}
+ talerPayPushUri={decodeURIComponent(talerUri)}
onClose={() => redirectTo(Pages.balance)}
onSuccess={(tid: string) =>
redirectTo(Pages.balanceTransaction({ tid }))