diff options
Diffstat (limited to 'packages/demobank-ui/src/hooks/bank-state.ts')
-rw-r--r-- | packages/demobank-ui/src/hooks/bank-state.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/packages/demobank-ui/src/hooks/bank-state.ts b/packages/demobank-ui/src/hooks/bank-state.ts index 15daf9180..83bb009cf 100644 --- a/packages/demobank-ui/src/hooks/bank-state.ts +++ b/packages/demobank-ui/src/hooks/bank-state.ts @@ -141,6 +141,8 @@ const codecForChallenge = (): Codec<ChallengeInProgess> => .alternative("update-password", codecForChallengeUpdatePassword()) .build("ChallengeInProgess"); + + interface BankState { currentWithdrawalOperationId: string | undefined; currentChallenge: ChallengeInProgess | undefined; @@ -159,6 +161,14 @@ const defaultBankState: BankState = { const BANK_STATE_KEY = buildStorageKey("bank-app-state", codecForBankState()); +/** + * Client state saved in local storage. + * + * This information is saved in the client because + * the backend server session API is not enough. + * + * @returns tuple of [state, update(), reset()] + */ export function useBankState(): [ Readonly<BankState>, <T extends keyof BankState>(key: T, value: BankState[T]) => void, @@ -175,3 +185,4 @@ export function useBankState(): [ } return [value, updateField, reset]; } + |