merchant-backoffice

ZZZ: Inactive/Deprecated
Log | Files | Refs | Submodules | README

commit d6b719772d37848192d92bad2ef6f3697606b24d
parent 460e665ab7c2912b53277acc9cdd26417c30844e
Author: ms <ms@taler.net>
Date:   Tue, 19 Apr 2022 18:27:43 +0200

fix shown public account in the state

Diffstat:
Mpackages/bank/src/pages/home/index.tsx | 20+++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/packages/bank/src/pages/home/index.tsx b/packages/bank/src/pages/home/index.tsx @@ -253,6 +253,24 @@ const getRootPath = () => { * and 'password' field, in order to avoid losing the * handle of the data entered by the user in <input> fields. */ +function useShowPublicAccount( + state?: string +): [string | undefined, StateUpdater<string | undefined>] { + + const ret = useLocalStorage("show-public-account", JSON.stringify(state)); + const retObj: string | undefined = ret[0] ? JSON.parse(ret[0]) : ret[0]; + const retSetter: StateUpdater<string | undefined> = function(val) { + const newVal = val instanceof Function ? JSON.stringify(val(retObj)) : JSON.stringify(val) + ret[1](newVal) + } + return [retObj, retSetter] +} + +/** + * Stores in the state a object containing a 'username' + * and 'password' field, in order to avoid losing the + * handle of the data entered by the user in <input> fields. + */ type CredentialsRequestTypeOpt = CredentialsRequestType | undefined; function useCredentialsRequestType( state?: CredentialsRequestType @@ -1510,7 +1528,7 @@ function SWRWithoutCredentials(Props: any): VNode { * Show histories of public accounts. */ function PublicHistories(Props: any): VNode { - const [showAccount, setShowAccount] = useState<string | undefined>(); + const [showAccount, setShowAccount] = useShowPublicAccount(); const { data, error } = useSWR("access-api/public-accounts"); const i18n = useTranslator();