[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: fix #8932
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: fix #8932 |
Date: |
Thu, 13 Jun 2024 20:46:21 +0200 |
This is an automated email from the git hooks/post-receive script.
sebasjm pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new ea17520cb fix #8932
ea17520cb is described below
commit ea17520cbdf0e0904605e2a18365d63ab4aeb3a6
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Thu Jun 13 15:46:15 2024 -0300
fix #8932
---
.../paths/instance/accounts/create/CreatePage.tsx | 83 +++++++++++++++++++---
.../src/paths/instance/accounts/create/index.tsx | 80 +--------------------
.../src/paths/instance/transfers/list/index.tsx | 2 +-
3 files changed, 75 insertions(+), 90 deletions(-)
diff --git
a/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx
b/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx
index 8b583308f..2f19d0c91 100644
---
a/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx
+++
b/packages/merchant-backoffice-ui/src/paths/instance/accounts/create/CreatePage.tsx
@@ -19,7 +19,13 @@
* @author Sebastian Javier Marchano (sebasjm)
*/
-import { TalerMerchantApi } from "@gnu-taler/taler-util";
+import {
+ HttpStatusCode,
+ TalerError,
+ TalerMerchantApi,
+ TranslatedString,
+ assertUnreachable,
+} from "@gnu-taler/taler-util";
import { useTranslationContext } from "@gnu-taler/web-util/browser";
import { Fragment, h, VNode } from "preact";
import { useState } from "preact/hooks";
@@ -34,6 +40,7 @@ import { InputSelector } from
"../../../../components/form/InputSelector.js";
import { ImportingAccountModal } from "../../../../components/modal/index.js";
import { undefinedIfEmpty } from "../../../../utils/table.js";
import { safeConvertURL } from "../update/UpdatePage.js";
+import { testRevenueAPI } from "./index.js";
type Entity = TalerMerchantApi.AccountAddDetails;
@@ -50,6 +57,9 @@ export function CreatePage({ onCreate, onBack }: Props):
VNode {
const [importing, setImporting] = useState(false);
const [state, setState] = useState<Partial<Entity>>({});
const facadeURL = safeConvertURL(state.credit_facade_url);
+ const [testError, setTestError] = useState<TranslatedString | undefined>(
+ undefined,
+ );
const errors: FormErrors<Entity> = {
payto_uri: !state.payto_uri ? i18n.str`required` : undefined,
@@ -110,6 +120,46 @@ export function CreatePage({ onCreate, onBack }: Props):
VNode {
credit_facade_url,
});
};
+
+ async function testAccountInfo() {
+ const revenueAPI = !state.credit_facade_url
+ ? undefined
+ : new URL("./", state.credit_facade_url);
+
+ if (revenueAPI) {
+ const resp = await testRevenueAPI(
+ revenueAPI,
+ state.credit_facade_credentials,
+ );
+ if (resp instanceof TalerError) {
+ setTestError(i18n.str`The request to check the revenue API failed.`);
+ return;
+ }
+ if (resp.type === "fail") {
+ switch (resp.case) {
+ case HttpStatusCode.BadRequest: {
+ setTestError(i18n.str`Server replied with "bad request".`);
+ return;
+ }
+ case HttpStatusCode.Unauthorized: {
+ setTestError(i18n.str`Unauthorized, try with another
credentials.`);
+
+ return;
+ }
+ case HttpStatusCode.NotFound: {
+ setTestError(
+ i18n.str`The endpoint doesn't seems to be a Taler Revenue API.`,
+ );
+ return;
+ }
+ default: {
+ assertUnreachable(resp);
+ }
+ }
+ }
+ }
+ }
+
return (
<div>
{importing && (
@@ -119,27 +169,30 @@ export function CreatePage({ onCreate, onBack }: Props):
VNode {
}}
onConfirm={(ac) => {
const u = new URL(ac.infoURL);
- const user = u.username
- const pwd = u.password
+ const user = u.username;
+ const pwd = u.password;
u.password = "";
u.username = "";
const credit_facade_url = u.href;
setState({
payto_uri: ac.accountURI,
- credit_facade_credentials: user || pwd ? {
- type: "basic",
- password: pwd,
- username: user,
- }: undefined,
+ credit_facade_credentials:
+ user || pwd
+ ? {
+ type: "basic",
+ password: pwd,
+ username: user,
+ }
+ : undefined,
credit_facade_url,
- })
+ });
// if (u.username && ac.accesToken) {
// state.credit_facade_credentials = {
// type: "bearer",
// token: ac.accesToken,
// username: u.username,
// };
- // } else
+ // } else
setImporting(false);
}}
/>
@@ -192,6 +245,16 @@ export function CreatePage({ onCreate, onBack }: Props):
VNode {
</FormProvider>
<div class="buttons is-right mt-5">
+ <button
+ class="button is-info"
+ data-tooltip={i18n.str`Need to complete marked fields`}
+ onClick={() => {
+ testAccountInfo();
+ }}
+ >
+ <i18n.Translate>Test account info</i18n.Translate>
+ </button>
+
<button
class="button is-info"
data-tooltip={i18n.str`Need to complete marked fields`}
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 7abff255c..9e0830e6e 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
@@ -52,6 +52,7 @@ export default function CreateValidator({ onConfirm, onBack
}: Props): VNode {
const { lib: api } = useSessionContext();
const { state } = useSessionContext();
const [notif, setNotif] = useState<Notification | undefined>(undefined);
+ const [tested, setTested] = useState(false);
const { i18n } = useTranslationContext();
return (
@@ -60,68 +61,6 @@ export default function CreateValidator({ onConfirm, onBack
}: Props): VNode {
<CreatePage
onBack={onBack}
onCreate={async (request: Entity) => {
- const revenueAPI = !request.credit_facade_url
- ? undefined
- : new URL("./", request.credit_facade_url);
-
- if (revenueAPI) {
- const resp = await testRevenueAPI(
- revenueAPI,
- request.credit_facade_credentials,
- request.payto_uri,
- );
- if (resp instanceof TalerError) {
- setNotif({
- message: i18n.str`Could not add bank account`,
- type: "ERROR",
- description: i18n.str`The request to check the revenue API
failed.`,
- details: JSON.stringify(resp.errorDetail, undefined, 2),
- });
- return;
- }
- if (resp.type === "fail") {
- switch (resp.case) {
- case HttpStatusCode.BadRequest: {
- setNotif({
- message: i18n.str`Could not add bank account`,
- type: "ERROR",
- description: i18n.str`Server replied with "bad request".`,
- });
- return;
-
- }
- case HttpStatusCode.Unauthorized: {
- setNotif({
- message: i18n.str`Could not add bank account`,
- type: "ERROR",
- description: i18n.str`Unauthorized, try with another
credentials.`,
- });
- return;
-
- }
- case HttpStatusCode.NotFound: {
- setNotif({
- message: i18n.str`Could not add bank account`,
- type: "ERROR",
- description: i18n.str`The endpoint doesn't seems to be a
Taler Revenue API`,
- });
- return;
- }
- case TestRevenueErrorType.ANOTHER_ACCOUNT: {
- setNotif({
- message: i18n.str`Could not add bank account`,
- type: "ERROR",
- description: i18n.str`The account info URL returned
information from an account which is not the same in the account form:
${resp.detail.hint} and ${request.payto_uri}`,
- });
- return;
- }
- default: {
- assertUnreachable(resp);
- }
- }
- }
- }
-
return api.instance
.addBankAccount(state.token, request)
.then(() => {
@@ -147,11 +86,9 @@ export enum TestRevenueErrorType {
export async function testRevenueAPI(
revenueAPI: URL,
creds: FacadeCredentials | undefined,
- account: PaytoString,
): Promise<OperationOk<void> | OperationFail<HttpStatusCode.NotFound>
| OperationFail<HttpStatusCode.Unauthorized>
| OperationFail<HttpStatusCode.BadRequest>
-| OperationFail<TestRevenueErrorType.ANOTHER_ACCOUNT>
| TalerError> {
const api = new TalerRevenueHttpClient(
revenueAPI.href,
@@ -176,21 +113,6 @@ export async function testRevenueAPI(
return config;
}
- const history = await api.getHistory(auth);
-
- if (history.type === "fail") {
- return history;
- }
- if (history.body.credit_account !== account) {
- return {
- type: "fail",
- case: TestRevenueErrorType.ANOTHER_ACCOUNT,
- detail: {
- code: 1,
- hint: history.body.credit_account
- },
- };
- }
} catch (err) {
if (err instanceof TalerError) {
return err;
diff --git
a/packages/merchant-backoffice-ui/src/paths/instance/transfers/list/index.tsx
b/packages/merchant-backoffice-ui/src/paths/instance/transfers/list/index.tsx
index 267d41711..6a16446d8 100644
---
a/packages/merchant-backoffice-ui/src/paths/instance/transfers/list/index.tsx
+++
b/packages/merchant-backoffice-ui/src/paths/instance/transfers/list/index.tsx
@@ -112,7 +112,7 @@ export default function ListTransfer({ onCreate }: Props):
VNode {
onCreate={onCreate}
onDelete={async (transfer) => {
try {
- const resp = await lib.instance.deleteWireTransfer(state.token,
transfer.wtid);
+ const resp = await lib.instance.deleteWireTransfer(state.token,
String(transfer.transfer_serial_id));
if (resp.type === "ok") {
setNotif({
message: i18n.str`Wire transfer
"${transfer.wtid.substring(0,16)}..." has been deleted`,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: fix #8932,
gnunet <=