summaryrefslogtreecommitdiff
path: root/packages/aml-backoffice-ui/src/pages/ShowConsolidated.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/aml-backoffice-ui/src/pages/ShowConsolidated.tsx')
-rw-r--r--packages/aml-backoffice-ui/src/pages/ShowConsolidated.tsx53
1 files changed, 13 insertions, 40 deletions
diff --git a/packages/aml-backoffice-ui/src/pages/ShowConsolidated.tsx b/packages/aml-backoffice-ui/src/pages/ShowConsolidated.tsx
index f59f8d41f..ad350c0e6 100644
--- a/packages/aml-backoffice-ui/src/pages/ShowConsolidated.tsx
+++ b/packages/aml-backoffice-ui/src/pages/ShowConsolidated.tsx
@@ -1,9 +1,10 @@
import { AbsoluteTime, AmountJson, TranslatedString } from "@gnu-taler/taler-util";
import { format } from "date-fns";
import { Fragment, VNode, h } from "preact";
-import { AmlExchangeBackend } from "../types.js";
import { AmlEvent } from "./CaseDetails.js";
-import { DefaultForm, FlexibleForm, UIFormField } from "@gnu-taler/web-util/browser";
+import { DefaultForm, FlexibleForm, UIFormField, useTranslationContext } from "@gnu-taler/web-util/browser";
+import { amlStateConverter } from "../utils/converter.js";
+import { AmlExchangeBackend } from "../utils/types.js";
export function ShowConsolidated({
history,
@@ -12,6 +13,8 @@ export function ShowConsolidated({
history: AmlEvent[];
until: AbsoluteTime;
}): VNode {
+ const { i18n } = useTranslationContext();
+
const cons = getConsolidated(history, until);
const form: FlexibleForm<Consolidated> = {
@@ -32,32 +35,32 @@ export function ShowConsolidated({
},
design: [
{
- title: "AML" as TranslatedString,
+ title: i18n.str`AML`,
fields: [
{
type: "amount",
props: {
- label: "Threshold" as TranslatedString,
+ label: i18n.str`Threshold`,
name: "aml.threshold",
},
},
{
type: "choiceHorizontal",
props: {
- label: "State" as TranslatedString,
+ label: i18n.str`State`,
name: "aml.state",
converter: amlStateConverter,
choices: [
{
- label: "Frozen" as TranslatedString,
+ label: i18n.str`Frozen`,
value: AmlExchangeBackend.AmlState.frozen,
},
{
- label: "Pending" as TranslatedString,
+ label: i18n.str`Pending`,
value: AmlExchangeBackend.AmlState.pending,
},
{
- label: "Normal" as TranslatedString,
+ label: i18n.str`Normal`,
value: AmlExchangeBackend.AmlState.normal,
},
],
@@ -67,7 +70,7 @@ export function ShowConsolidated({
},
Object.entries(cons.kyc).length > 0
? {
- title: "KYC" as TranslatedString,
+ title: i18n.str`KYC`,
fields: Object.entries(cons.kyc).map(([key, field]) => {
const result: UIFormField = {
type: "text",
@@ -167,34 +170,4 @@ function getConsolidated(
}
return prev;
}, initial);
-}
-
-export const amlStateConverter = {
- toStringUI: stringifyAmlState,
- fromStringUI: parseAmlState,
-};
-
-function stringifyAmlState(s: AmlExchangeBackend.AmlState | undefined): string {
- if (s === undefined) return "";
- switch (s) {
- case AmlExchangeBackend.AmlState.normal:
- return "normal";
- case AmlExchangeBackend.AmlState.pending:
- return "pending";
- case AmlExchangeBackend.AmlState.frozen:
- return "frozen";
- }
-}
-
-function parseAmlState(s: string | undefined): AmlExchangeBackend.AmlState {
- switch (s) {
- case "normal":
- return AmlExchangeBackend.AmlState.normal;
- case "pending":
- return AmlExchangeBackend.AmlState.pending;
- case "frozen":
- return AmlExchangeBackend.AmlState.frozen;
- default:
- throw Error(`unknown AML state: ${s}`);
- }
-}
+} \ No newline at end of file