From 1bfaf997c3f898ee7a5e8a19bbaf4475cce94f0f Mon Sep 17 00:00:00 2001
From: Sebastian
Date: Fri, 4 Nov 2022 14:35:38 -0300
Subject: some fixes
after update pageState reset info and error message
input values should not be undefined, otherwise it gets uncontrolled (not controlled by preact)
autofocus on captcha
create a dependency from transactionList to balance, so tx list will be queried again if balance is updated
update balance on any pageChange
---
packages/demobank-ui/src/pages/home/index.tsx | 72 +++++++++++++++++++--------
1 file changed, 52 insertions(+), 20 deletions(-)
(limited to 'packages/demobank-ui/src/pages/home/index.tsx')
diff --git a/packages/demobank-ui/src/pages/home/index.tsx b/packages/demobank-ui/src/pages/home/index.tsx
index 6477e018d..be115412b 100644
--- a/packages/demobank-ui/src/pages/home/index.tsx
+++ b/packages/demobank-ui/src/pages/home/index.tsx
@@ -176,6 +176,7 @@ interface PageStateType {
* be moved in a future "withdrawal state" object.
*/
withdrawalId?: string;
+ timestamp?: number;
}
/**
@@ -497,7 +498,24 @@ function usePageState(
ret[1](newVal);
};
- return [retObj, retSetter];
+
+ //when moving from one page to another
+ //clean up the info and error bar
+ function removeLatestInfo(val: any): ReturnType {
+ const updater = typeof val === 'function' ? val : (c:any) => val
+ return retSetter((current:any) => {
+ const cleanedCurrent: PageStateType = {...current,
+ hasInfo: false,
+ info: undefined,
+ hasError: false,
+ errors: undefined,
+ timestamp: new Date().getTime()
+ }
+ return updater(cleanedCurrent)
+ })
+ }
+
+ return [retObj, removeLatestInfo];
}
/**
@@ -997,9 +1015,7 @@ function StatusBanner(Props: any): VNode | null {
const i18n = useTranslator();
if (!pageState.hasInfo) return null;
- const rval =