diff options
author | Sebastian <sebasjm@gmail.com> | 2024-01-10 14:44:10 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-01-10 14:44:10 -0300 |
commit | 44820f06be979d3a30d2e66c430e212e28ca6052 (patch) | |
tree | 10325f2eadfafcdeb293524852142a6cd70e390d /packages/demobank-ui/src/pages/OperationState/state.ts | |
parent | 2c7db170a45fcb82deae3892d610b6b2805ee46c (diff) | |
download | wallet-core-44820f06be979d3a30d2e66c430e212e28ca6052.tar.xz |
save challenge id when 2fa is required
Diffstat (limited to 'packages/demobank-ui/src/pages/OperationState/state.ts')
-rw-r--r-- | packages/demobank-ui/src/pages/OperationState/state.ts | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/packages/demobank-ui/src/pages/OperationState/state.ts b/packages/demobank-ui/src/pages/OperationState/state.ts index 477146d1e..b214a400d 100644 --- a/packages/demobank-ui/src/pages/OperationState/state.ts +++ b/packages/demobank-ui/src/pages/OperationState/state.ts @@ -24,9 +24,11 @@ import { useBackendState } from "../../hooks/backend.js"; import { usePreferences } from "../../hooks/preferences.js"; import { assertUnreachable } from "../WithdrawalOperationPage.js"; import { Props, State } from "./index.js"; +import { useBankState } from "../../hooks/bank-state.js"; export function useComponentState({ currency, onClose }: Props): utils.RecursiveState<State> { - const [settings, updateSettings] = usePreferences() + const [settings] = usePreferences() + const [bankState, updateBankState] = useBankState(); const { state: credentials } = useBackendState() const creds = credentials.status !== "loggedIn" ? undefined : credentials const { api } = useBankCoreApiContext() @@ -46,11 +48,11 @@ export function useComponentState({ currency, onClose }: Props): utils.Recursive setFailure(resp) return; } - updateSettings("currentWithdrawalOperationId", resp.body.withdrawal_id) + updateBankState("currentWithdrawalOperationId", resp.body.withdrawal_id) } - const withdrawalOperationId = settings.currentWithdrawalOperationId + const withdrawalOperationId = bankState.currentWithdrawalOperationId useEffect(() => { if (withdrawalOperationId === undefined) { doSilentStart() @@ -77,7 +79,7 @@ export function useComponentState({ currency, onClose }: Props): utils.Recursive if (!creds) return; const resp = await api.abortWithdrawalById(creds, wid); if (resp.type === "ok") { - updateSettings("currentWithdrawalOperationId", undefined) + updateBankState("currentWithdrawalOperationId", undefined) onClose(); } else { return resp; @@ -140,7 +142,7 @@ export function useComponentState({ currency, onClose }: Props): utils.Recursive status: "aborted", error: undefined, onClose: async () => { - updateSettings("currentWithdrawalOperationId", undefined) + updateBankState("currentWithdrawalOperationId", undefined) onClose() }, } @@ -155,7 +157,7 @@ export function useComponentState({ currency, onClose }: Props): utils.Recursive status: "aborted", error: undefined, onClose: async () => { - updateSettings("currentWithdrawalOperationId", undefined) + updateBankState("currentWithdrawalOperationId", undefined) onClose() }, } @@ -163,14 +165,14 @@ export function useComponentState({ currency, onClose }: Props): utils.Recursive if (data.status === "confirmed") { if (!settings.showWithdrawalSuccess) { - updateSettings("currentWithdrawalOperationId", undefined) + updateBankState("currentWithdrawalOperationId", undefined) onClose() } return { status: "confirmed", error: undefined, onClose: async () => { - updateSettings("currentWithdrawalOperationId", undefined) + updateBankState("currentWithdrawalOperationId", undefined) onClose() }, } |