diff options
author | Sebastian <sebasjm@gmail.com> | 2023-11-20 12:38:16 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-11-20 12:38:16 -0300 |
commit | 6138846050563e0dca95b0b6d792776925e4c35f (patch) | |
tree | b33cd36acf4b38d3a016506d4f7fa681c83beb63 /packages/aml-backoffice-ui/src/pages/NewFormEntry.tsx | |
parent | 7ed3e78f790837479fc2bb2eb6ddc40c78ce59b5 (diff) | |
download | wallet-core-6138846050563e0dca95b0b6d792776925e4c35f.tar.xz |
new forms api
Diffstat (limited to 'packages/aml-backoffice-ui/src/pages/NewFormEntry.tsx')
-rw-r--r-- | packages/aml-backoffice-ui/src/pages/NewFormEntry.tsx | 68 |
1 files changed, 31 insertions, 37 deletions
diff --git a/packages/aml-backoffice-ui/src/pages/NewFormEntry.tsx b/packages/aml-backoffice-ui/src/pages/NewFormEntry.tsx index 95b1f35c4..214c17648 100644 --- a/packages/aml-backoffice-ui/src/pages/NewFormEntry.tsx +++ b/packages/aml-backoffice-ui/src/pages/NewFormEntry.tsx @@ -1,13 +1,11 @@ +import { Amounts, TalerExchangeApi, TalerProtocolTimestamp, TranslatedString } from "@gnu-taler/taler-util"; +import { LocalNotificationBanner, useLocalNotification, useTranslationContext } from "@gnu-taler/web-util/browser"; import { Fragment, VNode, h } from "preact"; -import { AntiMoneyLaunderingForm, allForms } from "./AntiMoneyLaunderingForm.js"; -import { Pages } from "../pages.js"; -import { NiceForm } from "../NiceForm.js"; -import { AbsoluteTime, Amounts, TalerExchangeApi, TalerProtocolTimestamp, TranslatedString } from "@gnu-taler/taler-util"; -import { AmlExchangeBackend } from "../types.js"; +import { useExchangeApiContext } from "../context/config.js"; import { useOfficer } from "../hooks/useOfficer.js"; +import { Pages } from "../pages.js"; +import { AntiMoneyLaunderingForm, allForms } from "./AntiMoneyLaunderingForm.js"; import { HandleAccountNotReady } from "./HandleAccountNotReady.js"; -import { useExchangeApiContext } from "../context/config.js"; -import { LocalNotificationBanner, useLocalNotification, useTranslationContext } from "@gnu-taler/web-util/browser"; export function NewFormEntry({ account, @@ -31,19 +29,13 @@ export function NewFormEntry({ return <HandleAccountNotReady officer={officer} />; } - const selectedForm = Number.parseInt(type ?? "0", 10); - if (Number.isNaN(selectedForm)) { - return <div>WHAT! {type}</div>; - } - - return ( <Fragment> <LocalNotificationBanner notification={notification} /> <AntiMoneyLaunderingForm account={account} - selectedForm={selectedForm} + formId={type} onSubmit={async (justification, new_state, new_threshold) => { const decision: Omit<TalerExchangeApi.AmlDecision, "officer_sig"> = { @@ -56,27 +48,29 @@ export function NewFormEntry({ } await handleError(async () => { const resp = await api.addDecisionDetails(officer.account, decision); - if (resp.type === "fail") { - switch (resp.case) { - case "unauthorized": return notify({ - type: "error", - title: i18n.str`Wrong credentials for "${officer.account}"`, - description: resp.detail.hint as TranslatedString, - debug: resp.detail, - }) - case "officer-or-account-not-found": return notify({ - type: "error", - title: i18n.str`Officer or account not found`, - description: resp.detail.hint as TranslatedString, - debug: resp.detail, - }) - case "officer-disabled-or-recent-decision": return notify({ - type: "error", - title: i18n.str`Officer disabled or more recent decision was already submitted.`, - description: resp.detail.hint as TranslatedString, - debug: resp.detail, - }) - } + if (resp.type === "ok") { + window.location.href = Pages.cases.url; + return; + } + switch (resp.case) { + case "unauthorized": return notify({ + type: "error", + title: i18n.str`Wrong credentials for "${officer.account}"`, + description: resp.detail.hint as TranslatedString, + debug: resp.detail, + }) + case "officer-or-account-not-found": return notify({ + type: "error", + title: i18n.str`Officer or account not found`, + description: resp.detail.hint as TranslatedString, + debug: resp.detail, + }) + case "officer-disabled-or-recent-decision": return notify({ + type: "error", + title: i18n.str`Officer disabled or more recent decision was already submitted.`, + description: resp.detail.hint as TranslatedString, + debug: resp.detail, + }) } }) }} @@ -92,10 +86,10 @@ function SelectForm({ account }: { account: string }) { {allForms.map((form, idx) => { return ( <a - href={Pages.newFormEntry.url({ account, type: String(idx) })} + href={Pages.newFormEntry.url({ account, type: form.id })} class="m-4 block rounded-md w-fit border-0 p-3 py-2 text-center text-sm bg-indigo-700 text-white shadow-sm hover:bg-indigo-600" > - {form.name} + {form.label} </a> ); })} |