diff options
Diffstat (limited to 'packages/aml-backoffice-ui/src/pages/CaseUpdate.tsx')
-rw-r--r-- | packages/aml-backoffice-ui/src/pages/CaseUpdate.tsx | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/packages/aml-backoffice-ui/src/pages/CaseUpdate.tsx b/packages/aml-backoffice-ui/src/pages/CaseUpdate.tsx index 7801625d0..87f1aed5f 100644 --- a/packages/aml-backoffice-ui/src/pages/CaseUpdate.tsx +++ b/packages/aml-backoffice-ui/src/pages/CaseUpdate.tsx @@ -117,7 +117,7 @@ export function CaseUpdate({ ); }); - const [form, state] = useFormState<FormType>(shape, initial, (st) => { + const { handler, status } = useFormState<FormType>(shape, initial, (st) => { const partialErrors = undefinedIfEmpty<FormErrors<FormType>>({ state: st.state === undefined ? i18n.str`required` : undefined, threshold: !st.threshold ? i18n.str`required` : undefined, @@ -143,7 +143,7 @@ export function CaseUpdate({ }; }); - const validatedForm = state.status !== "ok" ? undefined : state.result; + const validatedForm = status.status !== "ok" ? undefined : status.result; const submitHandler = validatedForm === undefined @@ -157,31 +157,37 @@ export function CaseUpdate({ value: validatedForm, }; - const decision: Omit<TalerExchangeApi.AmlDecision, "officer_sig"> = - { - justification: JSON.stringify(justification), - decision_time: TalerProtocolTimestamp.now(), - h_payto: account, - new_state: justification.value - .state as TalerExchangeApi.AmlState, - new_threshold: Amounts.stringify( - justification.value.threshold as AmountJson, - ), - kyc_requirements: undefined, - }; + const decision: Omit< + TalerExchangeApi.AmlDecisionRequest, + "officer_sig" + > = { + justification: JSON.stringify(justification), + decision_time: TalerProtocolTimestamp.now(), + h_payto: account, + keep_investigating: false, + new_rules: { + custom_measures: {}, + expiration_time: { + t_s: "never", + }, + rules: [], + successor_measure: undefined, + }, + properties: {}, + new_measures: undefined, + }; - return api.addDecisionDetails(officer.account, decision); + return api.makeAmlDesicion(officer.account, decision); }, () => { - window.location.href = privatePages.cases.url({}); + window.location.href = privatePages.profile.url({}); }, (fail) => { switch (fail.case) { case HttpStatusCode.Forbidden: - case HttpStatusCode.Unauthorized: return i18n.str`Wrong credentials for "${officer.account}"`; case HttpStatusCode.NotFound: - return i18n.str`Officer or account not found`; + return i18n.str`The account was not found`; case HttpStatusCode.Conflict: return i18n.str`Officer disabled or more recent decision was already submitted.`; default: @@ -218,7 +224,7 @@ export function CaseUpdate({ fields={convertUiField( i18n, section.fields, - form, + handler, getConverterById, )} /> |