aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx')
-rw-r--r--packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx96
1 files changed, 38 insertions, 58 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 14e2fcb46..a8108251d 100644
--- a/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx
@@ -19,7 +19,6 @@
* @author Sebastian Javier Marchano (sebasjm)
*/
-import { Amounts } from "@gnu-taler/taler-util";
import { useTranslationContext } from "@gnu-taler/web-util/browser";
import { h, VNode } from "preact";
import { useState } from "preact/hooks";
@@ -29,9 +28,8 @@ import {
FormProvider,
} from "../../../components/form/FormProvider.js";
import { DefaultInstanceFormFields } from "../../../components/instance/DefaultInstanceFormFields.js";
-import { SetTokenNewInstanceModal } from "../../../components/modal/index.js";
import { MerchantBackend } from "../../../declaration.js";
-import { INSTANCE_ID_REGEX, PAYTO_REGEX } from "../../../utils/constants.js";
+import { INSTANCE_ID_REGEX } from "../../../utils/constants.js";
import { undefinedIfEmpty } from "../../../utils/table.js";
export type Entity = MerchantBackend.Instances.InstanceConfigurationMessage & {
@@ -47,19 +45,19 @@ interface Props {
function with_defaults(id?: string): Partial<Entity> {
return {
id,
- accounts: [],
+ // accounts: [],
user_type: "business",
+ use_stefan: false,
default_pay_delay: { d_us: 2 * 1000 * 60 * 60 * 1000 }, // two hours
- default_wire_fee_amortization: 1,
default_wire_transfer_delay: { d_us: 1000 * 2 * 60 * 60 * 24 * 1000 }, // two days
};
}
export function CreatePage({ onCreate, onBack, forceId }: Props): VNode {
const [value, valueHandler] = useState(with_defaults(forceId));
- const [isTokenSet, updateIsTokenSet] = useState<boolean>(false);
- const [isTokenDialogActive, updateIsTokenDialogActive] =
- useState<boolean>(false);
+ // const [isTokenSet, updateIsTokenSet] = useState<boolean>(false);
+ // const [isTokenDialogActive, updateIsTokenDialogActive] =
+ // useState<boolean>(false);
const { i18n } = useTranslationContext();
@@ -67,42 +65,24 @@ export function CreatePage({ onCreate, onBack, forceId }: Props): VNode {
id: !value.id
? i18n.str`required`
: !INSTANCE_ID_REGEX.test(value.id)
- ? i18n.str`is not valid`
- : undefined,
+ ? i18n.str`is not valid`
+ : undefined,
name: !value.name ? i18n.str`required` : undefined,
user_type: !value.user_type
? i18n.str`required`
: value.user_type !== "business" && value.user_type !== "individual"
- ? i18n.str`should be business or individual`
- : undefined,
- accounts:
- !value.accounts || !value.accounts.length
- ? i18n.str`required`
- : undefinedIfEmpty(
- value.accounts.map((p) => {
- return !PAYTO_REGEX.test(p.payto_uri)
- ? i18n.str`is not valid`
- : undefined;
- }),
- ),
- default_max_deposit_fee: !value.default_max_deposit_fee
- ? i18n.str`required`
- : !Amounts.parse(value.default_max_deposit_fee)
- ? i18n.str`invalid format`
- : undefined,
- default_max_wire_fee: !value.default_max_wire_fee
- ? i18n.str`required`
- : !Amounts.parse(value.default_max_wire_fee)
- ? i18n.str`invalid format`
- : undefined,
- default_wire_fee_amortization:
- value.default_wire_fee_amortization === undefined
- ? i18n.str`required`
- : isNaN(value.default_wire_fee_amortization)
- ? i18n.str`is not a number`
- : value.default_wire_fee_amortization < 1
- ? i18n.str`must be 1 or greater`
+ ? i18n.str`should be business or individual`
: undefined,
+ // accounts:
+ // !value.accounts || !value.accounts.length
+ // ? i18n.str`required`
+ // : undefinedIfEmpty(
+ // value.accounts.map((p) => {
+ // return !PAYTO_REGEX.test(p.payto_uri)
+ // ? i18n.str`is not valid`
+ // : undefined;
+ // }),
+ // ),
default_pay_delay: !value.default_pay_delay
? i18n.str`required`
: undefined,
@@ -129,12 +109,12 @@ export function CreatePage({ onCreate, onBack, forceId }: Props): VNode {
const submit = (): Promise<void> => {
// use conversion instead of this
- const newToken = value.auth_token;
- value.auth_token = undefined;
- value.auth =
- newToken === null || newToken === undefined
- ? { method: "external" }
- : { method: "token", token: `secret-token:${newToken}` };
+ // const newToken = value.auth_token;
+ // value.auth_token = undefined;
+ value.auth = { method: "external" }
+ // newToken === null || newToken === undefined
+ // ? { method: "external" }
+ // : { method: "token", token: `secret-token:${newToken}` };
if (!value.address) value.address = {};
if (!value.jurisdiction) value.jurisdiction = {};
// remove above use conversion
@@ -142,16 +122,16 @@ export function CreatePage({ onCreate, onBack, forceId }: Props): VNode {
return onCreate(value as Entity);
};
- function updateToken(token: string | null) {
- valueHandler((old) => ({
- ...old,
- auth_token: token === null ? undefined : token,
- }));
- }
+ // function updateToken(token: string | null) {
+ // valueHandler((old) => ({
+ // ...old,
+ // auth_token: token === null ? undefined : token,
+ // }));
+ // }
return (
<div>
- <div class="columns">
+ {/* <div class="columns">
<div class="column" />
<div class="column is-four-fifths">
{isTokenDialogActive && (
@@ -174,9 +154,9 @@ export function CreatePage({ onCreate, onBack, forceId }: Props): VNode {
)}
</div>
<div class="column" />
- </div>
+ </div> */}
- <section class="hero is-hero-bar">
+ {/* <section class="hero is-hero-bar">
<div class="hero-body">
<div class="level">
<div class="level-item has-text-centered">
@@ -186,8 +166,8 @@ export function CreatePage({ onCreate, onBack, forceId }: Props): VNode {
!isTokenSet
? "button is-danger has-tooltip-bottom"
: !value.auth_token
- ? "button has-tooltip-bottom"
- : "button is-info has-tooltip-bottom"
+ ? "button has-tooltip-bottom"
+ : "button is-info has-tooltip-bottom"
}
data-tooltip={i18n.str`change authorization configuration`}
onClick={() => updateIsTokenDialogActive(true)}
@@ -228,7 +208,7 @@ export function CreatePage({ onCreate, onBack, forceId }: Props): VNode {
</div>
</div>
</div>
- </section>
+ </section> */}
<section class="section is-main-section">
<div class="columns">
@@ -250,7 +230,7 @@ export function CreatePage({ onCreate, onBack, forceId }: Props): VNode {
)}
<AsyncButton
onClick={submit}
- disabled={!isTokenSet || hasErrors}
+ disabled={hasErrors}
data-tooltip={
hasErrors
? i18n.str`Need to complete marked fields and choose authorization method`