aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx')
-rw-r--r--packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx143
1 files changed, 67 insertions, 76 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx
index 9bab33f6f..fa86271c3 100644
--- a/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/index.tsx
@@ -68,50 +68,45 @@ export default function CreateValidator({ onConfirm, onBack }: Props): VNode {
revenueAPI,
request.credit_facade_credentials,
);
+ if (resp instanceof TalerError) {
+ setNotif({
+ message: i18n.str`Could not create account`,
+ type: "ERROR",
+ description: i18n.str`The request to check the revenue API failed.`,
+ details: resp.errorDetail
+ });
+ return;
+ }
if (resp.type === "fail") {
switch (resp.case) {
- case TestRevenueErrorType.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 TestRevenueErrorType.CLIENT_BAD_REQUEST: {
+ case HttpStatusCode.BadRequest: {
setNotif({
message: i18n.str`Could not create account`,
type: "ERROR",
description: i18n.str`Server replied with "bad request".`,
});
return;
+
}
- case TestRevenueErrorType.UNAUTHORIZED: {
+ case HttpStatusCode.Unauthorized: {
setNotif({
message: i18n.str`Could not create account`,
type: "ERROR",
description: i18n.str`Unauthorized, try with another credentials.`,
});
return;
+
}
- case TestRevenueErrorType.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 TestRevenueErrorType.GENERIC_ERROR: {
+ case HttpStatusCode.NotFound: {
setNotif({
message: i18n.str`Could not create account`,
type: "ERROR",
- description: resp.detail.hint,
+ description: i18n.str`The endpoint doesn't seems to be a Taler Revenue API`,
});
return;
}
default: {
- assertUnreachable(resp.case);
+ assertUnreachable(resp);
}
}
}
@@ -146,7 +141,10 @@ export enum TestRevenueErrorType {
export async function testRevenueAPI(
revenueAPI: URL,
creds: FacadeCredentials | undefined,
-): Promise<OperationOk<void> | OperationFail<TestRevenueErrorType>> {
+): Promise<OperationOk<void> | OperationFail<HttpStatusCode.NotFound>
+| OperationFail<HttpStatusCode.Unauthorized>
+| OperationFail<HttpStatusCode.BadRequest>
+| TalerError> {
const api = new TalerRevenueHttpClient(
revenueAPI.href,
new BrowserFetchHttpLib(),
@@ -167,68 +165,61 @@ export async function testRevenueAPI(
const config = await api.getConfig(auth);
if (config.type === "fail") {
- switch (config.case) {
- case HttpStatusCode.Unauthorized: {
- return {
- type: "fail",
- case: TestRevenueErrorType.UNAUTHORIZED,
- detail: {
- code: 1,
- },
- };
- }
- case HttpStatusCode.NotFound: {
- return {
- type: "fail",
- case: TestRevenueErrorType.NO_CONFIG,
- detail: {
- code: 1,
- },
- };
- }
- }
+ return config;
+ // switch (config.case) {
+ // case HttpStatusCode.Unauthorized: {
+ // return {
+ // type: "fail",
+ // case: TestRevenueErrorType.UNAUTHORIZED,
+ // detail: config.detail,
+ // };
+ // }
+ // case HttpStatusCode.NotFound: {
+ // return {
+ // type: "fail",
+ // case: TestRevenueErrorType.NO_CONFIG,
+ // detail: config.detail,
+ // };
+ // }
+ // }
}
const history = await api.getHistory(auth);
if (history.type === "fail") {
- switch (history.case) {
- case HttpStatusCode.BadRequest: {
- return {
- type: "fail",
- case: TestRevenueErrorType.CLIENT_BAD_REQUEST,
- detail: {
- code: 1,
- },
- };
- }
- case HttpStatusCode.Unauthorized: {
- return {
- type: "fail",
- case: TestRevenueErrorType.UNAUTHORIZED,
- detail: {
- code: 1,
- },
- };
- }
- case HttpStatusCode.NotFound: {
- return {
- type: "fail",
- case: TestRevenueErrorType.NOT_FOUND,
- detail: {
- code: 1,
- },
- };
- }
- }
+ return history;
+ // switch (history.case) {
+ // case HttpStatusCode.BadRequest: {
+ // return {
+ // type: "fail",
+ // case: TestRevenueErrorType.CLIENT_BAD_REQUEST,
+ // detail: history.detail,
+ // };
+ // }
+ // case HttpStatusCode.Unauthorized: {
+ // return {
+ // type: "fail",
+ // case: TestRevenueErrorType.UNAUTHORIZED,
+ // detail: history.detail,
+ // };
+ // }
+ // case HttpStatusCode.NotFound: {
+ // return {
+ // type: "fail",
+ // case: TestRevenueErrorType.NOT_FOUND,
+ // detail: history.detail,
+ // };
+ // }
+ // }
}
} catch (err) {
if (err instanceof TalerError) {
- return {
- type: "fail",
- case: TestRevenueErrorType.GENERIC_ERROR,
- detail: err.errorDetail,
- };
+ return err;
+ // return {
+ // type: "fail",
+ // case: TestRevenueErrorType.GENERIC_ERROR,
+ // detail: err.errorDetail,
+ // };
}
}