diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet/Application.tsx')
-rw-r--r-- | packages/taler-wallet-webextension/src/wallet/Application.tsx | 80 |
1 files changed, 69 insertions, 11 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/Application.tsx b/packages/taler-wallet-webextension/src/wallet/Application.tsx index 62a519f06..893122c0f 100644 --- a/packages/taler-wallet-webextension/src/wallet/Application.tsx +++ b/packages/taler-wallet-webextension/src/wallet/Application.tsx @@ -23,7 +23,9 @@ import { Amounts, TalerUri, + TalerUriAction, TranslatedString, + parseTalerUri, stringifyTalerUri, } from "@gnu-taler/taler-util"; import { @@ -83,6 +85,8 @@ import { TransactionPage } from "./Transaction.js"; import { WelcomePage } from "./Welcome.js"; import { WalletActivity } from "../components/WalletActivity.js"; import { EnabledBySettings } from "../components/EnabledBySettings.js"; +import { DevExperimentPage } from "../cta/DevExperiment/index.js"; +import { ConfirmAddExchangeView } from "./AddExchange/views.js"; export function Application(): VNode { const { i18n } = useTranslationContext(); @@ -174,6 +178,27 @@ export function Application(): VNode { )} /> <Route + path={Pages.searchHistory.pattern} + component={({ currency }: { currency?: string }) => ( + <WalletTemplate path="balance" goToTransaction={redirectToTxInfo} goToURL={redirectToURL}> + <HistoryPage + currency={currency} + search + goToWalletDeposit={(currency: string) => + redirectTo(Pages.sendCash({ amount: `${currency}:0` })) + } + goToWalletManualWithdraw={(currency?: string) => + redirectTo( + Pages.receiveCash({ + amount: !currency ? undefined : `${currency}:0`, + }), + ) + } + /> + </WalletTemplate> + )} + /> + <Route path={Pages.sendCash.pattern} component={({ amount }: { amount?: string }) => ( <WalletTemplate path="balance" goToURL={redirectToURL}> @@ -497,7 +522,40 @@ export function Application(): VNode { </CallToActionTemplate> )} /> - + <Route + path={Pages.ctaExperiment} + component={({ talerUri }: { talerUri: string }) => ( + <CallToActionTemplate title={i18n.str`Development experiment`}> + <DevExperimentPage + talerExperimentUri={decodeURIComponent(talerUri)} + onCancel={() => redirectTo(Pages.balanceHistory({}))} + onSuccess={() => redirectTo(Pages.balanceHistory({}))} + /> + </CallToActionTemplate> + )} + /> + <Route + path={Pages.ctaAddExchange} + component={({ talerUri }: { talerUri: string }) => { + const tUri = parseTalerUri(decodeURIComponent(talerUri)) + const baseUrl = tUri?.type === TalerUriAction.AddExchange ? tUri.exchangeBaseUrl : undefined + if (!baseUrl) { + redirectTo(Pages.balanceHistory({})) + return <div> + invalid url {talerUri} + </div> + } + return <CallToActionTemplate title={i18n.str`Add exchange`}> + <ConfirmAddExchangeView + url={baseUrl} + status="confirm" + error={undefined} + onCancel={() => redirectTo(Pages.balanceHistory({}))} + onConfirm={() => redirectTo(Pages.balanceHistory({}))} + /> + </CallToActionTemplate> + }} + /> {/** * NOT FOUND * all redirects should be at the end @@ -531,17 +589,17 @@ function Redirect({ to }: { to: string }): null { return null; } -function matchesRoute(url: string, route: string): boolean { - type MatcherFunc = ( - url: string, - route: string, - opts: any, - ) => Record<string, string> | false; +// function matchesRoute(url: string, route: string): boolean { +// type MatcherFunc = ( +// url: string, +// route: string, +// opts: any, +// ) => Record<string, string> | false; - const internalPreactMatcher: MatcherFunc = (Router as any).exec; - const result = internalPreactMatcher(url, route, {}); - return !result ? false : true; -} +// const internalPreactMatcher: MatcherFunc = (Router as any).exec; +// const result = internalPreactMatcher(url, route, {}); +// return !result ? false : true; +// } function CallToActionTemplate({ title, |