aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/popupEntryPoint.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2022-01-04 17:06:17 -0300
committerSebastian <sebasjm@gmail.com>2022-01-04 17:06:24 -0300
commit9f8139e09b21ec12f9b9ba4926ea80557698c559 (patch)
treedba5aacf50e89176bee35cfdd1002cc61c3f52e5 /packages/taler-wallet-webextension/src/popupEntryPoint.tsx
parent2e71117f59e0ae6106930e705ae6a54a9839281b (diff)
downloadwallet-core-9f8139e09b21ec12f9b9ba4926ea80557698c559.tar.xz
replace jest with mocha
Diffstat (limited to 'packages/taler-wallet-webextension/src/popupEntryPoint.tsx')
-rw-r--r--packages/taler-wallet-webextension/src/popupEntryPoint.tsx163
1 files changed, 88 insertions, 75 deletions
diff --git a/packages/taler-wallet-webextension/src/popupEntryPoint.tsx b/packages/taler-wallet-webextension/src/popupEntryPoint.tsx
index ac1872fb1..27372db5e 100644
--- a/packages/taler-wallet-webextension/src/popupEntryPoint.tsx
+++ b/packages/taler-wallet-webextension/src/popupEntryPoint.tsx
@@ -22,7 +22,7 @@
import { setupI18n } from "@gnu-taler/taler-util";
import { createHashHistory } from "history";
-import { render, h } from "preact";
+import { render, h, VNode, Fragment } from "preact";
import Router, { route, Route } from "preact-router";
import { useEffect } from "preact/hooks";
import { PopupBox } from "./components/styled";
@@ -39,6 +39,7 @@ import { ProviderDetailPage } from "./wallet/ProviderDetailPage";
import { SettingsPage } from "./popup/Settings";
import { TalerActionFound } from "./popup/TalerActionFound";
import { ExchangeAddPage } from "./wallet/ExchangeAddPage";
+import { IoCProviderForRuntime } from "./context/iocContext";
function main(): void {
try {
@@ -63,87 +64,99 @@ if (document.readyState === "loading") {
main();
}
-function Application() {
- const [talerActionUrl, setDismissed] = useTalerActionURL();
+function CheckTalerActionComponent(): VNode {
+ const [talerActionUrl] = useTalerActionURL();
useEffect(() => {
- if (talerActionUrl) route(Pages.cta);
+ if (talerActionUrl)
+ route(Pages.cta.replace(":action", encodeURIComponent(talerActionUrl)));
}, [talerActionUrl]);
+ return <Fragment />;
+}
+
+function Application() {
return (
<div>
<DevContextProvider>
- <WalletNavBar />
- <PopupBox>
- <Router history={createHashHistory()}>
- <Route path={Pages.dev} component={DeveloperPage} />
-
- <Route
- path={Pages.balance}
- component={BalancePage}
- goToWalletManualWithdraw={() =>
- goToWalletPage(Pages.manual_withdraw)
- }
- goToWalletDeposit={(currency: string) =>
- goToWalletPage(Pages.deposit.replace(":currency", currency))
- }
- />
- <Route path={Pages.settings} component={SettingsPage} />
- <Route
- path={Pages.cta}
- component={() => (
- <TalerActionFound
- url={talerActionUrl!}
- onDismiss={() => {
- setDismissed(true);
- route(Pages.balance);
- }}
- />
- )}
- />
-
- <Route
- path={Pages.transaction}
- component={({ tid }: { tid: string }) =>
- goToWalletPage(Pages.transaction.replace(":tid", tid))
- }
- />
-
- <Route path={Pages.history} component={HistoryPage} />
-
- <Route
- path={Pages.backup}
- component={BackupPage}
- onAddProvider={() => {
- route(Pages.provider_add);
- }}
- />
- <Route
- path={Pages.provider_detail}
- component={ProviderDetailPage}
- onBack={() => {
- route(Pages.backup);
- }}
- />
- <Route
- path={Pages.provider_add}
- component={ProviderAddPage}
- onBack={() => {
- route(Pages.backup);
- }}
- />
-
- <Route
- path={Pages.exchange_add}
- component={ExchangeAddPage}
- onBack={() => {
- route(Pages.balance);
- }}
- />
-
- <Route default component={Redirect} to={Pages.balance} />
- </Router>
- </PopupBox>
+ <IoCProviderForRuntime>
+ <WalletNavBar />
+ <CheckTalerActionComponent />
+ <PopupBox>
+ <Router history={createHashHistory()}>
+ <Route path={Pages.dev} component={DeveloperPage} />
+
+ <Route
+ path={Pages.balance}
+ component={BalancePage}
+ goToWalletManualWithdraw={() =>
+ goToWalletPage(Pages.manual_withdraw)
+ }
+ goToWalletDeposit={(currency: string) =>
+ goToWalletPage(Pages.deposit.replace(":currency", currency))
+ }
+ />
+ <Route path={Pages.settings} component={SettingsPage} />
+ <Route
+ path={Pages.cta}
+ component={function Action({ action }: { action: string }) {
+ const [, setDismissed] = useTalerActionURL();
+
+ return (
+ <TalerActionFound
+ url={decodeURIComponent(action)}
+ onDismiss={() => {
+ setDismissed(true);
+ route(Pages.balance);
+ }}
+ />
+ );
+ }}
+ />
+
+ <Route
+ path={Pages.transaction}
+ component={({ tid }: { tid: string }) =>
+ goToWalletPage(Pages.transaction.replace(":tid", tid))
+ }
+ />
+
+ <Route path={Pages.history} component={HistoryPage} />
+
+ <Route
+ path={Pages.backup}
+ component={BackupPage}
+ onAddProvider={() => {
+ route(Pages.provider_add);
+ }}
+ />
+ <Route
+ path={Pages.provider_detail}
+ component={ProviderDetailPage}
+ onBack={() => {
+ route(Pages.backup);
+ }}
+ />
+ <Route
+ path={Pages.provider_add}
+ component={ProviderAddPage}
+ onBack={() => {
+ route(Pages.backup);
+ }}
+ />
+
+ <Route
+ path={Pages.exchange_add}
+ component={ExchangeAddPage}
+ onBack={() => {
+ route(Pages.balance);
+ }}
+ />
+
+ <Route default component={Redirect} to={Pages.balance} />
+ </Router>
+ </PopupBox>
+ </IoCProviderForRuntime>
</DevContextProvider>
</div>
);