From 0fa3b8ddb93e2d0352da82a6f2b07304ea239c28 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 7 Dec 2022 10:59:12 -0300 Subject: no-fix: move out routing --- packages/demobank-ui/src/pages/Routing.tsx | 28 ++++++++++++++++++++++ packages/demobank-ui/src/pages/home/index.tsx | 34 ++++----------------------- 2 files changed, 32 insertions(+), 30 deletions(-) create mode 100644 packages/demobank-ui/src/pages/Routing.tsx (limited to 'packages/demobank-ui/src/pages') 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 ( + + + + + + + ); +} + +function Redirect({ to }: { to: string }): VNode { + useEffect(() => { + route(to, true); + }, []); + return
being redirected to {to}
; +} 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 (

{i18n.str`Welcome to ${bankUiSettings.bankName}!`}

- +
); } @@ -2162,26 +2159,3 @@ function AccountPage(): VNode { ); } - -function Redirect({ to }: { to: string }): VNode { - useEffect(() => { - route(to, true); - }, []); - return
being redirected to {to}
; -} - -/** - * If the user is logged in, it displays - * the balance, otherwise it offers to login. - */ -export function BankHome(): VNode { - const history = createHashHistory(); - return ( - - - - - - - ); -} -- cgit v1.2.3