commit 22cefcd92bcb88771f1b198a3a00dc05e1f9e8a4
parent 263218d0a47e175c855cb8e3d4140e8a05648c7a
Author: Florian Dold <florian@dold.me>
Date: Mon, 21 Jul 2025 15:33:21 +0200
aml SPA tweaks
Diffstat:
2 files changed, 44 insertions(+), 28 deletions(-)
diff --git a/packages/aml-backoffice-ui/src/pages/Transfers.tsx b/packages/aml-backoffice-ui/src/pages/Transfers.tsx
@@ -42,8 +42,6 @@ import { ErrorLoadingWithDebug } from "../components/ErrorLoadingWithDebug.js";
import { useTransferList } from "../hooks/transfers.js";
import { Profile } from "./Profile.js";
-const TALER_SCREEN_ID = 109;
-
export function Transfers({
routeToAccountById,
account,
@@ -90,11 +88,7 @@ export function Transfers({
],
};
- const form = useForm<FormType>(
- design,
- { direction: "credit" },
- // createFormValidator(i18n),
- );
+ const form = useForm<FormType>(design, { direction: "credit" });
const direction = form.status.result.direction as
| FormType["direction"]
@@ -160,6 +154,19 @@ export function Transfers({
}
const transactions = resp.body;
+ if (!direction) {
+ return (
+ <>
+ <FormUI design={design} model={form.model} />
+ <Attention type="low" title={i18n.str`Select transaction type`}>
+ <i18n.Translate>
+ Please select a transaction type to show transactions.
+ </i18n.Translate>
+ </Attention>
+ </>
+ );
+ }
+
if (!transactions.length) {
return (
<div class="px-4 mt-8">
diff --git a/packages/aml-backoffice-ui/src/pages/decision/Rules.tsx b/packages/aml-backoffice-ui/src/pages/decision/Rules.tsx
@@ -28,7 +28,7 @@ import {
PaytoString,
PaytoUri,
TalerError,
- TranslatedString
+ TranslatedString,
} from "@gnu-taler/taler-util";
import {
Attention,
@@ -44,9 +44,9 @@ import { Fragment, h, VNode } from "preact";
import { useState } from "preact/hooks";
import { RulesInfo } from "../../components/RulesInfo.js";
import { ShowDecisionLimitInfo } from "../../components/ShowDecisionLimitInfo.js";
+import { ShowDefaultRules } from "../../components/ShowDefaultRules.js";
import { useCurrentDecisionRequest } from "../../hooks/decision-request.js";
import { useServerMeasures } from "../../hooks/server-info.js";
-import { ShowDefaultRules } from "../../components/ShowDefaultRules.js";
const TALER_SCREEN_ID = 103;
@@ -185,13 +185,12 @@ export function Rules({ newPayto }: { newPayto?: PaytoString }): VNode {
</h2>
{request.original === undefined ? (
<Fragment>
-
- <p>
- <i18n.Translate>
- There are no rules for this account yet.
- </i18n.Translate>
- </p>
- <ShowDefaultRules rules={defaultRules} />
+ <p>
+ <i18n.Translate>
+ There are no rules for this account yet.
+ </i18n.Translate>
+ </p>
+ <ShowDefaultRules rules={defaultRules} />
</Fragment>
) : (
<ShowDecisionLimitInfo
@@ -263,7 +262,6 @@ function AddNewRuleForm({
);
}
-
function UpdateRulesForm({
config,
limits,
@@ -282,18 +280,28 @@ function UpdateRulesForm({
const [showAddRuleForm, setShowAddRuleForm] = useState(false);
const measureList = !rootMeasures ? [] : Object.keys(rootMeasures);
const customMeasures = Object.keys(request.custom_measures ?? {});
- const expirationFormDesign = expirationFormDesignTemplate(i18n, [
- ...measureList,
- ...customMeasures,
- ]);
+ const allMeasure = [...measureList, ...customMeasures];
+ const expirationFormDesign = expirationFormDesignTemplate(i18n, allMeasure);
const [currentRules, setRules] = useState<KycRule[]>(
!request.rules ? limits.rules : request.rules,
);
+ let defaultSuccessorMeasure =
+ request.onExpire_measure ?? limits.successor_measure;
+
+ if (
+ defaultSuccessorMeasure &&
+ !allMeasure.includes(defaultSuccessorMeasure)
+ ) {
+ console.warn(
+ `configuration problem: default successor measure ${defaultSuccessorMeasure} not in known measures`,
+ );
+ defaultSuccessorMeasure = undefined;
+ }
const expirationForm = useForm<ExpirationFormType>(expirationFormDesign, {
expiration:
request.deadline ??
AbsoluteTime.fromProtocolTimestamp(limits.expiration_time),
- measure: request.onExpire_measure ?? limits.successor_measure,
+ measure: defaultSuccessorMeasure,
});
onComponentUnload(() => {
@@ -484,7 +492,7 @@ function UpdateRulesForm({
<i18n.Translate>Point-of-sale</i18n.Translate>
</button>
<h2 class="mt-4 mb-2">
- <i18n.Translate>On expiration behavior</i18n.Translate>
+ <i18n.Translate>Behavior on rule expiration</i18n.Translate>
</h2>
<FormUI design={expirationFormDesign} model={expirationForm.model} />
<button
@@ -612,6 +620,7 @@ const ruleFormDesignTemplate = (
},
],
});
+
const expirationFormDesignTemplate = (
i18n: InternationalizationAPI,
measureNames: string[],
@@ -626,7 +635,7 @@ const expirationFormDesignTemplate = (
choices: [
{
label: i18n.str`In a week`,
- // @ts-expect-error we have to format as string 'dd/MM/yyyy' and convert back
+ // @ts-expect-error we have to format as string 'dd/MM/yyyy' and convert back
value: AbsoluteTime.addDuration(
AbsoluteTime.now(),
Duration.fromSpec({ days: 7 }),
@@ -634,7 +643,7 @@ const expirationFormDesignTemplate = (
},
{
label: i18n.str`In a month`,
- // @ts-expect-error we have to format as string 'dd/MM/yyyy' and convert back
+ // @ts-expect-error we have to format as string 'dd/MM/yyyy' and convert back
value: AbsoluteTime.addDuration(
AbsoluteTime.now(),
Duration.fromSpec({ months: 1 }),
@@ -642,7 +651,7 @@ const expirationFormDesignTemplate = (
},
{
label: i18n.str`In a year`,
- // @ts-expect-error we have to format as string 'dd/MM/yyyy' and convert back
+ // @ts-expect-error we have to format as string 'dd/MM/yyyy' and convert back
value: AbsoluteTime.addDuration(
AbsoluteTime.now(),
Duration.fromSpec({ years: 1 }),
@@ -650,7 +659,7 @@ const expirationFormDesignTemplate = (
},
{
label: i18n.str`Never`,
- // @ts-expect-error we have to format as string 'dd/MM/yyyy' and convert back
+ // @ts-expect-error we have to format as string 'dd/MM/yyyy' and convert back
value: AbsoluteTime.never(),
},
],
@@ -661,7 +670,7 @@ const expirationFormDesignTemplate = (
placeholder: "dd/MM/yyyy",
pattern: "dd/MM/yyyy",
label: i18n.str`Expiration date`,
- help: i18n.str`For how long this rules will last`,
+ help: i18n.str`Until when are the new rules active.`,
},
{
type: "selectOne",