aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/context/backend.ts
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2023-10-10 14:14:42 +0200
committerÖzgür Kesim <oec-taler@kesim.org>2023-10-10 14:14:42 +0200
commit490b813f77b3806343bbdd453d5abd29db9ea037 (patch)
tree95855651b678302cf3cf62aad480b783ca0419bf /packages/merchant-backoffice-ui/src/context/backend.ts
parentb5f5001249122ff611f16c043e72ccb174990654 (diff)
parentadda4f8ce38ce030f55855bc0d66443d08153480 (diff)
Merge branch 'master' into age-withdraw
Diffstat (limited to 'packages/merchant-backoffice-ui/src/context/backend.ts')
-rw-r--r--packages/merchant-backoffice-ui/src/context/backend.ts31
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
};
}