aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/popupEntryPoint.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2021-06-16 18:21:03 -0300
committerSebastian <sebasjm@gmail.com>2021-06-16 18:21:15 -0300
commit0b4976601fe2ecb0462fe72ae188b5cbba06d9cc (patch)
tree93f18c88d754430d2c1261109c1e9b6c1ac7a500 /packages/taler-wallet-webextension/src/popupEntryPoint.tsx
parentd58945c830a33910dd93bc159c1ffe5d490df846 (diff)
downloadwallet-core-0b4976601fe2ecb0462fe72ae188b5cbba06d9cc.tar.xz
components renaming to follow react pattern
Diffstat (limited to 'packages/taler-wallet-webextension/src/popupEntryPoint.tsx')
-rw-r--r--packages/taler-wallet-webextension/src/popupEntryPoint.tsx43
1 files changed, 13 insertions, 30 deletions
diff --git a/packages/taler-wallet-webextension/src/popupEntryPoint.tsx b/packages/taler-wallet-webextension/src/popupEntryPoint.tsx
index 926ae7aa7..6cc781aa7 100644
--- a/packages/taler-wallet-webextension/src/popupEntryPoint.tsx
+++ b/packages/taler-wallet-webextension/src/popupEntryPoint.tsx
@@ -23,13 +23,17 @@
import { render } from "preact";
import { setupI18n } from "@gnu-taler/taler-util";
import { strings } from "./i18n/strings";
-import { useEffect, useState } from "preact/hooks";
+import { useEffect } from "preact/hooks";
import {
- actionForTalerUri, findTalerUriInActiveTab, Pages, WalletBalanceView, WalletDebug, WalletHistory,
- WalletNavBar, WalletSettings, WalletTransaction, WalletTransactionView
-} from "./popup/popup";
+ Pages, WalletNavBar} from "./popup/popup";
+import { HistoryPage } from "./popup/History";
+import { DebugPage } from "./popup/Debug";
+import { SettingsPage } from "./popup/Settings";
+import { TransactionPage } from "./popup/Transaction";
+import { BalancePage } from "./popup/Balance";
import Match from "preact-router/match";
import Router, { route, Route } from "preact-router";
+import { useTalerActionURL } from "./hooks/useTalerActionURL";
// import { Application } from "./Application";
function main(): void {
@@ -53,25 +57,6 @@ if (document.readyState === "loading") {
main();
}
-function useTalerActionURL(): [string | undefined, (s: boolean) => void] {
- const [talerActionUrl, setTalerActionUrl] = useState<string | undefined>(
- undefined,
- );
- const [dismissed, setDismissed] = useState(false);
- useEffect(() => {
- async function check(): Promise<void> {
- const talerUri = await findTalerUriInActiveTab();
- if (talerUri) {
- const actionUrl = actionForTalerUri(talerUri);
- setTalerActionUrl(actionUrl);
- }
- }
- check();
- }, []);
- const url = dismissed ? undefined : talerActionUrl
- return [url, setDismissed]
-}
-
interface Props {
url: string;
onDismiss: (s: boolean) => void;
@@ -105,11 +90,11 @@ function Application() {
<Match>{({ path }: any) => <WalletNavBar current={path} />}</Match >
<div style={{ margin: "1em", width: 400 }}>
<Router>
- <Route path={Pages.balance} component={WalletBalanceView} />
- <Route path={Pages.settings} component={WalletSettings} />
- <Route path={Pages.debug} component={WalletDebug} />
- <Route path={Pages.history} component={WalletHistory} />
- <Route path={Pages.transaction} component={WalletTransaction} />
+ <Route path={Pages.balance} component={BalancePage} />
+ <Route path={Pages.settings} component={SettingsPage} />
+ <Route path={Pages.debug} component={DebugPage} />
+ <Route path={Pages.history} component={HistoryPage} />
+ <Route path={Pages.transaction} component={TransactionPage} />
<Route default component={Redirect} to={Pages.balance} />
</Router>
</div>
@@ -118,8 +103,6 @@ function Application() {
}
-
-
function Redirect({ to }: { to: string }): null {
useEffect(() => {
route(to, true)