[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-merchant-backoffice] branch master updated: Copying pybank's appe
From: |
gnunet |
Subject: |
[taler-merchant-backoffice] branch master updated: Copying pybank's appearance. WIP |
Date: |
Fri, 08 Apr 2022 13:19:20 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository merchant-backoffice.
The following commit(s) were added to refs/heads/master by this push:
new 04623aa Copying pybank's appearance. WIP
04623aa is described below
commit 04623aa3b6ab7c86f06191c7a8754fd2e988f096
Author: ms <ms@taler.net>
AuthorDate: Fri Apr 8 13:17:32 2022 +0200
Copying pybank's appearance. WIP
Cache invalidation when login hits 404.
---
packages/bank/src/pages/home/index.tsx | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/packages/bank/src/pages/home/index.tsx
b/packages/bank/src/pages/home/index.tsx
index 90b7827..424d5b7 100644
--- a/packages/bank/src/pages/home/index.tsx
+++ b/packages/bank/src/pages/home/index.tsx
@@ -648,7 +648,6 @@ async function registrationCall(
error: errorRaw
}));
} else {
- console.log("Credentials are valid");
pageStateSetter((prevState) => ({
...prevState,
isLoggedIn: true,
@@ -859,7 +858,7 @@ function PaytoWireTransfer(Props: any): VNode {
* Additional authentication required to complete the operation.
* Not providing a back button, only abort.
*/
-function TalerWithdrawalConfirmationQuestion(Props): VNode {
+function TalerWithdrawalConfirmationQuestion(Props: any): VNode {
const [pageState, pageStateSetter] = useContext(PageContext);
const { backendState } = Props;
const i18n = useTranslator();
@@ -1060,6 +1059,7 @@ function LoginForm(Props: any): VNode {
type="submit"
class="pure-button pure-button-primary"
onClick={() => {
+ if (typeof submitData === "undefined") return;
if (submitData.password.length > 0 && submitData.username.length > 0)
loginCall(
submitData,
@@ -1076,7 +1076,7 @@ function LoginForm(Props: any): VNode {
*/
function RegistrationForm(Props: any): VNode {
const [pageState, pageStateSetter] = useContext(PageContext);
- var submitData: CredentialsRequestType = {};
+ var submitData: CredentialsRequestType;
const i18n = useTranslator();
return (
@@ -1116,6 +1116,7 @@ function RegistrationForm(Props: any): VNode {
class="pure-button pure-button-primary"
onClick={() => {
console.log("maybe submitting the registration..");
+ if (typeof submitData === "undefined") return;
if ((typeof submitData.password === "undefined") ||
(typeof submitData.username === "undefined")) return;
if (submitData.password.length === 0 ||
@@ -1200,6 +1201,7 @@ function Transactions(Props: any): VNode {
* to the bank.
*/
function Account(Props: any): VNode {
+ const { cache } = useSWRConfig();
const { accountLabel, backendState } = Props;
const [pageState, pageStateSetter] = useContext(PageContext);
const {
@@ -1208,6 +1210,7 @@ function Account(Props: any): VNode {
withdrawalOutcome,
transferOutcome,
withdrawalId,
+ isLoggedIn,
talerWithdrawUri } = pageState;
const i18n = useTranslator();
const logOut = (
@@ -1243,7 +1246,8 @@ function Account(Props: any): VNode {
/**
* Getting the bank account balance.
*/
- const { data, error } = useSWR(`access-api/accounts/${accountLabel}`);
+ const endpoint = `access-api/accounts/${accountLabel}`;
+ const { data, error, mutate } = useSWR(endpoint);
if (typeof error !== "undefined") {
console.log("account error", error);
/**
@@ -1256,8 +1260,21 @@ function Account(Props: any): VNode {
...prevState,
hasError: true,
isLoggedIn: false,
- error: i18n`Username or account label '${accountLabel}' not found.
Won't login.`
+ error: i18n`Username or account label '${accountLabel}' not found.
Won't login.`
}));
+
+ /**
+ * 404 should never stick to the cache, because they
+ * taint successful registrations:
+ */
+ console.log("Cache at Account:", cache);
+ for (const key of cache.keys()) {
+ console.log("processing key: " + key);
+ if (RegExp(`${endpoint}$`).test(key)) {
+ console.log("Deleting key: " + key);
+ cache.delete(key)
+ }
+ }
return <p>Profile not found...</p>;
}
case 401: {
@@ -1419,7 +1436,7 @@ function SWRWithoutCredentials(Props: any): VNode {
*/
function PublicHistories(Props: any): VNode {
const [showAccount, setShowAccount] = useState<string | undefined>();
- const { data, error } = useSWR("access-api/public-accounts")
+ const { data, error } = useSWR("access-api/public-accounts");
const i18n = useTranslator();
if (typeof error !== "undefined") {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-merchant-backoffice] branch master updated: Copying pybank's appearance. WIP,
gnunet <=