commit 3d6b0edeea71dac473a7a9240cfcec6b0558ebb6
parent aba933b1d11ce531a76db78d8ff34e88f8a54950
Author: Sebastian <sebasjm@taler-systems.com>
Date: Thu, 26 Mar 2026 18:22:38 -0300
fix #10595
Diffstat:
1 file changed, 29 insertions(+), 11 deletions(-)
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
@@ -71,6 +71,13 @@ const lastDayNextMonth = endOfMonth(nextMonth);
const afterLastDayNextMonth = addDays(lastDayNextMonth, 1);
const firstDayNextMonthAnd30Days = addDays(firstDayNextMonth, 30);
+const MINUTE = TalerProtocolDuration.fromSpec({minutes: 1})
+const HOUR = TalerProtocolDuration.fromSpec({hours: 1})
+const DAY = TalerProtocolDuration.fromSpec({days: 1})
+const MONTH = TalerProtocolDuration.fromSpec({days: 30})
+const THREE_MONTH = TalerProtocolDuration.fromSpec({days: 90})
+const YEAR = TalerProtocolDuration.fromSpec({days: 365})
+
export function CreatePage({ onCreated, onBack }: Props): VNode {
const { state: session, lib } = useSessionContext();
const [notification, safeFunctionHandler] = useLocalNotificationBetter();
@@ -83,7 +90,7 @@ export function CreatePage({ onCreated, onBack }: Props): VNode {
description_i18n: {},
kind: TalerMerchantApi.TokenFamilyKind.Discount,
duration: TalerProtocolDuration.forever(),
- valid_after: undefined,
+ valid_after: TalerProtocolTimestamp.now(),
valid_before: TalerProtocolTimestamp.never(),
validity_granularity: undefined,
});
@@ -220,18 +227,29 @@ export function CreatePage({ onCreated, onBack }: Props): VNode {
useProtocolDuration
/>
- <InputDurationDropdown<Entity>
+ <InputSelector
name="validity_granularity"
label={i18n.str`Validity Granularity`}
- tooltip={i18n.str`Rounds the validity to a specific unit of time (like day, hour, minute).`}
- help={i18n.str`If set to “1 day”, a 30-day pass bought on ${format(
- firstDayNextMonth,
- dateFormatForPreferences(preferences),
- )} is valid until the end of ${format(
- firstDayNextMonthAnd30Days,
- dateFormatForPreferences(preferences),
- )}, not exactly at the same time of day you purchased it.`}
- useProtocolDuration
+ tooltip={i18n.str`Rounds the validity to a specific unit of time.`}
+ values={[undefined, "MINUTE", "HOUR", "DAY", "MONTH", "THREE_MONTH", "YEAR"]}
+ toStr={(str) => {
+ if (str === "MINUTE") return i18n.str`1 minute`;
+ if (str === "HOUR") return i18n.str`1 hour`;
+ if (str === "DAY") return i18n.str`1 day`;
+ if (str === "MONTH") return i18n.str`30 days`;
+ if (str === "THREE_MONTH") return i18n.str`90 days`;
+ if (str === "YEAR") return i18n.str`365 days`;
+ return i18n.str`Select one`;
+ }}
+ fromStr={(str) => {
+ if (str === "MINUTE") return MINUTE;
+ if (str === "HOUR") return HOUR;
+ if (str === "DAY") return DAY;
+ if (str === "MONTH") return MONTH;
+ if (str === "THREE_MONTH") return THREE_MONTH;
+ if (str === "YEAR") return YEAR;
+ return undefined
+ }}
/>
<div class="buttons is-right mt-5">