summaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/pages/admin/AccountForm.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/demobank-ui/src/pages/admin/AccountForm.tsx')
-rw-r--r--packages/demobank-ui/src/pages/admin/AccountForm.tsx77
1 files changed, 32 insertions, 45 deletions
diff --git a/packages/demobank-ui/src/pages/admin/AccountForm.tsx b/packages/demobank-ui/src/pages/admin/AccountForm.tsx
index 8465a3d8f..300508abe 100644
--- a/packages/demobank-ui/src/pages/admin/AccountForm.tsx
+++ b/packages/demobank-ui/src/pages/admin/AccountForm.tsx
@@ -128,6 +128,8 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
const editableName =
purpose === "create" ||
(purpose === "update" && (config.allow_edit_name || userIsAdmin));
+
+ const isCashoutEnabled = config.allow_conversion
const editableCashout =
showingCurrentUserInfo &&
(purpose === "create" ||
@@ -162,9 +164,9 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
: !editableCashout
? undefined
: !cashoutParsed
- ? i18n.str`it doesn't have the pattern of an IBAN number`
+ ? i18n.str`Doesn't have the pattern of an IBAN number`
: !cashoutParsed.isKnown || cashoutParsed.targetType !== "iban"
- ? i18n.str`only "IBAN" target are supported`
+ ? i18n.str`Only "IBAN" target are supported`
: !IBAN_REGEX.test(cashoutParsed.iban)
? i18n.str`IBAN should have just uppercased letters and numbers`
: validateIBAN(cashoutParsed.iban, i18n),
@@ -173,40 +175,40 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
: !editableAccount
? undefined
: !internalParsed
- ? i18n.str`it doesn't have the pattern of an IBAN number`
+ ? i18n.str`Doesn't have the pattern of an IBAN number`
: !internalParsed.isKnown || internalParsed.targetType !== "iban"
- ? i18n.str`only "IBAN" target are supported`
+ ? i18n.str`Only "IBAN" target are supported`
: !IBAN_REGEX.test(internalParsed.iban)
? i18n.str`IBAN should have just uppercased letters and numbers`
: validateIBAN(internalParsed.iban, i18n),
email: !newForm.email
? undefined
: !EMAIL_REGEX.test(newForm.email)
- ? i18n.str`it doesn't have the pattern of an email`
+ ? i18n.str`Doesn't have the pattern of an email`
: undefined,
phone: !newForm.phone
? undefined
: !newForm.phone.startsWith("+") // FIXME: better phone number check
- ? i18n.str`should start with +`
+ ? i18n.str`Should start with +`
: !REGEX_JUST_NUMBERS_REGEX.test(newForm.phone)
- ? i18n.str`phone number can't have other than numbers`
+ ? i18n.str`Phone number can't have other than numbers`
: undefined,
debit_threshold: !editableThreshold
? undefined
: !trimmedAmountStr
? undefined
: !parsedAmount
- ? i18n.str`not valid`
+ ? i18n.str`Not valid`
: undefined,
name: !editableName
? undefined // disabled
: !newForm.name
- ? i18n.str`required`
+ ? i18n.str`Required`
: undefined,
username: !editableUsername
? undefined
: !newForm.username
- ? i18n.str`required`
+ ? i18n.str`Required`
: undefined,
});
setErrors(errors);
@@ -246,8 +248,8 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
debit_threshold: threshold ?? config.default_debit_threshold,
cashout_payto_uri: cashoutURI,
payto_uri: internalURI,
- is_public: !!newForm.isPublic,
- is_taler_exchange: !!newForm.isExchange,
+ is_public: newForm.isPublic,
+ is_taler_exchange: newForm.isExchange,
tan_channel:
newForm.tan_channel === "remove"
? undefined
@@ -263,11 +265,11 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
const result: TalerCorebankApi.AccountReconfiguration = {
cashout_payto_uri: cashoutURI,
contact_data: undefinedIfEmpty({
- email: newForm.email ?? template?.contact_data?.email,
- phone: newForm.phone ?? template?.contact_data?.phone,
+ email: newForm.email,
+ phone: newForm.phone,
}),
debit_threshold: threshold,
- is_public: !!newForm.isPublic,
+ is_public: newForm.isPublic,
name: newForm.name,
tan_channel:
newForm.tan_channel === "remove" ? null : newForm.tan_channel,
@@ -300,7 +302,7 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
class="block text-sm font-medium leading-6 text-gray-900"
for="username"
>
- {i18n.str`Username`}
+ {i18n.str`Login username`}
{editableUsername && <b style={{ color: "red" }}> *</b>}
</label>
<div class="mt-2">
@@ -326,9 +328,7 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
/>
</div>
<p class="mt-2 text-sm text-gray-500">
- <i18n.Translate>
- account identification in the bank
- </i18n.Translate>
+ <i18n.Translate>Account identification</i18n.Translate>
</p>
</div>
@@ -337,7 +337,7 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
class="block text-sm font-medium leading-6 text-gray-900"
for="name"
>
- {i18n.str`Name`}
+ {i18n.str`Full name`}
{editableName && <b style={{ color: "red" }}> *</b>}
</label>
<div class="mt-2">
@@ -362,9 +362,7 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
/>
</div>
<p class="mt-2 text-sm text-gray-500">
- <i18n.Translate>
- name of the person owner the account
- </i18n.Translate>
+ <i18n.Translate>Name of the account holder</i18n.Translate>
</p>
</div>
@@ -374,8 +372,8 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
label={i18n.str`Internal IBAN`}
help={
purpose === "create"
- ? i18n.str`if empty a random account number will be assigned`
- : i18n.str`account identification for bank transfer`
+ ? i18n.str`If empty a random account number will be assigned`
+ : i18n.str`Account number for bank transfers`
}
value={(form.payto_uri ?? defaultValue.payto_uri) as PaytoString}
disabled={!editableAccount}
@@ -444,12 +442,12 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
</div>
</div>
- {showingCurrentUserInfo && (
+ {showingCurrentUserInfo && isCashoutEnabled && (
<PaytoField
type="iban"
name="cashout-account"
label={i18n.str`Cashout IBAN`}
- help={i18n.str`account number where the money is going to be sent when doing cashouts`}
+ help={i18n.str`External account number where the money is going to be sent when doing cashouts`}
value={
(form.cashout_payto_uri ??
defaultValue.cashout_payto_uri) as PaytoString
@@ -492,7 +490,7 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
/>
<p class="mt-2 text-sm text-gray-500">
<i18n.Translate>
- how much is user able to transfer after zero balance
+ How much is user able to transfer after zero balance
</i18n.Translate>
</p>
</div>
@@ -539,19 +537,8 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
</div>
)}
{/* channel, not shown if old cashout api */}
- {OLD_CASHOUT_API ? undefined : config.supported_tan_channels
- .length === 0 ? (
- <div class="sm:col-span-5">
- <Attention
- type="warning"
- title={i18n.str`No cashout channel available`}
- >
- <i18n.Translate>
- This server doesn't support second factor authentication.
- </i18n.Translate>
- </Attention>
- </div>
- ) : (
+ {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"
@@ -597,7 +584,7 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
</span>
{purpose !== "show" &&
!hasEmail &&
- i18n.str`add a email in your profile to enable this option`}
+ i18n.str`Add a email in your profile to enable this option`}
</span>
</span>
<svg
@@ -655,7 +642,7 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
</span>
{purpose !== "show" &&
!hasPhone &&
- i18n.str`add a phone number in your profile to enable this option`}
+ i18n.str`Add a phone number in your profile to enable this option`}
</span>
</span>
<svg
@@ -702,7 +689,7 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
aria-labelledby="availability-label"
aria-describedby="availability-description"
onClick={() => {
- form.isPublic = !form.isPublic;
+ form.isPublic = !(form.isPublic ?? defaultValue.isPublic);
updateForm(structuredClone(form));
}}
>
@@ -717,7 +704,7 @@ export function AccountForm<PurposeType extends keyof ChangeByPurposeType>({
</div>
<p class="mt-2 text-sm text-gray-500">
<i18n.Translate>
- public accounts have their balance publicly accessible
+ Public accounts have their balance publicly accessible
</i18n.Translate>
</p>
</div>