diff options
author | Sebastian <sebasjm@gmail.com> | 2023-03-05 15:21:12 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-03-05 15:21:12 -0300 |
commit | 4de014927e95d792633ea367eb4404459489d44f (patch) | |
tree | c45ce3c0f7409f34b3f58711e055268e9fff1a9c /packages/demobank-ui/src/hooks/backend.ts | |
parent | 906eddd48a08f20e07325f241dc272e5f10e2781 (diff) | |
download | wallet-core-4de014927e95d792633ea367eb4404459489d44f.tar.xz |
validate IBAN, removing internal iban from account form, add missing logo, do not save backend URL in login state
Diffstat (limited to 'packages/demobank-ui/src/hooks/backend.ts')
-rw-r--r-- | packages/demobank-ui/src/hooks/backend.ts | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/packages/demobank-ui/src/hooks/backend.ts b/packages/demobank-ui/src/hooks/backend.ts index 3f2981edf..3eaf1f186 100644 --- a/packages/demobank-ui/src/hooks/backend.ts +++ b/packages/demobank-ui/src/hooks/backend.ts @@ -42,26 +42,23 @@ export interface BackendCredentials { } interface LoggedIn extends BackendCredentials { - url: string; status: "loggedIn"; isUserAdministrator: boolean; } interface LoggedOut { - url: string; status: "loggedOut"; } -const maybeRootPath = bankUiSettings.backendBaseURL; - export function getInitialBackendBaseURL(): string { const overrideUrl = localStorage.getItem("bank-base-url"); - return canonicalizeBaseUrl(overrideUrl ? overrideUrl : maybeRootPath); + return canonicalizeBaseUrl( + overrideUrl ? overrideUrl : bankUiSettings.backendBaseURL, + ); } export const defaultState: BackendState = { status: "loggedOut", - url: getInitialBackendBaseURL(), }; export interface BackendStateHandler { @@ -91,13 +88,12 @@ export function useBackendState(): BackendStateHandler { return { state, logOut() { - update(JSON.stringify({ ...defaultState, url: state.url })); + update(JSON.stringify({ ...defaultState })); }, logIn(info) { //admin is defined by the username const nextState: BackendState = { status: "loggedIn", - url: state.url, ...info, isUserAdministrator: info.username === "admin", }; @@ -125,7 +121,7 @@ export function usePublicBackend(): useBackendType { const { state } = useBackendContext(); const { request: requestHandler } = useApiContext(); - const baseUrl = state.url; + const baseUrl = getInitialBackendBaseURL(); const request = useCallback( function requestImpl<T>( @@ -201,7 +197,7 @@ export function useAuthenticatedBackend(): useBackendType { const { request: requestHandler } = useApiContext(); const creds = state.status === "loggedIn" ? state : undefined; - const baseUrl = state.url; + const baseUrl = getInitialBackendBaseURL(); const request = useCallback( function requestImpl<T>( |