diff options
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths')
3 files changed, 3 insertions, 18 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx index 16f22ea4b..0d7681e1d 100644 --- a/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx +++ b/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx @@ -33,6 +33,7 @@ import { Translate, useTranslator } from "../../../i18n/index.js"; import { DefaultInstanceFormFields } from "../../../components/instance/DefaultInstanceFormFields.js"; import { INSTANCE_ID_REGEX, PAYTO_REGEX } from "../../../utils/constants.js"; import { Amounts } from "@gnu-taler/taler-util"; +import { undefinedIfEmpty } from "../../../utils/table.js"; export type Entity = MerchantBackend.Instances.InstanceConfigurationMessage & { auth_token?: string; @@ -54,12 +55,6 @@ function with_defaults(id?: string): Partial<Entity> { }; } -function undefinedIfEmpty<T>(obj: T): T | undefined { - return Object.keys(obj).some((k) => (obj as any)[k] !== undefined) - ? obj - : undefined; -} - export function CreatePage({ onCreate, onBack, forceId }: Props): VNode { const [value, valueHandler] = useState(with_defaults(forceId)); const [isTokenSet, updateIsTokenSet] = useState<boolean>(false); diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx index fa0dd7a5a..56bb65b90 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx @@ -42,6 +42,7 @@ import { InventoryProductForm } from "../../../../components/product/InventoryPr import { NonInventoryProductFrom } from "../../../../components/product/NonInventoryProductForm.js"; import { InputNumber } from "../../../../components/form/InputNumber.js"; import { InputBoolean } from "../../../../components/form/InputBoolean.js"; +import { undefinedIfEmpty } from "../../../../utils/table.js"; interface Props { onCreate: (d: MerchantBackend.Orders.PostOrderRequest) => void; @@ -126,12 +127,6 @@ const stringIsValidJSON = (value: string) => { } }; -function undefinedIfEmpty<T>(obj: T): T | undefined { - return Object.keys(obj).some((k) => (obj as any)[k] !== undefined) - ? obj - : undefined; -} - export function CreatePage({ onCreate, onBack, diff --git a/packages/merchant-backoffice-ui/src/paths/instance/update/UpdatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/update/UpdatePage.tsx index fb4794bf0..b5328249a 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/update/UpdatePage.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/update/UpdatePage.tsx @@ -34,6 +34,7 @@ import { Translate, useTranslator } from "../../../i18n/index.js"; import { DefaultInstanceFormFields } from "../../../components/instance/DefaultInstanceFormFields.js"; import { PAYTO_REGEX } from "../../../utils/constants.js"; import { Amounts } from "@gnu-taler/taler-util"; +import { undefinedIfEmpty } from "../../../utils/table.js"; type Entity = MerchantBackend.Instances.InstanceReconfigurationMessage & { auth_token?: string; @@ -70,12 +71,6 @@ function getTokenValuePart(t?: string): string | undefined { return match[1]; } -function undefinedIfEmpty<T>(obj: T): T | undefined { - return Object.keys(obj).some((k) => (obj as any)[k] !== undefined) - ? obj - : undefined; -} - export function UpdatePage({ onUpdate, onChangeAuth, |