[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 02/02: sane default for pay deadline and wire transf
From: |
gnunet |
Subject: |
[taler-wallet-core] 02/02: sane default for pay deadline and wire transfer and webhook docs |
Date: |
Tue, 21 Nov 2023 04:40:14 +0100 |
This is an automated email from the git hooks/post-receive script.
sebasjm pushed a commit to branch master
in repository wallet-core.
commit 79e93451394c66f7f08d25fc578c59cffb807bd0
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Tue Nov 21 00:40:04 2023 -0300
sane default for pay deadline and wire transfer and webhook docs
---
.../paths/instance/orders/create/CreatePage.tsx | 74 ++++++++++++++++------
.../paths/instance/webhooks/create/CreatePage.tsx | 46 +++++++++++---
2 files changed, 91 insertions(+), 29 deletions(-)
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 ea2cf849a..52ee9d351 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
@@ -143,7 +143,7 @@ export function CreatePage({
const instance_default = with_defaults(instanceConfig, config.currency)
const [value, valueHandler] = useState(instance_default);
const zero = Amounts.zeroOfCurrency(config.currency);
- const [settings] = useSettings()
+ const [settings, updateSettings] = useSettings()
const inventoryList = Object.values(value.inventoryProducts || {});
const productList = Object.values(value.products || {});
@@ -184,7 +184,7 @@ export function CreatePage({
? i18n.str`wire transfer deadline cannot be before refund
deadline`
: undefined,
pay_deadline: !value.payments?.pay_deadline
- ? undefined
+ ? i18n.str`required`
: !isFuture(value.payments.pay_deadline)
? i18n.str`should be in the future`
: value.payments.wire_transfer_deadline &&
@@ -194,6 +194,11 @@ export function CreatePage({
)
? i18n.str`wire transfer deadline cannot be before pay deadline`
: undefined,
+ wire_transfer_deadline: !value.payments?.wire_transfer_deadline
+ ? i18n.str`required`
+ : !isFuture(value.payments.wire_transfer_deadline)
+ ? i18n.str`should be in the future`
+ : undefined,
auto_refund_deadline: !value.payments?.auto_refund_deadline
? undefined
: !isFuture(value.payments.auto_refund_deadline)
@@ -354,9 +359,39 @@ export function CreatePage({
!prev.minimum_age || cur > prev.minimum_age ? cur : prev.minimum_age,
0,
);
+
+ const noDefault_payDeadline = !instance_default.payments ||
!instance_default.payments.pay_deadline
+ const noDefault_wireDeadline = !instance_default.payments ||
!instance_default.payments.wire_transfer_deadline
+ const requiresSomeTalerOptions = noDefault_payDeadline ||
noDefault_wireDeadline
+
return (
<div>
+
<section class="section is-main-section">
+ <div class="tabs is-toggle is-fullwidth is-small">
+ <ul>
+ <li class={!settings.advanceOrderMode ? "is-active" : ""}
onClick={() => {
+ updateSettings({
+ ...settings,
+ advanceOrderMode: false
+ })
+ }}>
+ <a >
+ <span><i18n.Translate>Simple</i18n.Translate></span>
+ </a>
+ </li>
+ <li class={settings.advanceOrderMode ? "is-active" : ""}
onClick={() => {
+ updateSettings({
+ ...settings,
+ advanceOrderMode: true
+ })
+ }}>
+ <a >
+ <span><i18n.Translate>Advanced</i18n.Translate></span>
+ </a>
+ </li>
+ </ul>
+ </div>
<div class="columns">
<div class="column" />
<div class="column is-four-fifths">
@@ -481,33 +516,34 @@ export function CreatePage({
</InputGroup>
}
- {settings.advanceOrderMode &&
+ {(settings.advanceOrderMode || requiresSomeTalerOptions) &&
<InputGroup
name="payments"
label={i18n.str`Taler payment options`}
tooltip={i18n.str`Override default Taler payment settings
for this order`}
>
- <InputDate
+ {(settings.advanceOrderMode || noDefault_payDeadline) &&
<InputDate
name="payments.pay_deadline"
label={i18n.str`Payment deadline`}
tooltip={i18n.str`Deadline for the customer to pay for the
offer before it expires. Inventory products will be reserved until this
deadline.`}
side={
<span>
<button class="button" onClick={() => {
- valueHandler({
+ const c = {
...value,
payments: {
...(value.payments ?? {}),
pay_deadline:
instance_default.payments?.pay_deadline
}
- })
+ }
+ valueHandler(c)
}}>
<i18n.Translate>default</i18n.Translate>
</button>
</span>
}
- />
- <InputDate
+ />}
+ {settings.advanceOrderMode && <InputDate
name="payments.refund_deadline"
label={i18n.str`Refund deadline`}
tooltip={i18n.str`Time until which the order can be
refunded by the merchant.`}
@@ -526,8 +562,8 @@ export function CreatePage({
</button>
</span>
}
- />
- <InputDate
+ />}
+ {(settings.advanceOrderMode || noDefault_wireDeadline) &&
<InputDate
name="payments.wire_transfer_deadline"
label={i18n.str`Wire transfer deadline`}
tooltip={i18n.str`Deadline for the exchange to make the
wire transfer.`}
@@ -546,24 +582,24 @@ export function CreatePage({
</button>
</span>
}
- />
- <InputDate
+ />}
+ {settings.advanceOrderMode && <InputDate
name="payments.auto_refund_deadline"
label={i18n.str`Auto-refund deadline`}
tooltip={i18n.str`Time until which the wallet will
automatically check for refunds without user interaction.`}
- />
+ />}
- <InputCurrency
+ {settings.advanceOrderMode && <InputCurrency
name="payments.max_fee"
label={i18n.str`Maximum fee`}
tooltip={i18n.str`Maximum fees the merchant is willing to
cover for this order. Higher deposit fees must be covered in full by the
consumer.`}
- />
- <InputToggle
+ />}
+ {settings.advanceOrderMode && <InputToggle
name="payments.createToken"
label={i18n.str`Create token`}
tooltip={i18n.str`If the order ID is easy to guess the
token will prevent user to steal orders from others.`}
- />
- <InputNumber
+ />}
+ {settings.advanceOrderMode && <InputNumber
name="payments.minimum_age"
label={i18n.str`Minimum age required`}
tooltip={i18n.str`Any value greater than 0 will limit the
coins able be used to pay this contract. If empty the age restriction will be
defined by the products`}
@@ -572,7 +608,7 @@ export function CreatePage({
? i18n.str`Min age defined by the producs is
${minAgeByProducts}`
: i18n.str`No product with age restriction in this
order`
}
- />
+ />}
</InputGroup>
}
diff --git
a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/create/CreatePage.tsx
b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/create/CreatePage.tsx
index 7b07e689e..434d69412 100644
---
a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/create/CreatePage.tsx
+++
b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/create/CreatePage.tsx
@@ -20,7 +20,7 @@
*/
import { useTranslationContext } from "@gnu-taler/web-util/browser";
-import { h, VNode } from "preact";
+import { Fragment, h, VNode } from "preact";
import { useState } from "preact/hooks";
import { AsyncButton } from "../../../../components/exception/AsyncButton.js";
import {
@@ -51,14 +51,14 @@ export function CreatePage({ onCreate, onBack }: Props):
VNode {
const errors: FormErrors<Entity> = {
webhook_id: !state.webhook_id ? i18n.str`required` : undefined,
- event_type: !state.event_type ? i18n.str`required`
- : state.event_type !== "pay" && state.event_type !== "refund" ?
i18n.str`it should be "pay" or "refund"`
- : undefined,
+ event_type: !state.event_type ? i18n.str`required`
+ : state.event_type !== "pay" && state.event_type !== "refund" ?
i18n.str`it should be "pay" or "refund"`
+ : undefined,
http_method: !state.http_method
? i18n.str`required`
: !validMethod.includes(state.http_method)
- ? i18n.str`should be one of '${validMethod.join(", ")}'`
- : undefined,
+ ? i18n.str`should be one of '${validMethod.join(", ")}'`
+ : undefined,
url: !state.url ? i18n.str`required` : undefined,
};
@@ -116,16 +116,42 @@ export function CreatePage({ onCreate, onBack }: Props):
VNode {
label={i18n.str`URL`}
tooltip={i18n.str`URL of the webhook where the customer will
be redirected`}
/>
- <Input<Entity>
+
+ <p>
+ The text below support <a target="_blank" rel="noreferrer"
href="https://mustache.github.io/mustache.5.html">mustache</a> template engine.
Any string
+ between <pre style={{ display: "inline", padding: 0
}}>{{</pre> and <pre style={{ display: "inline", padding: 0
}}>}}</pre> will
+ be replaced with replaced with the value of the correspoding
variable.
+ </p>
+ <p>
+ For example <pre style={{ display: "inline", padding: 0
}}>{{contract_terms.amount}}</pre> will be replaced
+ with the the order's price
+ </p>
+ <p>
+ The short list of variables are:
+ </p>
+ <div class="menu">
+
+ <ul class="menu-list" style={{ listStyleType: "disc",
marginLeft: 20 }}>
+ <li><b>contract_terms.summary:</b> order's description </li>
+ <li><b>contract_terms.amount:</b> order's price </li>
+ <li><b>order_id:</b> order's unique identification </li>
+ {state.event_type === "refund" && <Fragment>
+ <li><b>refund_amout:</b> the amount that was being
refunded</li>
+ <li><b>reason:</b> the reason entered by the merchant
staff for granting the refund</li>
+ <li><b>timestamp:</b> time of the refund in nanoseconds
since 1970</li>
+ </Fragment>}
+ </ul>
+ </div>
+ {/* <Input<Entity>
name="header_template"
- label={i18n.str`Header`}
+ label={i18n.str`Http header`}
inputType="multiline"
tooltip={i18n.str`Header template of the webhook`}
- />
+ /> */}
<Input<Entity>
name="body_template"
inputType="multiline"
- label={i18n.str`Body`}
+ label={i18n.str`Http body`}
tooltip={i18n.str`Body template by the webhook`}
/>
</FormProvider>
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.