diff options
Diffstat (limited to 'packages/auditor-backoffice-ui/src/context/backend.ts')
-rw-r--r-- | packages/auditor-backoffice-ui/src/context/backend.ts | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/packages/auditor-backoffice-ui/src/context/backend.ts b/packages/auditor-backoffice-ui/src/context/backend.ts index b13b92c42..ce321c3e6 100644 --- a/packages/auditor-backoffice-ui/src/context/backend.ts +++ b/packages/auditor-backoffice-ui/src/context/backend.ts @@ -17,54 +17,54 @@ /** * * @author Sebastian Javier Marchano (sebasjm) + * @author Nic Eigel */ -import { useMemoryStorage } from "@gnu-taler/web-util/browser"; import { createContext, h, VNode } from "preact"; import { useContext } from "preact/hooks"; -import { LoginToken } from "../declaration.js"; -import { useBackendDefaultToken, useBackendURL } from "../hooks/index.js"; +import { useBackendURL } from "../hooks/index.js"; interface BackendContextType { - url: string, - alreadyTriedLogin: boolean; - token?: LoginToken; - updateToken: (token: LoginToken | undefined) => void; + url: string, } const BackendContext = createContext<BackendContextType>({ - url: "", - alreadyTriedLogin: false, - token: undefined, - updateToken: () => null, + url: "", }); function useBackendContextState( - defaultUrl?: string, + defaultUrl?: string, ): BackendContextType { -const [url] = useBackendURL(defaultUrl); - //const url = "http://localhost:8081"; - const [token, updateToken] = useBackendDefaultToken(); - - return { - url, - token, - alreadyTriedLogin: token !== undefined, - updateToken, - }; + const [url] = useBackendURL(defaultUrl); + + return { + url, + }; } export const BackendContextProvider = ({ - children, - defaultUrl, -}: { - children: any; - defaultUrl?: string; + children, + defaultUrl, + }: { + children: any; + defaultUrl?: string; }): VNode => { - const value = useBackendContextState(defaultUrl); + const value = useBackendContextState(defaultUrl); - return h(BackendContext.Provider, { value, children }); + return h(BackendContext.Provider, { value, children }); }; + + export const useBackendContext = (): BackendContextType => - useContext(BackendContext); + useContext(BackendContext); + +interface BackendTokenType { + token: string; +} + +const BackendTokenContext = createContext<BackendTokenType>({} as any); + +export const BackendTokenContextProvider = BackendTokenContext.Provider; + +export const useBackendTokenContext = (): BackendTokenType => useContext(BackendTokenContext);
\ No newline at end of file |