From 24cac493dded00ef40e0e30a0d2263e4f35c3e29 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 4 Jan 2023 11:24:58 -0300 Subject: fix #7522 --- .../src/popup/Application.tsx | 246 ++++++++++++--------- 1 file changed, 137 insertions(+), 109 deletions(-) (limited to 'packages/taler-wallet-webextension/src/popup') diff --git a/packages/taler-wallet-webextension/src/popup/Application.tsx b/packages/taler-wallet-webextension/src/popup/Application.tsx index 8186c6790..9cae0d048 100644 --- a/packages/taler-wallet-webextension/src/popup/Application.tsx +++ b/packages/taler-wallet-webextension/src/popup/Application.tsx @@ -21,7 +21,7 @@ */ import { createHashHistory } from "history"; -import { Fragment, h, VNode } from "preact"; +import { ComponentChildren, Fragment, h, VNode } from "preact"; import Router, { route, Route } from "preact-router"; import { Match } from "preact-router/match"; import { useEffect, useState } from "preact/hooks"; @@ -34,15 +34,28 @@ import { useTranslationContext, } from "../context/translation.js"; import { useTalerActionURL } from "../hooks/useTalerActionURL.js"; -import { Pages, PopupNavBar } from "../NavigationBar.js"; +import { PopupNavBarOptions, Pages, PopupNavBar } from "../NavigationBar.js"; import { platform } from "../platform/api.js"; import { BackupPage } from "../wallet/BackupPage.js"; import { ProviderDetailPage } from "../wallet/ProviderDetailPage.js"; import { BalancePage } from "./BalancePage.js"; import { TalerActionFound } from "./TalerActionFound.js"; -function CheckTalerActionComponent(): VNode { - const [action] = useTalerActionURL(); +export function Application(): VNode { + return ( + + + + + + + + ); +} +function ApplicationView(): VNode { + const hash_history = createHashHistory(); + + const [action, setDismissed] = useTalerActionURL(); const actionUri = action?.uri; @@ -52,116 +65,110 @@ function CheckTalerActionComponent(): VNode { } }, [actionUri]); - return ; -} + async function redirectToTxInfo(tid: string): Promise { + redirectTo(Pages.balanceTransaction({ tid })); + } -export function Application(): VNode { - const hash_history = createHashHistory(); return ( - - - {({ devMode }: { devMode: boolean }) => ( - - - redirectTo(Pages.balanceTransaction({ tid })) + + ( + + redirectTo(Pages.receiveCash({}))} + goToWalletDeposit={(currency: string) => + redirectTo(Pages.sendCash({ amount: `${currency}:0` })) + } + goToWalletHistory={(currency: string) => + redirectTo(Pages.balanceHistory({ currency })) } /> - - {({ path }: { path: string }) => } - - - - - - redirectTo(Pages.receiveCash({})) - } - goToWalletDeposit={(currency: string) => - redirectTo(Pages.sendCash({ amount: `${currency}:0` })) - } - goToWalletHistory={(currency: string) => - redirectTo(Pages.balanceHistory({ currency })) - } - /> - - { - setDismissed(true); - return redirectTo(Pages.balance); - }} - /> - ); - }} - /> - - redirectTo(Pages.backupProviderAdd)} - /> - redirectTo(Pages.backup)} - /> - - - - - - - - - - - - - - - - - - + )} - - + /> + + + { + setDismissed(true); + return redirectTo(Pages.balance); + }} + /> + + ); + }} + /> + + ( + + redirectTo(Pages.backupProviderAdd)} + /> + + )} + /> + ( + + + redirectTo(`${Pages.ctaPay}?talerPayUri=${uri}`) + } + onWithdraw={(amount: string) => + redirectTo(Pages.receiveCash({ amount })) + } + pid={pid} + onBack={() => redirectTo(Pages.backup)} + /> + + )} + /> + + + + + + + + + + + + + + + + + ); } @@ -195,3 +202,24 @@ function Redirect({ to }: { to: string }): null { }); return null; } + +function PopupTemplate({ + path, + children, + goToTransaction, +}: { + path?: PopupNavBarOptions; + children: ComponentChildren; + goToTransaction?: (id: string) => Promise; +}): VNode { + return ( + + {/* */} + {goToTransaction ? ( + + ) : undefined} + + {children} + + ); +} -- cgit v1.2.3