summaryrefslogtreecommitdiff
path: root/packages/challenger-ui/src/pages/AnswerChallenge.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-04-22 12:18:41 -0300
committerSebastian <sebasjm@gmail.com>2024-04-22 12:18:41 -0300
commit5db4cb99e3f16c8471117ca7443bc323180e67ec (patch)
treea2340eb33b259cf420abb6a1e3cf295c0393b4f9 /packages/challenger-ui/src/pages/AnswerChallenge.tsx
parent594dd1fd4638d658303c4c8a0f24c4082564eceb (diff)
downloadwallet-core-5db4cb99e3f16c8471117ca7443bc323180e67ec.tar.gz
wallet-core-5db4cb99e3f16c8471117ca7443bc323180e67ec.tar.bz2
wallet-core-5db4cb99e3f16c8471117ca7443bc323180e67ec.zip
fix #8393
Diffstat (limited to 'packages/challenger-ui/src/pages/AnswerChallenge.tsx')
-rw-r--r--packages/challenger-ui/src/pages/AnswerChallenge.tsx24
1 files changed, 15 insertions, 9 deletions
diff --git a/packages/challenger-ui/src/pages/AnswerChallenge.tsx b/packages/challenger-ui/src/pages/AnswerChallenge.tsx
index bad6d70de..62b7e775d 100644
--- a/packages/challenger-ui/src/pages/AnswerChallenge.tsx
+++ b/packages/challenger-ui/src/pages/AnswerChallenge.tsx
@@ -16,7 +16,7 @@
import {
ChallengerApi,
HttpStatusCode,
- assertUnreachable
+ assertUnreachable,
} from "@gnu-taler/taler-util";
import {
Attention,
@@ -25,7 +25,7 @@ import {
ShowInputErrorLabel,
useChallengerApiContext,
useLocalNotificationHandler,
- useTranslationContext
+ useTranslationContext,
} from "@gnu-taler/web-util/browser";
import { Fragment, VNode, h } from "preact";
import { useState } from "preact/hooks";
@@ -50,19 +50,25 @@ export function AnswerChallenge({ nonce, onComplete }: Props): VNode {
pin: !pin ? i18n.str`Can't be empty` : undefined,
});
+ const lastEmail = !state
+ ? undefined
+ : !state.lastStatus
+ ? undefined
+ : ((state.lastStatus.last_address as any)["email"] as string);
+
const onSendAgain =
- !state || state.email === undefined
+ !state || lastEmail === undefined
? undefined
: withErrorHandler(
async () => {
- if (!state?.email) return;
- return await lib.bank.challenge(nonce, { email: state.email });
+ if (!lastEmail) return;
+ return await lib.bank.challenge(nonce, { email: lastEmail });
},
(ok) => {
if ("redirectURL" in ok.body) {
completed(ok.body.redirectURL);
} else {
- accepted(state.email!, {
+ accepted({
attemptsLeft: ok.body.attempts_left,
nextSend: ok.body.next_tx_time,
transmitted: ok.body.transmitted,
@@ -141,13 +147,13 @@ export function AnswerChallenge({ nonce, onComplete }: Props): VNode {
<p class="mt-2 text-lg leading-8 text-gray-600">
{state.lastTry.transmitted ? (
<i18n.Translate>
- A TAN was sent to your address &quot;{state.email}&quot;.
+ A TAN was sent to your address &quot;{lastEmail}&quot;.
</i18n.Translate>
) : (
<Attention title={i18n.str`Resend failed`} type="warning">
<i18n.Translate>
We recently already sent a TAN to your address &quot;
- {state.email}&quot;. A new TAN will not be transmitted again
+ {lastEmail}&quot;. A new TAN will not be transmitted again
before &quot;{state.lastTry.nextSend}&quot;.
</i18n.Translate>
</Attention>
@@ -227,7 +233,7 @@ export function AnswerChallenge({ nonce, onComplete }: Props): VNode {
</form>
</div>
</Fragment>
- )
+ );
}
export function undefinedIfEmpty<T extends object>(obj: T): T | undefined {