diff options
author | Sebastian <sebasjm@gmail.com> | 2022-12-07 15:44:16 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-12-07 16:08:19 -0300 |
commit | d2554bedf3984ba4eb3a52b5649daa9c7c686c39 (patch) | |
tree | 237e020c1ef78634a5a288df4420f541bf706a1b /packages/demobank-ui/src/context | |
parent | 9112655ef5b68245f934ad25d2c8b9fa19a0f7bd (diff) | |
download | wallet-core-d2554bedf3984ba4eb3a52b5649daa9c7c686c39.tar.xz |
no-fix: remove 'any' and login status is taken from backend
Diffstat (limited to 'packages/demobank-ui/src/context')
-rw-r--r-- | packages/demobank-ui/src/context/backend.ts | 52 | ||||
-rw-r--r-- | packages/demobank-ui/src/context/pageState.ts | 3 | ||||
-rw-r--r-- | packages/demobank-ui/src/context/translation.ts | 4 |
3 files changed, 54 insertions, 5 deletions
diff --git a/packages/demobank-ui/src/context/backend.ts b/packages/demobank-ui/src/context/backend.ts new file mode 100644 index 000000000..b9b7f8527 --- /dev/null +++ b/packages/demobank-ui/src/context/backend.ts @@ -0,0 +1,52 @@ +/* + This file is part of GNU Taler + (C) 2021 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ + +import { ComponentChildren, createContext, h, VNode } from "preact"; +import { useContext } from "preact/hooks"; +import { BackendStateHandler, defaultState, useBackendState } from "../hooks/backend.js"; + +/** + * + * @author Sebastian Javier Marchano (sebasjm) + */ + +export type Type = BackendStateHandler; + +const initial: Type = { + state: defaultState, + clear() { + null + }, + save(info) { + null + }, +}; +const Context = createContext<Type>(initial); + +export const useBackendContext = (): Type => useContext(Context); + +export const BackendStateProvider = ({ + children, +}: { + children: ComponentChildren; +}): VNode => { + const value = useBackendState(); + + return h(Context.Provider, { + value, + children, + }); +};
\ No newline at end of file diff --git a/packages/demobank-ui/src/context/pageState.ts b/packages/demobank-ui/src/context/pageState.ts index 4ef21b8f0..b954ad20e 100644 --- a/packages/demobank-ui/src/context/pageState.ts +++ b/packages/demobank-ui/src/context/pageState.ts @@ -29,7 +29,6 @@ export type Type = { }; const initial: Type = { pageState: { - isLoggedIn: false, isRawPayto: false, withdrawalInProgress: false, }, @@ -59,7 +58,6 @@ export const PageStateProvider = ({ */ function usePageState( state: PageStateType = { - isLoggedIn: false, isRawPayto: false, withdrawalInProgress: false, }, @@ -98,7 +96,6 @@ function usePageState( * Track page state. */ export interface PageStateType { - isLoggedIn: boolean; isRawPayto: boolean; withdrawalInProgress: boolean; error?: { diff --git a/packages/demobank-ui/src/context/translation.ts b/packages/demobank-ui/src/context/translation.ts index 478bdbde0..0a7e9429d 100644 --- a/packages/demobank-ui/src/context/translation.ts +++ b/packages/demobank-ui/src/context/translation.ts @@ -20,7 +20,7 @@ */ import { i18n, setupI18n } from "@gnu-taler/taler-util"; -import { createContext, h, VNode } from "preact"; +import { ComponentChildren, createContext, h, VNode } from "preact"; import { useContext, useEffect } from "preact/hooks"; import { hooks } from "@gnu-taler/web-util/lib/index.browser"; import { strings } from "../i18n/strings.js"; @@ -60,7 +60,7 @@ const Context = createContext<Type>(initial); interface Props { initial?: string; - children: any; + children: ComponentChildren; forceLang?: string; } |