summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2023-01-09 08:38:48 -0300
committerSebastian <sebasjm@gmail.com>2023-01-09 08:38:48 -0300
commit9b04d8bf3581d162cbd631892ca115df811c46f8 (patch)
tree42b7da7cc3a3f8186823a7571aa221dc8e9aa7a5 /packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts
parent14f3d1e06dda003d457f2b3531e197011a284244 (diff)
downloadwallet-core-9b04d8bf3581d162cbd631892ca115df811c46f8.tar.gz
wallet-core-9b04d8bf3581d162cbd631892ca115df811c46f8.tar.bz2
wallet-core-9b04d8bf3581d162cbd631892ca115df811c46f8.zip
fix #7152
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts')
-rw-r--r--packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts37
1 files changed, 26 insertions, 11 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts
index 998270e53..46b1262b1 100644
--- a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts
+++ b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/state.ts
@@ -23,7 +23,9 @@ import {
import { TalerError, WalletApiOperation } from "@gnu-taler/taler-wallet-core";
import { isFuture, parse } from "date-fns";
import { useState } from "preact/hooks";
+import { alertFromError } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js";
+import { useTranslationContext } from "../../context/translation.js";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
import { useSelectedExchange } from "../../hooks/useSelectedExchange.js";
import { RecursiveState } from "../../utils/index.js";
@@ -40,6 +42,7 @@ export function useComponentState({
const hook = useAsyncAsHook(() =>
api.wallet.call(WalletApiOperation.ListExchanges, {}),
);
+ const { i18n } = useTranslationContext();
if (!hook) {
return {
@@ -49,10 +52,19 @@ export function useComponentState({
}
if (hook.hasError) {
return {
- status: "loading-uri",
- error: hook,
+ status: "error",
+ error: alertFromError(
+ i18n.str`Could not load the status of the term of service`,
+ hook,
+ ),
};
}
+ // if (hook.hasError) {
+ // return {
+ // status: "loading-uri",
+ // error: hook,
+ // };
+ // }
const exchangeList = hook.response.exchanges;
@@ -60,10 +72,6 @@ export function useComponentState({
const [subject, setSubject] = useState<string | undefined>();
const [timestamp, setTimestamp] = useState<string | undefined>();
- const [operationError, setOperationError] = useState<
- TalerErrorDetail | undefined
- >(undefined);
-
const selectedExchange = useSelectedExchange({
currency: amount.currency,
defaultExchange: undefined,
@@ -93,11 +101,19 @@ export function useComponentState({
error: undefined,
};
}
+
if (hook.hasError) {
return {
- status: "loading-uri",
- error: hook,
+ status: "error",
+ error: alertFromError(
+ i18n.str`Could not load the status of the term of service`,
+ hook,
+ ),
};
+ // return {
+ // status: "loading-uri",
+ // error: hook,
+ // };
}
const { amountEffective, amountRaw } = hook.response;
@@ -160,8 +176,8 @@ export function useComponentState({
subject === undefined
? undefined
: !subject
- ? "Can't be empty"
- : undefined,
+ ? "Can't be empty"
+ : undefined,
value: subject ?? "",
onInput: async (e) => setSubject(e),
},
@@ -183,7 +199,6 @@ export function useComponentState({
requestAmount,
toBeReceived,
error: undefined,
- operationError,
};
};
}