[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 08/19: no-fix: move out routing
From: |
gnunet |
Subject: |
[taler-wallet-core] 08/19: no-fix: move out routing |
Date: |
Wed, 07 Dec 2022 20:08:36 +0100 |
This is an automated email from the git hooks/post-receive script.
sebasjm pushed a commit to branch master
in repository wallet-core.
commit 0fa3b8ddb93e2d0352da82a6f2b07304ea239c28
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Wed Dec 7 10:59:12 2022 -0300
no-fix: move out routing
---
packages/demobank-ui/src/components/app.tsx | 4 ++--
packages/demobank-ui/src/pages/Routing.tsx | 28 ++++++++++++++++++++++
packages/demobank-ui/src/pages/home/index.tsx | 34 ++++-----------------------
3 files changed, 34 insertions(+), 32 deletions(-)
diff --git a/packages/demobank-ui/src/components/app.tsx
b/packages/demobank-ui/src/components/app.tsx
index 91410a485..35681a58c 100644
--- a/packages/demobank-ui/src/components/app.tsx
+++ b/packages/demobank-ui/src/components/app.tsx
@@ -1,13 +1,13 @@
import { h, FunctionalComponent } from "preact";
import { PageStateProvider } from "../context/pageState.js";
import { TranslationProvider } from "../context/translation.js";
-import { BankHome } from "../pages/home/index.js";
+import { Routing } from "../pages/Routing.js";
const App: FunctionalComponent = () => {
return (
<TranslationProvider>
<PageStateProvider>
- <BankHome />
+ <Routing />
</PageStateProvider>
</TranslationProvider>
);
diff --git a/packages/demobank-ui/src/pages/Routing.tsx
b/packages/demobank-ui/src/pages/Routing.tsx
new file mode 100644
index 000000000..cfc6a4bd8
--- /dev/null
+++ b/packages/demobank-ui/src/pages/Routing.tsx
@@ -0,0 +1,28 @@
+import { createHashHistory } from "history";
+import { h, VNode } from "preact";
+import Router, { route, Route } from "preact-router";
+import { useEffect } from "preact/hooks";
+import {
+ AccountPage,
+ PublicHistoriesPage,
+ RegistrationPage,
+} from "./home/index.js";
+
+export function Routing(): VNode {
+ const history = createHashHistory();
+ return (
+ <Router history={history}>
+ <Route path="/public-accounts" component={PublicHistoriesPage} />
+ <Route path="/register" component={RegistrationPage} />
+ <Route path="/account/:id*" component={AccountPage} />
+ <Route default component={Redirect} to="/account" />
+ </Router>
+ );
+}
+
+function Redirect({ to }: { to: string }): VNode {
+ useEffect(() => {
+ route(to, true);
+ }, []);
+ return <div>being redirected to {to}</div>;
+}
diff --git a/packages/demobank-ui/src/pages/home/index.tsx
b/packages/demobank-ui/src/pages/home/index.tsx
index 9927f965c..64ceedf66 100644
--- a/packages/demobank-ui/src/pages/home/index.tsx
+++ b/packages/demobank-ui/src/pages/home/index.tsx
@@ -2079,7 +2079,7 @@ function PublicHistories(Props: any): VNode {
);
}
-function PublicHistoriesPage(): VNode {
+export function PublicHistoriesPage(): VNode {
const { pageState, pageStateSetter } = usePageContext();
// const { i18n } = useTranslationContext();
return (
@@ -2104,7 +2104,7 @@ function PublicHistoriesPage(): VNode {
);
}
-function RegistrationPage(): VNode {
+export function RegistrationPage(): VNode {
const { i18n } = useTranslationContext();
if (!bankUiSettings.allowRegistrations) {
return (
@@ -2120,7 +2120,7 @@ function RegistrationPage(): VNode {
);
}
-function AccountPage(): VNode {
+export function AccountPage(): VNode {
const [backendState, backendStateSetter] = useBackendState();
const { i18n } = useTranslationContext();
const { pageState, pageStateSetter } = usePageContext();
@@ -2129,10 +2129,7 @@ function AccountPage(): VNode {
return (
<BankFrame>
<h1 class="nav">{i18n.str`Welcome to ${bankUiSettings.bankName}!`}</h1>
- <LoginForm
- pageStateSetter={pageStateSetter}
- backendStateSetter={backendStateSetter}
- />
+ <LoginForm />
</BankFrame>
);
}
@@ -2162,26 +2159,3 @@ function AccountPage(): VNode {
</SWRWithCredentials>
);
}
-
-function Redirect({ to }: { to: string }): VNode {
- useEffect(() => {
- route(to, true);
- }, []);
- return <div>being redirected to {to}</div>;
-}
-
-/**
- * If the user is logged in, it displays
- * the balance, otherwise it offers to login.
- */
-export function BankHome(): VNode {
- const history = createHashHistory();
- return (
- <Router history={history}>
- <Route path="/public-accounts" component={PublicHistoriesPage} />
- <Route path="/register" component={RegistrationPage} />
- <Route path="/account/:id*" component={AccountPage} />
- <Route default component={Redirect} to="/account" />
- </Router>
- );
-}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-wallet-core] 03/19: fix: remove red style when input is invalid, (continued)
- [taler-wallet-core] 03/19: fix: remove red style when input is invalid, gnunet, 2022/12/07
- [taler-wallet-core] 04/19: no-fix: move out useBackend hook, gnunet, 2022/12/07
- [taler-wallet-core] 02/19: no-fix: move pagestate provider to app component and move some common hooks to web-utils, gnunet, 2022/12/07
- [taler-wallet-core] 13/19: also listen for tab title change, gnunet, 2022/12/07
- [taler-wallet-core] 01/19: pretty, gnunet, 2022/12/07
- [taler-wallet-core] 05/19: fix: empty form should not allow the "send" button, gnunet, 2022/12/07
- [taler-wallet-core] 19/19: no-fix: user logger instead of console.log, gnunet, 2022/12/07
- [taler-wallet-core] 11/19: no-fix: removing unused showPublicHistories, gnunet, 2022/12/07
- [taler-wallet-core] 15/19: fix jsx config, gnunet, 2022/12/07
- [taler-wallet-core] 14/19: fix: updating the title is better that location.hash, gnunet, 2022/12/07
- [taler-wallet-core] 08/19: no-fix: move out routing,
gnunet <=
- [taler-wallet-core] 16/19: no-fix: remove unused, gnunet, 2022/12/07
- [taler-wallet-core] 12/19: no-fix: moved out AccountPage, gnunet, 2022/12/07
- [taler-wallet-core] 07/19: fix: show error message on login and registration form, prevent saving password on localstorage, gnunet, 2022/12/07
- [taler-wallet-core] 18/19: feature: useLocalStorage also update when the localStorage has been updated from other window, gnunet, 2022/12/07
- [taler-wallet-core] 06/19: fix: better loading page while waiting for server response, gnunet, 2022/12/07
- [taler-wallet-core] 17/19: no-fix: remove 'any' and login status is taken from backend, gnunet, 2022/12/07
- [taler-wallet-core] 09/19: no-fix: moving out public histories page, gnunet, 2022/12/07
- [taler-wallet-core] 10/19: no-fix: moving out registration page, gnunet, 2022/12/07