diff options
Diffstat (limited to 'packages/bank-ui/src/pages/admin/AccountForm.tsx')
-rw-r--r-- | packages/bank-ui/src/pages/admin/AccountForm.tsx | 147 |
1 files changed, 5 insertions, 142 deletions
diff --git a/packages/bank-ui/src/pages/admin/AccountForm.tsx b/packages/bank-ui/src/pages/admin/AccountForm.tsx index 10b6afdf9..026f6e9b3 100644 --- a/packages/bank-ui/src/pages/admin/AccountForm.tsx +++ b/packages/bank-ui/src/pages/admin/AccountForm.tsx @@ -30,7 +30,7 @@ import { } from "@gnu-taler/web-util/browser"; import { ComponentChildren, VNode, h } from "preact"; import { useState } from "preact/hooks"; -import { VersionHint, useBankCoreApiContext } from "../../context/config.js"; +import { useBankCoreApiContext } from "@gnu-taler/web-util/browser"; import { useSessionState } from "../../hooks/session.js"; import { ErrorMessageMappingFor, @@ -92,7 +92,7 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({ onChange: ChangeByPurposeType[PurposeType]; purpose: PurposeType; }): VNode { - const { config, hints, url } = useBankCoreApiContext(); + const { config, url } = useBankCoreApiContext(); const { i18n } = useTranslationContext(); const { state: credentials } = useSessionState(); const [form, setForm] = useState<AccountFormData>({}); @@ -125,8 +125,6 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({ tan_channel: template?.tan_channel, }; - const OLD_CASHOUT_API = hints.indexOf(VersionHint.CASHOUT_BEFORE_2FA) !== -1; - const userIsAdmin = credentials.status !== "loggedIn" ? false : credentials.isUserAdministrator; @@ -144,9 +142,6 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({ userIsAdmin && (purpose === "create" || purpose === "update"); const editableAccount = purpose === "create" && userIsAdmin; - const hasPhone = !!defaultValue.phone || !!form.phone; - const hasEmail = !!defaultValue.email || !!form.email; - function updateForm(newForm: typeof defaultValue): void { const trimmedAmountStr = newForm.debit_threshold?.trim(); const parsedAmount = Amounts.parse( @@ -503,138 +498,6 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({ /> )} - {/* channel, not shown if old cashout api */} - {OLD_CASHOUT_API || - config.supported_tan_channels.length === 0 ? undefined : ( - <div class="sm:col-span-5"> - <label - class="block text-sm font-medium leading-6 text-gray-900" - for="channel" - > - {i18n.str`Enable second factor authentication`} - </label> - <div class="mt-2 max-w-xl text-sm text-gray-500"> - <div class="px-4 mt-4 grid grid-cols-1 gap-y-6"> - {config.supported_tan_channels.indexOf(TanChannel.EMAIL) === - -1 ? undefined : ( - <label - onClick={(e) => { - if (!hasEmail) return; - if (form.tan_channel === TanChannel.EMAIL) { - form.tan_channel = "remove"; - } else { - form.tan_channel = TanChannel.EMAIL; - } - updateForm(structuredClone(form)); - e.preventDefault(); - }} - data-disabled={purpose === "show" || !hasEmail} - data-selected={ - (form.tan_channel ?? defaultValue.tan_channel) === - TanChannel.EMAIL - } - class="relative flex data-[disabled=false]:cursor-pointer rounded-lg border bg-white data-[disabled=true]:bg-gray-200 p-4 shadow-sm focus:outline-none border-gray-300 data-[selected=true]:ring-2 data-[selected=true]:ring-indigo-600" - > - <input - type="radio" - name="channel" - value="Newsletter" - class="sr-only" - /> - <span class="flex flex-1"> - <span class="flex flex-col"> - <span - id="project-type-0-label" - class="block text-sm font-medium text-gray-900 " - > - <i18n.Translate>Using email</i18n.Translate> - </span> - {purpose !== "show" && - !hasEmail && - i18n.str`Add an email in your profile to enable this option`} - </span> - </span> - <svg - data-selected={ - (form.tan_channel ?? defaultValue.tan_channel) === - TanChannel.EMAIL - } - class="h-5 w-5 text-indigo-600 data-[selected=false]:hidden" - viewBox="0 0 20 20" - fill="currentColor" - aria-hidden="true" - > - <path - fill-rule="evenodd" - d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" - clip-rule="evenodd" - /> - </svg> - </label> - )} - - {config.supported_tan_channels.indexOf(TanChannel.SMS) === - -1 ? undefined : ( - <label - onClick={(e) => { - if (!hasPhone) return; - if (form.tan_channel === TanChannel.SMS) { - form.tan_channel = "remove"; - } else { - form.tan_channel = TanChannel.SMS; - } - updateForm(structuredClone(form)); - e.preventDefault(); - }} - data-disabled={purpose === "show" || !hasPhone} - data-selected={ - (form.tan_channel ?? defaultValue.tan_channel) === - TanChannel.SMS - } - class="relative flex data-[disabled=false]:cursor-pointer rounded-lg border data-[disabled=true]:bg-gray-200 p-4 shadow-sm focus:outline-none border-gray-300 data-[selected=true]:ring-2 data-[selected=true]:ring-indigo-600" - > - <input - type="radio" - name="channel" - value="Existing Customers" - class="sr-only" - /> - <span class="flex flex-1"> - <span class="flex flex-col"> - <span - id="project-type-1-label" - class="block text-sm font-medium text-gray-900" - > - <i18n.Translate>Using SMS</i18n.Translate> - </span> - {purpose !== "show" && - !hasPhone && - i18n.str`Add a phone number in your profile to enable this option`} - </span> - </span> - <svg - data-selected={ - (form.tan_channel ?? defaultValue.tan_channel) === - TanChannel.SMS - } - class="h-5 w-5 text-indigo-600 data-[selected=false]:hidden" - viewBox="0 0 20 20" - fill="currentColor" - aria-hidden="true" - > - <path - fill-rule="evenodd" - d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" - clip-rule="evenodd" - /> - </svg> - </label> - )} - </div> - </div> - </div> - )} - <div class="sm:col-span-5"> <label for="debit" @@ -649,9 +512,9 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({ !editableThreshold ? undefined : (e) => { - form.debit_threshold = e as AmountString; - updateForm(structuredClone(form)); - } + form.debit_threshold = e as AmountString; + updateForm(structuredClone(form)); + } } /> <ShowInputErrorLabel |