summaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx')
-rw-r--r--packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx62
1 files changed, 60 insertions, 2 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx
index 6b8af50a9..cf1d5b0c7 100644
--- a/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx
@@ -35,6 +35,7 @@ import { Notification } from "../../../../utils/types.js";
import { LoginPage } from "../../../login/index.js";
import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js";
import { UpdatePage } from "./UpdatePage.js";
+import { testRevenueAPI } from "../create/index.js";
export type Entity = TalerMerchantApi.AccountPatchDetails & WithId;
@@ -79,8 +80,65 @@ export default function UpdateValidator({
<UpdatePage
account={{ ...result.body, id: bid }}
onBack={onBack}
- onUpdate={(data) => {
- return api.instance.updateBankAccount(state.token, bid, data)
+ onUpdate={async (request) => {
+ const revenueAPI = !request.credit_facade_url
+ ? undefined
+ : new URL("/", request.credit_facade_url);
+
+ if (revenueAPI) {
+ const resp = await testRevenueAPI(
+ revenueAPI,
+ request.credit_facade_credentials,
+ );
+ if (resp.type === "fail") {
+ switch (resp.case) {
+ case "no-config": {
+ setNotif({
+ message: i18n.str`Could not create account`,
+ type: "ERROR",
+ description: i18n.str`The endpoint doesn't seems to be a Taler Revenue API`,
+ });
+ return;
+ }
+ case "client-bad-request": {
+ setNotif({
+ message: i18n.str`Could not create account`,
+ type: "ERROR",
+ description: i18n.str`Server replied with "bad request".`,
+ });
+ return;
+ }
+ case "unauthorized": {
+ setNotif({
+ message: i18n.str`Could not create account`,
+ type: "ERROR",
+ description: i18n.str`Unauthorized, try with another credentials.`,
+ });
+ return;
+ }
+ case "not-found": {
+ setNotif({
+ message: i18n.str`Could not create account`,
+ type: "ERROR",
+ description: i18n.str`Check facade URL, server replied with "not found".`,
+ });
+ return;
+ }
+ case "error": {
+ setNotif({
+ message: i18n.str`Could not create account`,
+ type: "ERROR",
+ description: resp.detail.hint,
+ });
+ return;
+ }
+ default: {
+ assertUnreachable(resp)
+ }
+ }
+ }
+ }
+ return api.instance.updateBankAccount(state.token, bid, request)
.then(onConfirm)
.catch((error) => {
setNotif({