diff options
Diffstat (limited to 'packages/merchant-backoffice-ui/src/context/backend.ts')
-rw-r--r-- | packages/merchant-backoffice-ui/src/context/backend.ts | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/packages/merchant-backoffice-ui/src/context/backend.ts b/packages/merchant-backoffice-ui/src/context/backend.ts index d4a9abd5f..9b1a37be6 100644 --- a/packages/merchant-backoffice-ui/src/context/backend.ts +++ b/packages/merchant-backoffice-ui/src/context/backend.ts @@ -19,56 +19,39 @@ * @author Sebastian Javier Marchano (sebasjm) */ +import { useMemoryStorage } from "@gnu-taler/web-util/browser"; import { createContext, h, VNode } from "preact"; -import { useContext, useState } from "preact/hooks"; +import { useContext } from "preact/hooks"; import { LoginToken } from "../declaration.js"; import { useBackendDefaultToken, useBackendURL } from "../hooks/index.js"; -import { buildStorageKey, useLocalStorage } from "@gnu-taler/web-util/browser"; -import { codecForBoolean } from "@gnu-taler/taler-util"; interface BackendContextType { url: string, - selected: boolean; + alreadyTriedLogin: boolean; token?: LoginToken; updateToken: (token: LoginToken | undefined) => void; - changeBackend: (url: string) => void; - resetBackend: () => void; } const BackendContext = createContext<BackendContextType>({ url: "", - selected: false, + alreadyTriedLogin: false, token: undefined, updateToken: () => null, - changeBackend: () => null, - resetBackend: () => null, }); -const BACKEND_SELECTED = buildStorageKey("backend-selected", codecForBoolean()); - function useBackendContextState( defaultUrl?: string, ): BackendContextType { - const [url, changeBackend2] = useBackendURL(defaultUrl); + const [url] = useBackendURL(defaultUrl); const [token, updateToken] = useBackendDefaultToken(); - const {value, update} = useLocalStorage(BACKEND_SELECTED) - - function changeBackend(s:string) { - changeBackend2(s) - update(true) - } - function resetBackend() { - update(false) - } + console.log(JSON.stringify(token)) return { url, token, - selected: value ?? false, + alreadyTriedLogin: token !== undefined, updateToken, - changeBackend, - resetBackend }; } |