From 20d2861508df18da18e66c94a5a268067565121b Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 30 Apr 2024 14:21:01 -0300 Subject: testing aml form as json --- .../aml-backoffice-ui/src/pages/CaseDetails.tsx | 31 ++-- .../aml-backoffice-ui/src/pages/CaseUpdate.tsx | 39 ++--- .../aml-backoffice-ui/src/pages/CreateAccount.tsx | 1 - packages/aml-backoffice-ui/src/pages/Officer.tsx | 4 +- .../src/pages/ShowConsolidated.stories.tsx | 168 +++++++++++---------- .../src/pages/ShowConsolidated.tsx | 6 +- 6 files changed, 134 insertions(+), 115 deletions(-) (limited to 'packages/aml-backoffice-ui/src/pages') diff --git a/packages/aml-backoffice-ui/src/pages/CaseDetails.tsx b/packages/aml-backoffice-ui/src/pages/CaseDetails.tsx index e16a6a103..1ad8c9453 100644 --- a/packages/aml-backoffice-ui/src/pages/CaseDetails.tsx +++ b/packages/aml-backoffice-ui/src/pages/CaseDetails.tsx @@ -34,6 +34,7 @@ import { import { DefaultForm, ErrorLoading, + FlexibleForm, InternationalizationAPI, Loading, useTranslationContext, @@ -42,9 +43,9 @@ import { format } from "date-fns"; import { VNode, h } from "preact"; import { useState } from "preact/hooks"; import { privatePages } from "../Routing.js"; -import { BaseForm, FormMetadata, uiForms } from "../forms/declaration.js"; import { useCaseDetails } from "../hooks/useCaseDetails.js"; import { ShowConsolidated } from "./ShowConsolidated.js"; +import { FormMetadata, useUiFormsContext } from "../context/ui-forms.js"; export type AmlEvent = | AmlFormEvent @@ -56,7 +57,7 @@ type AmlFormEvent = { when: AbsoluteTime; title: TranslatedString; justification: Justification; - metadata: FormMetadata; + metadata: FormMetadata; state: TalerExchangeApi.AmlState; threshold: AmountJson; }; @@ -115,9 +116,10 @@ export function getEventsFromAmlHistory( aml: TalerExchangeApi.AmlDecisionDetail[], kyc: TalerExchangeApi.KycDetail[], i18n: InternationalizationAPI, + forms: FormMetadata[], ): AmlEvent[] { const ae: AmlEvent[] = aml.map((a) => { - const just = parseJustification(a.justification, uiForms.forms(i18n)); + const just = parseJustification(a.justification, forms); return { type: just.type === "ok" ? "aml-form" : "aml-form-error", state: a.new_state, @@ -156,11 +158,13 @@ export function CaseDetails({ account }: { account: string }) { const [selected, setSelected] = useState(AbsoluteTime.now()); const [showForm, setShowForm] = useState<{ justification: Justification; - metadata: FormMetadata; + metadata: FormMetadata; }>(); const { i18n } = useTranslationContext(); const details = useCaseDetails(account); + const {forms} = useUiFormsContext() + if (!details) { return ; } @@ -180,14 +184,14 @@ export function CaseDetails({ account }: { account: string }) { } const { aml_history, kyc_attributes } = details.body; - const events = getEventsFromAmlHistory(aml_history, kyc_attributes, i18n); + const events = getEventsFromAmlHistory(aml_history, kyc_attributes, i18n, forms); if (showForm !== undefined) { return (