aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/paths/instance/transfers/create/CreatePage.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/transfers/create/CreatePage.tsx')
-rw-r--r--packages/merchant-backoffice-ui/src/paths/instance/transfers/create/CreatePage.tsx33
1 files changed, 16 insertions, 17 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/transfers/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/transfers/create/CreatePage.tsx
index 91aabe58e..d3a1d7832 100644
--- a/packages/merchant-backoffice-ui/src/paths/instance/transfers/create/CreatePage.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/instance/transfers/create/CreatePage.tsx
@@ -35,6 +35,7 @@ import {
CROCKFORD_BASE32_REGEX,
URL_REGEX,
} from "../../../../utils/constants.js";
+import { undefinedIfEmpty } from "../../../../utils/table.js";
type Entity = TalerMerchantApi.TransferInformation;
@@ -54,26 +55,24 @@ export function CreatePage({ accounts, onCreate, onBack }: Props): VNode {
credit_amount: `` as AmountString,
});
- const errors: FormErrors<Entity> = {
+ const errors = undefinedIfEmpty<FormErrors<Entity>>({
wtid: !state.wtid
- ? i18n.str`cannot be empty`
+ ? i18n.str`Required`
: !CROCKFORD_BASE32_REGEX.test(state.wtid)
- ? i18n.str`check the id, does not look valid`
- : state.wtid.length !== 52
- ? i18n.str`should have 52 characters, current ${state.wtid.length}`
- : undefined,
- payto_uri: !state.payto_uri ? i18n.str`cannot be empty` : undefined,
- credit_amount: !state.credit_amount ? i18n.str`cannot be empty` : undefined,
+ ? i18n.str`Check the id, does not look valid`
+ : state.wtid.length !== 52
+ ? i18n.str`Must have 52 characters, current ${state.wtid.length}`
+ : undefined,
+ payto_uri: !state.payto_uri ? i18n.str`Required` : undefined,
+ credit_amount: !state.credit_amount ? i18n.str`Required` : undefined,
exchange_url: !state.exchange_url
- ? i18n.str`cannot be empty`
+ ? i18n.str`Required`
: !URL_REGEX.test(state.exchange_url)
- ? i18n.str`URL doesn't have the right format`
- : undefined,
- };
+ ? i18n.str`URL doesn't have the right format`
+ : undefined,
+ });
- const hasErrors = Object.keys(errors).some(
- (k) => (errors as any)[k] !== undefined,
- );
+ const hasErrors = errors !== undefined;
const submitForm = () => {
if (hasErrors) return Promise.reject();
@@ -102,7 +101,7 @@ export function CreatePage({ accounts, onCreate, onBack }: Props): VNode {
name="wtid"
label={i18n.str`Wire transfer ID`}
help=""
- tooltip={i18n.str`unique identifier of the wire transfer used by the exchange, must be 52 characters long`}
+ tooltip={i18n.str`Unique identifier of the wire transfer used by the exchange, must be 52 characters long`}
/>
<Input<Entity>
name="exchange_url"
@@ -128,7 +127,7 @@ export function CreatePage({ accounts, onCreate, onBack }: Props): VNode {
data-tooltip={
hasErrors
? i18n.str`Need to complete marked fields`
- : "confirm operation"
+ : i18n.str`Confirm operation`
}
onClick={submitForm}
>