diff options
author | Sebastian <sebasjm@gmail.com> | 2024-06-27 09:18:09 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-06-27 09:18:09 -0300 |
commit | 541f2fb960f125802931519966981691914ed903 (patch) | |
tree | e2387eae5a7a30c3f6ebc9e0f741df76c37c46dc /packages/challenger-ui/src/pages | |
parent | ae993d949b4a754bf87f1eb008ec8e6803170ebb (diff) | |
download | wallet-core-541f2fb960f125802931519966981691914ed903.tar.xz |
fix types
Diffstat (limited to 'packages/challenger-ui/src/pages')
-rw-r--r-- | packages/challenger-ui/src/pages/AnswerChallenge.tsx | 27 | ||||
-rw-r--r-- | packages/challenger-ui/src/pages/AskChallenge.tsx | 18 |
2 files changed, 24 insertions, 21 deletions
diff --git a/packages/challenger-ui/src/pages/AnswerChallenge.tsx b/packages/challenger-ui/src/pages/AnswerChallenge.tsx index 9788ea8a5..5fe2d9743 100644 --- a/packages/challenger-ui/src/pages/AnswerChallenge.tsx +++ b/packages/challenger-ui/src/pages/AnswerChallenge.tsx @@ -75,15 +75,15 @@ export function AnswerChallenge({ return await lib.challenger.challenge(nonce, { email: lastEmail }); }, (ok) => { - // if ("redirectURL" in ok.body) { - // completed(ok.body.redirectURL); - // } else { - accepted({ - attemptsLeft: ok.body.attempts_left, - nextSend: ok.body.next_tx_time, - transmitted: ok.body.transmitted, - }); - // } + if (ok.body.type === "completed") { + completed(new URL(ok.body.redirect_url)); + } else { + accepted({ + attemptsLeft: ok.body.attempts_left, + nextSend: ok.body.next_tx_time, + transmitted: ok.body.transmitted, + }); + } return undefined; }, (fail) => { @@ -112,7 +112,11 @@ export function AnswerChallenge({ return lib.challenger.solve(nonce, { pin: pin! }); }, (ok) => { - completed(new URL(ok.body.redirect_url)); + if (ok.body.type === "completed") { + completed(new URL(ok.body.redirect_url)); + } else { + setLastTryError(ok.body); + } onComplete(); }, (fail) => { @@ -120,8 +124,7 @@ export function AnswerChallenge({ case HttpStatusCode.BadRequest: return i18n.str`Invalid request`; case HttpStatusCode.Forbidden: { - setLastTryError(fail.body); - return i18n.str`Invalid pin`; + return i18n.str`Too many attemps where made`; } case HttpStatusCode.NotFound: return i18n.str``; diff --git a/packages/challenger-ui/src/pages/AskChallenge.tsx b/packages/challenger-ui/src/pages/AskChallenge.tsx index c2ef43615..829cdaccc 100644 --- a/packages/challenger-ui/src/pages/AskChallenge.tsx +++ b/packages/challenger-ui/src/pages/AskChallenge.tsx @@ -87,15 +87,15 @@ export function AskChallenge({ return lib.challenger.challenge(nonce, { email: email! }); }, (ok) => { - // if ("redirectURL" in ok.body) { - // completed(ok.body.); - // } else { - accepted({ - attemptsLeft: ok.body.attempts_left, - nextSend: ok.body.next_tx_time, - transmitted: ok.body.transmitted, - }); - // } + if (ok.body.type === "completed") { + completed(new URL(ok.body.redirect_url)); + } else { + accepted({ + attemptsLeft: ok.body.attempts_left, + nextSend: ok.body.next_tx_time, + transmitted: ok.body.transmitted, + }); + } onSendSuccesful(); }, (fail) => { |