From 228324bb4411515675930e68eece2045dcafe12a Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 3 Jun 2024 12:42:53 -0300 Subject: support noContent --- .../src/paths/instance/accounts/create/index.tsx | 41 +--------------------- .../taler-util/src/http-client/bank-revenue.ts | 4 +++ packages/web-util/src/components/CopyButton.tsx | 2 +- 3 files changed, 6 insertions(+), 41 deletions(-) (limited to 'packages') 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 fa86271c3..4849d1d6c 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 @@ -73,7 +73,7 @@ export default function CreateValidator({ onConfirm, onBack }: Props): VNode { message: i18n.str`Could not create account`, type: "ERROR", description: i18n.str`The request to check the revenue API failed.`, - details: resp.errorDetail + details: JSON.stringify(resp.errorDetail, undefined, 2), }); return; } @@ -166,51 +166,12 @@ export async function testRevenueAPI( if (config.type === "fail") { 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") { 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) { diff --git a/packages/taler-util/src/http-client/bank-revenue.ts b/packages/taler-util/src/http-client/bank-revenue.ts index 34afe7d86..8331856a9 100644 --- a/packages/taler-util/src/http-client/bank-revenue.ts +++ b/packages/taler-util/src/http-client/bank-revenue.ts @@ -25,6 +25,7 @@ import { LibtoolVersion } from "../libtool-version.js"; import { FailCasesByMethod, ResultByMethod, + opFixedSuccess, opKnownHttpFailure, opSuccessFromHttp, opUnknownFailure, @@ -117,6 +118,9 @@ export class TalerRevenueHttpClient { switch (resp.status) { case HttpStatusCode.Ok: return opSuccessFromHttp(resp, codecForRevenueIncomingHistory()); + // FIXME: missing in docs + case HttpStatusCode.NoContent: + return opFixedSuccess({incoming_transactions: [], credit_account: "" }); case HttpStatusCode.BadRequest: return opKnownHttpFailure(resp.status, resp); case HttpStatusCode.Unauthorized: diff --git a/packages/web-util/src/components/CopyButton.tsx b/packages/web-util/src/components/CopyButton.tsx index dbb38b474..3ca3e4078 100644 --- a/packages/web-util/src/components/CopyButton.tsx +++ b/packages/web-util/src/components/CopyButton.tsx @@ -21,7 +21,7 @@ export function CopyButton({ class: clazz, children, getContent }: { children?: const [copied, setCopied] = useState(false); function copyText(): void { if (!navigator.clipboard && !window.isSecureContext) { - alert('clipboard is not available on insecure context (http)') + alert(`clipboard is not available on insecure context (http), the content is:\n${getContent()}`) } if (navigator.clipboard) { navigator.clipboard.writeText(getContent() || ""); -- cgit v1.2.3