aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui
diff options
context:
space:
mode:
authorChristian Blättler <blatc2@bfh.ch>2023-11-28 09:44:06 +0100
committerChristian Blättler <blatc2@bfh.ch>2023-11-28 09:44:06 +0100
commitf49d24ae6e99b0a879d99855aa1b4eb183157610 (patch)
tree9e007e2745e6ec1acd07ac2558c1596709313d33 /packages/merchant-backoffice-ui
parent628a2ff35590fb37c69ad5ac075db1ba4049df1e (diff)
downloadwallet-core-f49d24ae6e99b0a879d99855aa1b4eb183157610.tar.xz
use composite type instead of enum
Diffstat (limited to 'packages/merchant-backoffice-ui')
-rw-r--r--packages/merchant-backoffice-ui/src/components/tokenfamily/TokenFamilyForm.tsx2
-rw-r--r--packages/merchant-backoffice-ui/src/declaration.d.ts5
-rw-r--r--packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/CreatePage.tsx6
-rw-r--r--packages/merchant-backoffice-ui/src/schemas/index.ts5
4 files changed, 8 insertions, 10 deletions
diff --git a/packages/merchant-backoffice-ui/src/components/tokenfamily/TokenFamilyForm.tsx b/packages/merchant-backoffice-ui/src/components/tokenfamily/TokenFamilyForm.tsx
index 3cb739aea..420466eaa 100644
--- a/packages/merchant-backoffice-ui/src/components/tokenfamily/TokenFamilyForm.tsx
+++ b/packages/merchant-backoffice-ui/src/components/tokenfamily/TokenFamilyForm.tsx
@@ -50,7 +50,7 @@ export function TokenFamilyForm({ onSubscribe, initial, alreadyExist }: Props) {
name: "",
description: "",
description_i18n: {},
- kind: MerchantBackend.TokenFamilies.TokenFamilyKind.Discount,
+ kind: "discount",
duration: { d_us: "forever" },
valid_after: { t_s: "never" },
valid_before: { t_s: "never" },
diff --git a/packages/merchant-backoffice-ui/src/declaration.d.ts b/packages/merchant-backoffice-ui/src/declaration.d.ts
index 9808f8b66..15bde2305 100644
--- a/packages/merchant-backoffice-ui/src/declaration.d.ts
+++ b/packages/merchant-backoffice-ui/src/declaration.d.ts
@@ -1528,10 +1528,7 @@ export namespace MerchantBackend {
namespace TokenFamilies {
// Kind of the token family.
- enum TokenFamilyKind {
- Discount = "discount",
- Subscription = "subscription",
- }
+ type TokenFamilyKind = "discount" | "subscription";
// POST /private/tokenfamilies
interface TokenFamilyAddDetail {
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/CreatePage.tsx
index 777066d20..7ae9bebe6 100644
--- a/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/CreatePage.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/CreatePage.tsx
@@ -25,7 +25,7 @@ import { AsyncButton } from "../../../../components/exception/AsyncButton.js";
import { MerchantBackend } from "../../../../declaration.js";
import { useListener } from "../../../../hooks/listener.js";
import { TokenFamilyForm } from "../../../../components/tokenfamily/TokenFamilyForm.js";
-import { Test } from "../../../../components/tokenfamily/Test.js";
+// import { Test } from "../../../../components/tokenfamily/Test.js";
type Entity = MerchantBackend.TokenFamilies.TokenFamilyAddDetail;
@@ -50,9 +50,9 @@ export function CreatePage({ onCreate, onBack }: Props): VNode {
<div class="columns">
<div class="column" />
<div class="column is-four-fifths">
- {/* <TokenFamilyCreateForm onSubscribe={addFormSubmitter} /> */}
+ <TokenFamilyForm onSubscribe={addFormSubmitter} />
- <Test />
+ {/* <Test /> */}
<div class="buttons is-right mt-5">
{onBack && (
diff --git a/packages/merchant-backoffice-ui/src/schemas/index.ts b/packages/merchant-backoffice-ui/src/schemas/index.ts
index 1704b0555..5bcb68021 100644
--- a/packages/merchant-backoffice-ui/src/schemas/index.ts
+++ b/packages/merchant-backoffice-ui/src/schemas/index.ts
@@ -21,9 +21,10 @@
import { isAfter, isFuture } from "date-fns";
import * as yup from "yup";
-import { AMOUNT_REGEX, PAYTO_REGEX } from "../utils/constants.js";
+import { PAYTO_REGEX } from "../utils/constants.js";
import { Amounts } from "@gnu-taler/taler-util";
import { MerchantBackend } from "../declaration.js";
+// import { MerchantBackend } from "../declaration.js";
yup.setLocale({
mixed: {
@@ -261,7 +262,7 @@ const durationSchema = yup.object().shape({
)
}).required();
-const tokenFamilyKindSchema = yup.mixed().oneOf(Object.values(MerchantBackend.TokenFamilies.TokenFamilyKind)).required();
+const tokenFamilyKindSchema = yup.mixed().oneOf<MerchantBackend.TokenFamilies.TokenFamilyKind>(["discount", "subscription"]).required();
export const TokenFamilyCreateSchema = yup.object().shape({
slug: yup.string().ensure().required(),