taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit ebee97d833afca5aa668b7eac9230361d08de2d8
parent 37778e8c1f5ed91e5b79e005817c2712b329cf5e
Author: Florian Dold <florian@dold.me>
Date:   Mon, 16 Jun 2025 21:55:24 +0200

web-util: Only have one preloadedForms definition

Diffstat:
Mpackages/aml-backoffice-ui/src/pages/CaseDetails.tsx | 4++--
Mpackages/kyc-ui/dev.mjs | 4++--
Mpackages/kyc-ui/src/context/ui-forms.ts | 1+
Dpackages/kyc-ui/src/forms/index.ts | 70----------------------------------------------------------------------
Mpackages/kyc-ui/src/pages/FillForm.tsx | 5+++--
Mpackages/kyc-ui/src/pages/TriggerForms.tsx | 2+-
Mpackages/web-util/src/forms/forms-types.ts | 2--
Mpackages/web-util/src/forms/gana/multi_upload.ts | 13++++++++++---
8 files changed, 19 insertions(+), 82 deletions(-)

diff --git a/packages/aml-backoffice-ui/src/pages/CaseDetails.tsx b/packages/aml-backoffice-ui/src/pages/CaseDetails.tsx @@ -154,9 +154,9 @@ export function CaseDetails({ return ( <div class="min-w-60"> - <header class="flex items-center justify-between border-b border-white/5 px-4 py-4 sm:px-6 sm:py-6 lg:px-8"> + <header class="flex items-center justify-between border-b border-white/5 px-4 py-4 sm:px-6 sm:py-6 lg:px-8 gap-2"> <h1 class="text-base font-semibold leading-7 text-black"> - <i18n.Translate>Case history for account: </i18n.Translate> + <i18n.Translate>Case history for account:</i18n.Translate> </h1> <div>{account}</div> <CopyButton class="" getContent={() => account} /> diff --git a/packages/kyc-ui/dev.mjs b/packages/kyc-ui/dev.mjs @@ -43,6 +43,6 @@ serve({ port: 8080, source: "./src", onSourceUpdate: build, -// appSamplePath: "/kyc-spa/ZBNB5AS4F4MARC983KZ64EMHHNWGF9GDD4J0CA4EPCVERCEK64S0", -// appPath: "/kyc-spa/:token", + appSamplePath: "/kyc-spa/ZBNB5AS4F4MARC983KZ64EMHHNWGF9GDD4J0CA4EPCVERCEK64S0", + appPath: "/kyc-spa/:token", }); diff --git a/packages/kyc-ui/src/context/ui-forms.ts b/packages/kyc-ui/src/context/ui-forms.ts @@ -28,6 +28,7 @@ export type Type = UiForms; const defaultForms: UiForms = { forms: [], }; + const Context = createContext<Type>(defaultForms); export type BaseForm = Record<string, unknown>; diff --git a/packages/kyc-ui/src/forms/index.ts b/packages/kyc-ui/src/forms/index.ts @@ -1,70 +0,0 @@ -/* - This file is part of GNU Taler - (C) 2022-2025 Taler Systems S.A. - - GNU Taler is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -import { - acceptTos, - form_generic_note, - form_gls_merchant_onboarding, - form_gls_wallet_confirmation, - form_vqf_902_11_customer, - form_vqf_902_11_officer, - form_vqf_902_14, - form_vqf_902_1_customer, - form_vqf_902_1_officer, - form_vqf_902_4, - form_vqf_902_5, - form_vqf_902_9_customer, - form_vqf_902_9_officer, - FormMetadata, - InternationalizationAPI, -} from "@gnu-taler/web-util/browser"; -import { nameAndDob } from "../../../web-util/src/forms/gana/nameAndBirthdate.js"; -import { simplest } from "../../../web-util/src/forms/gana/simplest.js"; - -export const preloadedForms: ( - i18n: InternationalizationAPI, -) => Array<FormMetadata> = (i18n) => [ - { - label: i18n.str`Simple comment`, - id: "__simple_comment", - version: 1, - config: simplest(i18n), - }, - { - label: i18n.str`Terms of Service`, - id: "accept-tos", - version: 1, - config: (context: any) => acceptTos(i18n, context), - }, - { - label: i18n.str`Name and birthdate`, - id: "name_and_dob", - version: 1, - config: nameAndDob(i18n), - }, - form_vqf_902_1_customer(i18n), - form_vqf_902_1_officer(i18n), - form_vqf_902_4(i18n), - form_vqf_902_5(i18n), - form_vqf_902_9_customer(i18n), - form_vqf_902_9_officer(i18n), - form_vqf_902_11_customer(i18n), - form_vqf_902_11_officer(i18n), - form_vqf_902_14(i18n), - form_generic_note(i18n), - form_gls_merchant_onboarding(i18n), - form_gls_wallet_confirmation(i18n), -]; diff --git a/packages/kyc-ui/src/pages/FillForm.tsx b/packages/kyc-ui/src/pages/FillForm.tsx @@ -31,6 +31,7 @@ import { InternationalizationAPI, Loading, LocalNotificationBanner, + preloadedForms, useAsyncAsHook, useExchangeApiContext, useLocalNotificationHandler, @@ -40,7 +41,6 @@ import { Fragment, VNode, h } from "preact"; import { useFormMeta } from "../../../web-util/src/hooks/useForm.js"; import { usePreferences } from "../context/preferences.js"; import { useUiFormsContext } from "../context/ui-forms.js"; -import { preloadedForms } from "../forms/index.js"; type Props = { token: AccessToken; @@ -50,9 +50,9 @@ type Props = { }; type FormType = { - form_id: string; [TalerFormAttributes.FORM_ID]: string; [TalerFormAttributes.FORM_VERSION]: number; + [TalerFormAttributes.FORM_CONTEXT]?: any; }; async function getContextByFormId( @@ -124,6 +124,7 @@ function ShowForm({ async () => { validatedForm[TalerFormAttributes.FORM_ID] = theForm.id; validatedForm[TalerFormAttributes.FORM_VERSION] = theForm.version; + validatedForm[TalerFormAttributes.FORM_CONTEXT] = formContext; return lib.exchange.uploadKycForm(reqId, validatedForm); }, (res) => { diff --git a/packages/kyc-ui/src/pages/TriggerForms.tsx b/packages/kyc-ui/src/pages/TriggerForms.tsx @@ -17,13 +17,13 @@ import { FormMetadata, FormUI, LocalNotificationBanner, + preloadedForms, UIHandlerId, useFormMeta, useLocalNotificationHandler, useTranslationContext, } from "@gnu-taler/web-util/browser"; import { Fragment, h, VNode } from "preact"; -import { preloadedForms } from "../forms/index.js"; type FormType = { form: string; diff --git a/packages/web-util/src/forms/forms-types.ts b/packages/web-util/src/forms/forms-types.ts @@ -603,7 +603,5 @@ export type FormMetadata = { }; export interface UiForms { - // Where libeufin backend is localted - // default: window.origin without "webui/" forms: Array<FormMetadata>; } diff --git a/packages/web-util/src/forms/gana/multi_upload.ts b/packages/web-util/src/forms/gana/multi_upload.ts @@ -25,6 +25,7 @@ export interface MultiUploadContext { REQUESTED_FILE_ID: string; REQUESTED_FILE_TITLE: string; REQUESTED_FILE_DESCRIPTION: string; + REQUESTED_FILE_REQUIRED?: boolean; }[]; } @@ -48,16 +49,22 @@ export function design_multi_upload( return { type: "double-column", sections: context.REQUESTED_FILES.map((x, i) => { + let fileId: string; + if (x.REQUESTED_FILE_ID != null) { + fileId = x.REQUESTED_FILE_ID; + } else { + fileId = `file_${String(i).padStart(4, "0")}`; + } return { title: i18n.str`Document upload (${x.REQUESTED_FILE_TITLE})`, - description: `${x.REQUESTED_FILE_DESCRIPTION}`, + description: x.REQUESTED_FILE_DESCRIPTION ?? undefined, fields: [ { - id: `FILE_MAP.${x.REQUESTED_FILE_ID}`, + id: `FILE_MAP.${fileId}`, label: i18n.str`File (PDF)`, type: "file", accept: "application/pdf", - required: false, + required: x.REQUESTED_FILE_REQUIRED ?? true, }, ], };