From c019f4c040e82baebdbbda8208f10be2fbc19566 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 8 Jan 2024 16:22:48 -0300 Subject: duration label --- .../paths/instance/orders/create/CreatePage.tsx | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'packages/merchant-backoffice-ui/src/paths/instance') 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 a30f79169..fbfd023c1 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 @@ -22,7 +22,7 @@ import { AbsoluteTime, Amounts, Duration, TalerProtocolDuration } from "@gnu-taler/taler-util"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { format, isFuture } from "date-fns"; -import { Fragment, VNode, h } from "preact"; +import { ComponentChildren, Fragment, VNode, h } from "preact"; import { useEffect, useState } from "preact/hooks"; import { FormErrors, @@ -334,10 +334,6 @@ export function CreatePage({ // user required to set the taler options const requiresSomeTalerOptions = noDefault_payDeadline || noDefault_wireDeadline - const whenPay = !value.payments?.pay_deadline ? undefined : AbsoluteTime.addDuration(AbsoluteTime.now(), value.payments.pay_deadline) - const whenRefund = !value.payments?.refund_deadline ? undefined : AbsoluteTime.addDuration(AbsoluteTime.now(), value.payments.refund_deadline) - const whenWire = !value.payments?.wire_transfer_deadline ? undefined : AbsoluteTime.addDuration(AbsoluteTime.now(), value.payments.wire_transfer_deadline) - const whenAutoRefund = !value.payments?.auto_refund_deadline ? undefined : AbsoluteTime.addDuration(AbsoluteTime.now(), value.payments.auto_refund_deadline) return (
@@ -500,7 +496,7 @@ export function CreatePage({ {(settings.advanceOrderMode || noDefault_payDeadline) && } withForever withoutClear tooltip={i18n.str`Time for the customer to pay for the offer before it expires. Inventory products will be reserved until this deadline. Time start to run after the order is created.`} @@ -524,7 +520,7 @@ export function CreatePage({ {settings.advanceOrderMode && } withForever withoutClear tooltip={i18n.str`Time while the order can be refunded by the merchant. Time starts after the order is created.`} @@ -547,7 +543,7 @@ export function CreatePage({ {(settings.advanceOrderMode || noDefault_wireDeadline) && } withoutClear withForever tooltip={i18n.str`Time for the exchange to make the wire transfer. Time starts after the order is created.`} @@ -569,8 +565,8 @@ export function CreatePage({ />} {settings.advanceOrderMode && } tooltip={i18n.str`Time until which the wallet will automatically check for refunds without user interaction.`} withForever />} @@ -691,3 +687,19 @@ function asProduct(p: ProductAndQuantity): MerchantBackend.Product { } +function DeadlineHelp({ duration }: { duration?: Duration }): VNode { + const { i18n } = useTranslationContext(); + const [now, setNow] = useState(AbsoluteTime.now()) + useEffect(() => { + const iid = setInterval(() => { + setNow(AbsoluteTime.now()) + }, 60 * 1000) + return () => { + clearInterval(iid) + } + }) + if (!duration) return Disabled + const when = AbsoluteTime.addDuration(now, duration) + if (when.t_ms === "never") return No deadline + return Deadline at {format(when.t_ms, "dd/MM/yy HH:mm")} +} -- cgit v1.2.3