aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-webextension')
-rw-r--r--packages/taler-wallet-webextension/src/context/alert.ts13
-rw-r--r--packages/taler-wallet-webextension/src/wallet/Application.tsx3
-rw-r--r--packages/taler-wallet-webextension/src/wallet/DepositPage/index.ts1
-rw-r--r--packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts3
-rw-r--r--packages/taler-wallet-webextension/src/wallet/DepositPage/test.ts11
5 files changed, 17 insertions, 14 deletions
diff --git a/packages/taler-wallet-webextension/src/context/alert.ts b/packages/taler-wallet-webextension/src/context/alert.ts
index 8527f30f6..da37a2768 100644
--- a/packages/taler-wallet-webextension/src/context/alert.ts
+++ b/packages/taler-wallet-webextension/src/context/alert.ts
@@ -49,13 +49,16 @@ type Type = {
pushAlert: (n: Alert) => void;
removeAlert: (n: Alert) => void;
/**
- *
- * @param h
- * @returns
+ *
+ * @param h
+ * @returns
* @deprecated use safely
*/
pushAlertOnError: <T>(h: (p: T) => Promise<void>) => SafeHandler<T>;
- safely: <T>(h: (p: T) => Promise<void>, error: TranslatedString) => SafeHandler<T>;
+ safely: <T>(
+ h: (p: T) => Promise<void>,
+ error: TranslatedString,
+ ) => SafeHandler<T>;
};
const initial: Type = {
@@ -112,7 +115,7 @@ export const AlertProvider = ({ children }: Props): VNode => {
function safely<T>(
handler: (p: T) => Promise<void>,
- message: TranslatedString
+ message: TranslatedString,
): SafeHandler<T> {
return withSafe(handler, (e) => {
const a = alertFromError(message, e);
diff --git a/packages/taler-wallet-webextension/src/wallet/Application.tsx b/packages/taler-wallet-webextension/src/wallet/Application.tsx
index 0db06fe08..ec34606dd 100644
--- a/packages/taler-wallet-webextension/src/wallet/Application.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Application.tsx
@@ -207,9 +207,10 @@ export function Application(): VNode {
<Route
path={Pages.balanceDeposit.pattern}
- component={() => (
+ component={({ amount }: { amount: string }) => (
<WalletTemplate path="balance">
<DepositPage
+ amount={amount}
onCancel={(currency: string) => {
redirectTo(Pages.balanceHistory({ currency }));
}}
diff --git a/packages/taler-wallet-webextension/src/wallet/DepositPage/index.ts b/packages/taler-wallet-webextension/src/wallet/DepositPage/index.ts
index 6de406400..838739ad1 100644
--- a/packages/taler-wallet-webextension/src/wallet/DepositPage/index.ts
+++ b/packages/taler-wallet-webextension/src/wallet/DepositPage/index.ts
@@ -35,7 +35,6 @@ import {
export interface Props {
amount?: string;
- currency?: string;
onCancel: (currency: string) => void;
onSuccess: (currency: string) => void;
}
diff --git a/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts b/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts
index 935adf012..1b628047a 100644
--- a/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts
+++ b/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts
@@ -33,7 +33,6 @@ import { Props, State } from "./index.js";
export function useComponentState({
amount: amountStr,
- currency: currencyStr,
onCancel,
onSuccess,
}: Props): State {
@@ -41,7 +40,7 @@ export function useComponentState({
const { i18n } = useTranslationContext();
const { pushAlertOnError } = useAlertContext();
const parsed = amountStr === undefined ? undefined : Amounts.parse(amountStr);
- const currency = parsed !== undefined ? parsed.currency : currencyStr;
+ const currency = parsed !== undefined ? parsed.currency : undefined;
const hook = useAsyncAsHook(async () => {
const { balances } = await api.wallet.call(
diff --git a/packages/taler-wallet-webextension/src/wallet/DepositPage/test.ts b/packages/taler-wallet-webextension/src/wallet/DepositPage/test.ts
index 0054ab5af..42b76cf50 100644
--- a/packages/taler-wallet-webextension/src/wallet/DepositPage/test.ts
+++ b/packages/taler-wallet-webextension/src/wallet/DepositPage/test.ts
@@ -34,6 +34,7 @@ import { createWalletApiMock } from "../../test-utils.js";
import { useComponentState } from "./state.js";
const currency = "EUR";
+const amount = `${currency}:0`;
const withoutFee = (): DepositGroupFees => ({
coin: Amounts.stringify(`${currency}:0`),
wire: Amounts.stringify(`${currency}:0`),
@@ -49,7 +50,7 @@ const withSomeFee = (): DepositGroupFees => ({
describe("DepositPage states", () => {
it("should have status 'no-enough-balance' when balance is empty", async () => {
const { handler, TestingContext } = createWalletApiMock();
- const props = { currency, onCancel: nullFunction, onSuccess: nullFunction };
+ const props = { amount, onCancel: nullFunction, onSuccess: nullFunction };
handler.addWalletCallResponse(WalletApiOperation.GetBalances, undefined, {
balances: [
@@ -90,7 +91,7 @@ describe("DepositPage states", () => {
it("should have status 'no-accounts' when balance is not empty and accounts is empty", async () => {
const { handler, TestingContext } = createWalletApiMock();
- const props = { currency, onCancel: nullFunction, onSuccess: nullFunction };
+ const props = { amount, onCancel: nullFunction, onSuccess: nullFunction };
handler.addWalletCallResponse(WalletApiOperation.GetBalances, undefined, {
balances: [
@@ -144,7 +145,7 @@ describe("DepositPage states", () => {
it("should have status 'ready' but unable to deposit ", async () => {
const { handler, TestingContext } = createWalletApiMock();
- const props = { currency, onCancel: nullFunction, onSuccess: nullFunction };
+ const props = { amount, onCancel: nullFunction, onSuccess: nullFunction };
handler.addWalletCallResponse(WalletApiOperation.GetBalances, undefined, {
balances: [
@@ -198,7 +199,7 @@ describe("DepositPage states", () => {
it("should not be able to deposit more than the balance ", async () => {
const { handler, TestingContext } = createWalletApiMock();
- const props = { currency, onCancel: nullFunction, onSuccess: nullFunction };
+ const props = { amount, onCancel: nullFunction, onSuccess: nullFunction };
handler.addWalletCallResponse(WalletApiOperation.GetBalances, undefined, {
balances: [
@@ -273,7 +274,7 @@ describe("DepositPage states", () => {
it("should calculate the fee upon entering amount ", async () => {
const { handler, TestingContext } = createWalletApiMock();
- const props = { currency, onCancel: nullFunction, onSuccess: nullFunction };
+ const props = { amount, onCancel: nullFunction, onSuccess: nullFunction };
handler.addWalletCallResponse(WalletApiOperation.GetBalances, undefined, {
balances: [