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/CopyButton.tsx | 4 +- packages/demobank-ui/src/components/Routing.tsx | 66 +++++- .../src/components/Transactions/state.ts | 2 +- packages/demobank-ui/src/pages/BankFrame.tsx | 227 +++++++++++---------- .../src/pages/PaytoWireTransferForm.tsx | 111 +--------- .../demobank-ui/src/pages/WalletWithdrawForm.tsx | 70 +------ .../src/pages/WithdrawalConfirmationQuestion.tsx | 8 +- 7 files changed, 193 insertions(+), 295 deletions(-) (limited to 'packages/demobank-ui') diff --git a/packages/demobank-ui/src/components/CopyButton.tsx b/packages/demobank-ui/src/components/CopyButton.tsx index 97ccbf2bf..b36de770e 100644 --- a/packages/demobank-ui/src/components/CopyButton.tsx +++ b/packages/demobank-ui/src/components/CopyButton.tsx @@ -45,14 +45,14 @@ export function CopyButton({ getContent }: { getContent: () => string }): VNode if (!copied) { return ( - ); } return (
-
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"); + }} + /> + } + }} /> */ -import { Logger, PaytoUriIBAN, TranslatedString, parsePaytoUri, stringifyPaytoUri } from "@gnu-taler/taler-util"; +import { Amounts, Logger, PaytoUriIBAN, TranslatedString, parsePaytoUri, stringifyPaytoUri } from "@gnu-taler/taler-util"; import { useNotifications, useTranslationContext } from "@gnu-taler/web-util/browser"; import { ComponentChildren, Fragment, h, VNode } from "preact"; import { StateUpdater, useEffect, useState } from "preact/hooks"; @@ -25,6 +25,7 @@ import { bankUiSettings } from "../settings.js"; import { useSettings } from "../hooks/settings.js"; import { CopyButton, CopyIcon } from "../components/CopyButton.js"; import logo from "../assets/logo-2021.svg"; +import { useAccountDetails } from "../hooks/access.js"; const IS_PUBLIC_ACCOUNT_ENABLED = false; const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined; @@ -63,7 +64,9 @@ function MaybeBusinessButton({ export function BankFrame({ children, goToBusinessAccount, + account, }: { + account: string | undefined, children: ComponentChildren; goToBusinessAccount?: () => void; }): VNode { @@ -122,123 +125,118 @@ export function BankFrame({ {open && - -