import { VNode, h } from "preact"; import { allForms } from "./AntiMoneyLaunderingForm.js"; import { Pages } from "../pages.js"; import { NiceForm } from "../NiceForm.js"; import { AbsoluteTime, Amounts, TalerExchangeApi, TalerProtocolTimestamp } from "@gnu-taler/taler-util"; import { AmlExchangeBackend } from "../types.js"; import { useOfficer } from "../hooks/useOfficer.js"; import { HandleAccountNotReady } from "./HandleAccountNotReady.js"; import { useExchangeApiContext } from "../context/config.js"; export function NewFormEntry({ account, type, }: { account?: string; type?: string; }): VNode { const officer = useOfficer(); if (!account) { return
no account
; } if (!type) { return ; } if (officer.state !== "ready") { return ; } const selectedForm = Number.parseInt(type ?? "0", 10); if (Number.isNaN(selectedForm)) { return
WHAT! {type}
; } const showingFrom = allForms[selectedForm].impl; const formName = allForms[selectedForm].name const initial = { fullName: "loggedIn_user_fullname", when: AbsoluteTime.now(), state: AmlExchangeBackend.AmlState.pending, threshold: Amounts.parseOrThrow("KUDOS:1000"), }; const { api } = useExchangeApiContext() return ( { if (formValue.state === undefined || formValue.threshold === undefined) return; const justification = { index: selectedForm, name: formName, value: formValue } const decision: TalerExchangeApi.AmlDecision = { justification: JSON.stringify(justification), decision_time: TalerProtocolTimestamp.now(), h_payto: account, new_state: formValue.state, new_threshold: Amounts.stringify(formValue.threshold), officer_sig: "", kyc_requirements: undefined } // const signature = buildDecisionSignature(officer.account.signingKey, decision); // decision.officer_sig = signature api.addDecisionDetails(officer.account, decision); // alert(JSON.stringify(formValue)); }} >
Cancel
); } function SelectForm({ account }: { account: string }) { return (
New form for account: {account}
{allForms.map((form, idx) => { return ( {form.name} ); })}
); }