taler-typescript-core

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

commit 2aaa2e999a034f5020eb8ef4a21a8fe71d92ff74
parent c63b6481d62278488dac3870c88917f39c4d2b13
Author: Sebastian <sebasjm@gmail.com>
Date:   Tue, 20 Aug 2024 12:20:42 -0300

open kyc link

Diffstat:
Mpackages/kyc-ui/src/pages/FillForm.tsx | 13++++++++++++-
Mpackages/kyc-ui/src/pages/Start.tsx | 21+++++++++++++++++++--
2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/packages/kyc-ui/src/pages/FillForm.tsx b/packages/kyc-ui/src/pages/FillForm.tsx @@ -16,6 +16,7 @@ import { AbsoluteTime, AccessToken, + Amounts, HttpStatusCode, KycRequirementInformation, assertUnreachable, @@ -131,7 +132,17 @@ export function FillForm({ payload: validatedForm, }; - return lib.exchange.uploadKycForm(reqId, information); + const fh = new FormData() + // fh.set("header", JSON.stringify(information.header)) + // fh.set("payload", JSON.stringify(information.payload)) + Object.entries(validatedForm as Record<string,string>).forEach(([key, value]) => { + if (key === "money") { + fh.set(key,Amounts.stringify(value)) + } else { + fh.set(key,(value)) + } + }) + return lib.exchange.uploadKycForm(reqId, fh); }, (res) => { onComplete(); diff --git a/packages/kyc-ui/src/pages/Start.tsx b/packages/kyc-ui/src/pages/Start.tsx @@ -22,8 +22,10 @@ import { } from "@gnu-taler/taler-util"; import { Attention, + Button, Loading, LocalNotificationBanner, + useExchangeApiContext, useLocalNotificationHandler, useTranslationContext, } from "@gnu-taler/web-util/browser"; @@ -211,6 +213,18 @@ function RequirementRow({ onFormSelected: () => void; }): VNode { const { i18n } = useTranslationContext(); + const { lib } = useExchangeApiContext(); + const [notification, withErrorHandler] = useLocalNotificationHandler(); + const reqId = req.id; + const startHandler = + !reqId ? undefined : + withErrorHandler( + async () => { + return lib.exchange.startKycProcess(reqId) + }, (res) => { + window.open(res.body.redirect_url, "_blank") + }); + switch (req.form) { case "INFO": { return ( @@ -267,10 +281,13 @@ function RequirementRow({ </div> <div class="min-w-0 flex-auto"> <p class="text-sm font-semibold leading-6 text-gray-900"> - <a href="#"> + <Button + type="submit" + handler={startHandler} + > <span class="absolute inset-x-0 -top-px bottom-0"></span> <i18n.Translate>Begin KYC process</i18n.Translate> - </a> + </Button> </p> <p class="mt-1 flex text-xs leading-5 text-gray-500"> {req.description}