aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/wallet/ExchangeSelection
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet/ExchangeSelection')
-rw-r--r--packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts41
-rw-r--r--packages/taler-wallet-webextension/src/wallet/ExchangeSelection/stories.tsx14
2 files changed, 28 insertions, 27 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts
index cfb32cbbb..7ad11e67c 100644
--- a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts
+++ b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/state.ts
@@ -20,7 +20,7 @@ import {
WalletApiOperation,
} from "@gnu-taler/taler-wallet-core";
import { useState } from "preact/hooks";
-import { alertFromError } from "../../context/alert.js";
+import { alertFromError, useAlertContext } from "../../context/alert.js";
import { useBackendContext } from "../../context/backend.js";
import { useTranslationContext } from "../../context/translation.js";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
@@ -33,6 +33,7 @@ export function useComponentState({
currentExchange,
}: Props): State {
const api = useBackendContext();
+ const { pushAlertOnError } = useAlertContext();
const { i18n } = useTranslationContext();
const initialValue = exchanges.findIndex(
(e) => e.exchangeBaseUrl === currentExchange,
@@ -115,7 +116,7 @@ export function useComponentState({
status: "showing-privacy",
error: undefined,
onClose: {
- onClick: async () => setShowingPrivacy(undefined),
+ onClick: pushAlertOnError(async () => setShowingPrivacy(undefined)),
},
exchangeUrl: showingPrivacy,
};
@@ -125,7 +126,7 @@ export function useComponentState({
status: "showing-tos",
error: undefined,
onClose: {
- onClick: async () => setShowingTos(undefined),
+ onClick: pushAlertOnError(async () => setShowingTos(undefined)),
},
exchangeUrl: showingTos,
};
@@ -138,24 +139,24 @@ export function useComponentState({
exchanges: {
list: exchangeMap,
value: value,
- onChange: async (v) => {
+ onChange: pushAlertOnError(async (v) => {
setValue(v);
- },
+ }),
},
error: undefined,
onClose: {
- onClick: onCancel,
+ onClick: pushAlertOnError(onCancel),
},
selected,
onShowPrivacy: {
- onClick: async () => {
+ onClick: pushAlertOnError(async () => {
setShowingPrivacy(selected.exchangeBaseUrl);
- },
+ }),
},
onShowTerms: {
- onClick: async () => {
+ onClick: pushAlertOnError(async () => {
setShowingTos(selected.exchangeBaseUrl);
- },
+ }),
},
};
}
@@ -215,30 +216,30 @@ export function useComponentState({
exchanges: {
list: exchangeMap,
value: value,
- onChange: async (v) => {
+ onChange: pushAlertOnError(async (v) => {
setValue(v);
- },
+ }),
},
error: undefined,
onReset: {
- onClick: async () => {
+ onClick: pushAlertOnError(async () => {
setValue(String(initialValue));
- },
+ }),
},
onSelect: {
- onClick: async () => {
+ onClick: pushAlertOnError(async () => {
onSelection(selected.exchangeBaseUrl);
- },
+ }),
},
onShowPrivacy: {
- onClick: async () => {
+ onClick: pushAlertOnError(async () => {
setShowingPrivacy(selected.exchangeBaseUrl);
- },
+ }),
},
onShowTerms: {
- onClick: async () => {
+ onClick: pushAlertOnError(async () => {
setShowingTos(selected.exchangeBaseUrl);
- },
+ }),
},
selected,
coinOperationTimeline,
diff --git a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/stories.tsx b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/stories.tsx
index 05765b50a..a65f85c6a 100644
--- a/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/stories.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/ExchangeSelection/stories.tsx
@@ -19,14 +19,14 @@
* @author Sebastian Javier Marchano (sebasjm)
*/
-import { createExample } from "../../test-utils.js";
+import { tests } from "@gnu-taler/web-util/lib/index.browser";
import { ComparingView, ReadyView } from "./views.js";
export default {
title: "select exchange",
};
-export const Bitcoin1 = createExample(ReadyView, {
+export const Bitcoin1 = tests.createExample(ReadyView, {
exchanges: {
list: { "0": "https://exchange.taler.ar" },
value: "0",
@@ -43,7 +43,7 @@ export const Bitcoin1 = createExample(ReadyView, {
onShowTerms: {},
onClose: {},
});
-export const Bitcoin2 = createExample(ReadyView, {
+export const Bitcoin2 = tests.createExample(ReadyView, {
exchanges: {
list: {
"https://exchange.taler.ar": "https://exchange.taler.ar",
@@ -64,7 +64,7 @@ export const Bitcoin2 = createExample(ReadyView, {
onClose: {},
});
-export const Kudos1 = createExample(ReadyView, {
+export const Kudos1 = tests.createExample(ReadyView, {
exchanges: {
list: {
"https://exchange-kudos.taler.ar": "https://exchange-kudos.taler.ar",
@@ -83,7 +83,7 @@ export const Kudos1 = createExample(ReadyView, {
onShowTerms: {},
onClose: {},
});
-export const Kudos2 = createExample(ReadyView, {
+export const Kudos2 = tests.createExample(ReadyView, {
exchanges: {
list: {
"https://exchange-kudos.taler.ar": "https://exchange-kudos.taler.ar",
@@ -103,7 +103,7 @@ export const Kudos2 = createExample(ReadyView, {
onShowTerms: {},
onClose: {},
});
-export const ComparingBitcoin = createExample(ComparingView, {
+export const ComparingBitcoin = tests.createExample(ComparingView, {
exchanges: {
list: { "http://exchange": "http://exchange" },
value: "http://exchange",
@@ -131,7 +131,7 @@ export const ComparingBitcoin = createExample(ComparingView, {
missingWireTYpe: [],
wireFeeTimeline: {},
});
-export const ComparingKudos = createExample(ComparingView, {
+export const ComparingKudos = tests.createExample(ComparingView, {
exchanges: {
list: { "http://exchange": "http://exchange" },
value: "http://exchange",