From b3c747151bb3f50d28bf6205cafa4b7dd6ae2b1c Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 21 Sep 2023 09:41:07 -0300 Subject: more ui --- packages/demobank-ui/src/components/Routing.tsx | 66 +++++++++++++++++++++---- 1 file changed, 56 insertions(+), 10 deletions(-) (limited to 'packages/demobank-ui/src/components/Routing.tsx') diff --git a/packages/demobank-ui/src/components/Routing.tsx b/packages/demobank-ui/src/components/Routing.tsx index 2c532e863..890058a9b 100644 --- a/packages/demobank-ui/src/components/Routing.tsx +++ b/packages/demobank-ui/src/components/Routing.tsx @@ -24,12 +24,50 @@ import { HomePage, WithdrawalOperationPage } from "../pages/HomePage.js"; import { PublicHistoriesPage } from "../pages/PublicHistoriesPage.js"; import { RegistrationPage } from "../pages/RegistrationPage.js"; import { Test } from "../pages/Test.js"; +import { useBackendContext } from "../context/backend.js"; +import { LoginForm } from "../pages/LoginForm.js"; +import { AdminPage } from "../pages/AdminPage.js"; export function Routing(): VNode { const history = createHashHistory(); + const backend = useBackendContext(); + + if (backend.state.status === "loggedOut") { + return { + route("/business"); + }} + > + + ( + { + route("/register"); + }} + /> + )} + /> + ( + { + route("/account"); + }} + /> + )} + /> + + + + } + const isAdmin = backend.state.isUserAdministrator return ( { route("/business"); }} @@ -69,16 +107,24 @@ export function Routing(): VNode { /> ( - { - route(`/operation/${wopid}`); - }} - onRegister={() => { - route("/register"); - }} - /> - )} + component={() => { + if (isAdmin) { + return { + route("/register"); + }} + />; + } else { + return { + route(`/operation/${wopid}`); + }} + onRegister={() => { + route("/register"); + }} + /> + } + }} />