taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 5fefbf3179e828dbbed06ffdb66662a92501b7be
parent eef5b37306ed430fe6140c1b332e1f001fc0b969
Author: Sebastian <sebasjm@gmail.com>
Date:   Thu,  4 Jul 2024 10:05:09 -0300

new location api

Diffstat:
Mpackages/aml-backoffice-ui/src/Routing.tsx | 27+++++++++++----------------
Mpackages/bank-ui/src/Routing.tsx | 29+++++++++++++----------------
2 files changed, 24 insertions(+), 32 deletions(-)

diff --git a/packages/aml-backoffice-ui/src/Routing.tsx b/packages/aml-backoffice-ui/src/Routing.tsx @@ -62,15 +62,14 @@ function PublicRounting(): VNode { // const [notification, notify, handleError] = useLocalNotification(); const session = useOfficer(); - if (location === undefined) { - if (session.state !== "ready") { - return <HandleAccountNotReady officer={session}/>; - } else { - return <div /> - } - } - switch (location.name) { + case undefined: { + if (session.state !== "ready") { + return <HandleAccountNotReady officer={session} />; + } else { + return <div />; + } + } case "config": { return ( <Fragment> @@ -120,11 +119,10 @@ function PrivateRouting(): VNode { } }, [location]); - if (location === undefined) { - return <Fragment />; - } - switch (location.name) { + case undefined: { + return <Fragment />; + } case "account": { return <Officer />; } @@ -133,10 +131,7 @@ function PrivateRouting(): VNode { } case "caseUpdate": { return ( - <CaseUpdate - account={location.values.cid} - type={location.values.type} - /> + <CaseUpdate account={location.values.cid} type={location.values.type} /> ); } case "caseNew": { diff --git a/packages/bank-ui/src/Routing.tsx b/packages/bank-ui/src/Routing.tsx @@ -31,7 +31,7 @@ import { HttpStatusCode, TranslatedString, assertUnreachable, - createRFC8959AccessTokenEncoded + createRFC8959AccessTokenEncoded, } from "@gnu-taler/taler-util"; import { useEffect } from "preact/hooks"; import { useSessionState } from "./hooks/session.js"; @@ -108,10 +108,6 @@ function PublicRounting({ } }, [location]); - if (location === undefined) { - return <Fragment />; - } - async function doAutomaticLogin(username: string, password: string) { await handleError(async () => { const resp = await lib @@ -122,7 +118,10 @@ function PublicRounting({ refreshable: true, }); if (resp.type === "ok") { - onLoggedUser(username, createRFC8959AccessTokenEncoded(resp.body.access_token)); + onLoggedUser( + username, + createRFC8959AccessTokenEncoded(resp.body.access_token), + ); } else { switch (resp.case) { case HttpStatusCode.Unauthorized: @@ -149,6 +148,9 @@ function PublicRounting({ } switch (location.name) { + case undefined: { + return <Fragment />; + } case "login": { return ( <Fragment> @@ -278,11 +280,10 @@ function PrivateRouting({ } }, [location]); - if (location === undefined) { - return <Fragment />; - } - switch (location.name) { + case undefined: { + return <Fragment />; + } case "operationDetails": { return ( <WithdrawalOperationPage @@ -395,9 +396,7 @@ function PrivateRouting({ routeMyAccountDetails={privatePages.myAccountDetails} routeMyAccountPassword={privatePages.myAccountPassword} routeConversionConfig={privatePages.conversionConfig} - onCashout={() => - navigateTo(privatePages.home.url({})) - } + onCashout={() => navigateTo(privatePages.home.url({}))} onAuthorizationRequired={() => navigateTo(privatePages.solveSecondFactor.url({})) } @@ -465,9 +464,7 @@ function PrivateRouting({ routeMyAccountDetails={privatePages.myAccountDetails} routeMyAccountPassword={privatePages.myAccountPassword} routeConversionConfig={privatePages.conversionConfig} - onCashout={() => - navigateTo(privatePages.home.url({})) - } + onCashout={() => navigateTo(privatePages.home.url({}))} onAuthorizationRequired={() => navigateTo(privatePages.solveSecondFactor.url({})) }