From cf929379bc2b09222817fbbd7063d0b31fc00add Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 14 Jun 2024 15:11:34 -0300 Subject: fix #8930 --- packages/bank-ui/src/hooks/preferences.ts | 13 ++++++++++++- packages/bank-ui/src/pages/OperationState/state.ts | 4 ++-- packages/bank-ui/src/pages/WalletWithdrawForm.tsx | 6 +++--- packages/bank-ui/src/pages/account/ShowAccountDetails.tsx | 15 +++++++++++++++ packages/bank-ui/src/settings.ts | 9 --------- 5 files changed, 32 insertions(+), 15 deletions(-) (limited to 'packages') diff --git a/packages/bank-ui/src/hooks/preferences.ts b/packages/bank-ui/src/hooks/preferences.ts index 4cb5e6a95..fadbbc8c1 100644 --- a/packages/bank-ui/src/hooks/preferences.ts +++ b/packages/bank-ui/src/hooks/preferences.ts @@ -19,7 +19,6 @@ import { TranslatedString, buildCodecForObject, codecForBoolean, - codecForNumber, } from "@gnu-taler/taler-util"; import { buildStorageKey, @@ -32,6 +31,8 @@ interface Preferences { showDemoDescription: boolean; showInstallWallet: boolean; showDebugInfo: boolean; + fastWithdrawalForm: boolean; + showCopyAccount: boolean; } export const codecForPreferences = (): Codec => @@ -40,6 +41,8 @@ export const codecForPreferences = (): Codec => .property("showDemoDescription", codecForBoolean()) .property("showInstallWallet", codecForBoolean()) .property("showDebugInfo", codecForBoolean()) + .property("fastWithdrawalForm", codecForBoolean()) + .property("showCopyAccount", codecForBoolean()) .build("Settings"); const defaultPreferences: Preferences = { @@ -47,6 +50,8 @@ const defaultPreferences: Preferences = { showDemoDescription: true, showInstallWallet: true, showDebugInfo: false, + fastWithdrawalForm: false, + showCopyAccount: false, }; const BANK_PREFERENCES_KEY = buildStorageKey( @@ -80,6 +85,8 @@ export function getAllBooleanPreferences(): Array { "showDemoDescription", "showInstallWallet", "showWithdrawalSuccess", + "fastWithdrawalForm", + "showCopyAccount", ]; } @@ -90,6 +97,10 @@ export function getLabelForPreferences( switch (k) { case "showWithdrawalSuccess": return i18n.str`Show withdrawal confirmation`; + case "fastWithdrawalForm": + return i18n.str`Withdraw without setting amount`; + case "showCopyAccount": + return i18n.str`Show copy account letter`; case "showDemoDescription": return i18n.str`Show demo description`; case "showInstallWallet": diff --git a/packages/bank-ui/src/pages/OperationState/state.ts b/packages/bank-ui/src/pages/OperationState/state.ts index 5544c4e23..540856ec8 100644 --- a/packages/bank-ui/src/pages/OperationState/state.ts +++ b/packages/bank-ui/src/pages/OperationState/state.ts @@ -62,7 +62,7 @@ export function useComponentState({ const parsedAmount = Amounts.parseOrThrow(`${currency}:${amount}`); if (!creds) return; const params: TalerCorebankApi.BankAccountCreateWithdrawalRequest = - settings.fastWithdrawalForm + preference.fastWithdrawalForm ? { suggested_amount: Amounts.stringify(parsedAmount), } @@ -83,7 +83,7 @@ export function useComponentState({ if (withdrawalOperationId === undefined) { doSilentStart(); } - }, [settings.fastWithdrawalForm, amount]); + }, [preference.fastWithdrawalForm, amount]); if (failure) { return { diff --git a/packages/bank-ui/src/pages/WalletWithdrawForm.tsx b/packages/bank-ui/src/pages/WalletWithdrawForm.tsx index 7cf2c7881..953b29d76 100644 --- a/packages/bank-ui/src/pages/WalletWithdrawForm.tsx +++ b/packages/bank-ui/src/pages/WalletWithdrawForm.tsx @@ -67,6 +67,7 @@ function OldWithdrawalForm({ }): VNode { const { i18n } = useTranslationContext(); const settings = useSettingsContext(); + const [preference] = usePreferences(); // const walletInegrationApi = useTalerWalletIntegrationAPI() // const { navigateTo } = useNavigationContext(); @@ -144,7 +145,7 @@ function OldWithdrawalForm({ if (!parsedAmount || !creds) return; await handleError(async () => { const params: TalerCorebankApi.BankAccountCreateWithdrawalRequest = - settings.fastWithdrawalForm + preference.fastWithdrawalForm ? { suggested_amount: Amounts.stringify(parsedAmount), } @@ -349,7 +350,6 @@ export function WalletWithdrawForm({ }): VNode { const { i18n } = useTranslationContext(); const [pref, updatePref] = usePreferences(); - const settings = useSettingsContext(); return (
@@ -388,7 +388,7 @@ export function WalletWithdrawForm({ )} - {!settings.fastWithdrawalForm ? ( + {!pref.fastWithdrawalForm ? ( Cancel + + {!preferences.showCopyAccount ? ( + + ) : ( + + !accountLetter ? "" : JSON.stringify(accountLetter) + } + class="flex text-center disabled:opacity-50 disabled:cursor-default cursor-pointer rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" + > + Copy + + )}
)} diff --git a/packages/bank-ui/src/settings.ts b/packages/bank-ui/src/settings.ts index 6d8f7b850..c1e418bc1 100644 --- a/packages/bank-ui/src/settings.ts +++ b/packages/bank-ui/src/settings.ts @@ -46,13 +46,6 @@ export interface UiSettings { // - value: link target, where the user is going to be redirected // default: empty list topNavSites?: Record; - // Use the withdrawal form which redirect the user to the wallet - // without asking the amount to the user. - // - true: on withdrawal creation the spa will use suggested_amount instead - // of fixed amount - // - false: on withdrawal creation the spa will use fixed amount - // default: false - fastWithdrawalForm?: boolean; // When the withdrawal form use the suggested amount the bank // will send a default value that the user can change. // default: 10 @@ -68,7 +61,6 @@ const defaultSettings: UiSettings = { simplePasswordForRandomAccounts: false, allowRandomAccountCreation: false, topNavSites: {}, - fastWithdrawalForm: false, defaultSuggestedAmount: 10, }; @@ -76,7 +68,6 @@ const codecForUISettings = (): Codec => buildCodecForObject() .property("backendBaseURL", codecOptional(codecForString())) .property("allowRandomAccountCreation", codecOptional(codecForBoolean())) - .property("fastWithdrawalForm", codecOptional(codecForBoolean())) .property("defaultSuggestedAmount", codecOptional(codecForNumber())) .property( "simplePasswordForRandomAccounts", -- cgit v1.2.3