diff options
author | Sebastian <sebasjm@gmail.com> | 2023-11-22 13:33:44 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-11-22 15:20:28 -0300 |
commit | 33c0267b37eecf44dc9f04e124eb44d27cba700c (patch) | |
tree | 9d5549dbb5a415b44005ab05711fc66c4643cbc9 /packages/demobank-ui/src/pages/BankFrame.tsx | |
parent | 5eec408d9fb5e8c2375937166997ef8267a4053c (diff) |
settings and preferences, getting conversion info
Diffstat (limited to 'packages/demobank-ui/src/pages/BankFrame.tsx')
-rw-r--r-- | packages/demobank-ui/src/pages/BankFrame.tsx | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/packages/demobank-ui/src/pages/BankFrame.tsx b/packages/demobank-ui/src/pages/BankFrame.tsx index f0baae3a3..5fef04b66 100644 --- a/packages/demobank-ui/src/pages/BankFrame.tsx +++ b/packages/demobank-ui/src/pages/BankFrame.tsx @@ -20,9 +20,9 @@ import { ComponentChildren, Fragment, VNode, h } from "preact"; import { useEffect, useErrorBoundary } from "preact/hooks"; import { useAccountDetails } from "../hooks/access.js"; import { useBackendState } from "../hooks/backend.js"; -import { getAllBooleanSettings, getLabelForSetting, useSettings } from "../hooks/settings.js"; -import { bankUiSettings } from "../settings.js"; +import { getAllBooleanPreferences, getLabelForPreferences, usePreferences } from "../hooks/preferences.js"; import { RenderAmount } from "./PaytoWireTransferForm.js"; +import { useSettingsContext } from "../context/settings.js"; const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : undefined; const VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : undefined; @@ -37,7 +37,8 @@ export function BankFrame({ }): VNode { const { i18n } = useTranslationContext(); const backend = useBackendState(); - const [settings, updateSettings] = useSettings(); + const settings = useSettingsContext(); + const [preferences, updatePreferences] = usePreferences(); const [error, resetError] = useErrorBoundary(); @@ -59,12 +60,12 @@ export function BankFrame({ <div class="bg-indigo-600 pb-32"> <Header title="Bank" - iconLinkURL={bankUiSettings.iconLinkURL ?? "#"} + iconLinkURL={settings.iconLinkURL ?? "#"} onLogout={backend.state.status !== "loggedIn" ? undefined : () => { backend.logOut() - updateSettings("currentWithdrawalOperationId", undefined); + updatePreferences("currentWithdrawalOperationId", undefined); }} - sites={bankUiSettings.demoSites ?? []} + sites={settings.demoSites ?? new Array<Array<string>>(new Array<string>())} supportedLangs={["en", "es", "de"]} > <li> @@ -72,18 +73,18 @@ export function BankFrame({ <i18n.Translate>Preferences</i18n.Translate> </div> <ul role="list" class="space-y-1"> - {getAllBooleanSettings().map(set => { - const isOn: boolean = !!settings[set] + {getAllBooleanPreferences().map(set => { + const isOn: boolean = !!preferences[set] return <li class="mt-2 pl-2"> <div class="flex items-center justify-between"> <span class="flex flex-grow flex-col"> <span class="text-sm text-black font-medium leading-6 " id="availability-label"> - {getLabelForSetting(set, i18n)} + {getLabelForPreferences(set, i18n)} </span> </span> <button type="button" data-enabled={isOn} class="bg-indigo-600 data-[enabled=false]:bg-gray-200 relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2" role="switch" aria-checked="false" aria-labelledby="availability-label" aria-describedby="availability-description" - onClick={() => { updateSettings(set, !isOn); }}> + onClick={() => { updatePreferences(set, !isOn); }}> <span aria-hidden="true" data-enabled={isOn} class="translate-x-5 data-[enabled=false]:translate-x-0 pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out"></span> </button> </div> @@ -130,7 +131,7 @@ export function BankFrame({ } function MaybeShowDebugInfo({ info }: { info: any }): VNode { - const [settings] = useSettings() + const [settings] = usePreferences() if (settings.showDebugInfo) { return <pre class="whitespace-break-spaces "> {info} |