summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/cta
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-10-15 12:59:26 +0200
committerFlorian Dold <florian@dold.me>2022-10-15 12:59:26 +0200
commitbd88dcebbcf90414c790a86ee13740eaf20e3334 (patch)
tree3faa7508089bfa4316aebb310a7a5cf55076db34 /packages/taler-wallet-webextension/src/cta
parente075134ffc94fda3582b179122bda594d91a962b (diff)
downloadwallet-core-bd88dcebbcf90414c790a86ee13740eaf20e3334.tar.gz
wallet-core-bd88dcebbcf90414c790a86ee13740eaf20e3334.tar.bz2
wallet-core-bd88dcebbcf90414c790a86ee13740eaf20e3334.zip
wallet-core: simplify exchanges list response
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta')
-rw-r--r--packages/taler-wallet-webextension/src/cta/Withdraw/state.ts13
-rw-r--r--packages/taler-wallet-webextension/src/cta/Withdraw/test.ts3
-rw-r--r--packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx4
3 files changed, 13 insertions, 7 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
index 53bac579e..f4aea9cd6 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/state.ts
@@ -15,7 +15,12 @@
*/
/* eslint-disable react-hooks/rules-of-hooks */
-import { AmountJson, Amounts, ExchangeListItem } from "@gnu-taler/taler-util";
+import {
+ AmountJson,
+ Amounts,
+ ExchangeListItem,
+ ExchangeTosStatus,
+} from "@gnu-taler/taler-util";
import { TalerError } from "@gnu-taler/taler-wallet-core";
import { useState } from "preact/hooks";
import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js";
@@ -173,10 +178,8 @@ function exchangeSelectionState(
const [ageRestricted, setAgeRestricted] = useState(0);
const currentExchange = selectedExchange.selected;
const tosNeedToBeAccepted =
- !currentExchange.tos.acceptedVersion ||
- currentExchange.tos.currentVersion !==
- currentExchange.tos.acceptedVersion;
-
+ currentExchange.tosStatus == ExchangeTosStatus.New ||
+ currentExchange.tosStatus == ExchangeTosStatus.Changed;
/**
* With the exchange and amount, ask the wallet the information
* about the withdrawal
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts b/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts
index d86771208..2b0690800 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/test.ts
@@ -22,6 +22,7 @@
import {
Amounts,
ExchangeFullDetails,
+ ExchangeTosStatus,
GetExchangeTosResult,
} from "@gnu-taler/taler-util";
import { expect } from "chai";
@@ -169,6 +170,7 @@ describe("Withdraw CTA states", () => {
content: "just accept",
acceptedEtag: "v1",
currentEtag: "v1",
+ tosStatus: ExchangeTosStatus.Accepted,
}),
} as any,
),
@@ -254,6 +256,7 @@ describe("Withdraw CTA states", () => {
content: "just accept",
acceptedEtag: "v1",
currentEtag: "v2",
+ tosStatus: ExchangeTosStatus.Changed,
}),
setExchangeTosAccepted: async () => ({}),
} as any,
diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx
index 468d22d54..5c35151c8 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx
@@ -37,6 +37,7 @@ import editIcon from "../../svg/edit_24px.svg";
import { ExchangeDetails, WithdrawDetails } from "../../wallet/Transaction.js";
import { TermsOfService } from "../../components/TermsOfService/index.js";
import { State } from "./index.js";
+import { ExchangeTosStatus } from "@gnu-taler/taler-util";
export function LoadingUriView({ error }: State.LoadingUriError): VNode {
const { i18n } = useTranslationContext();
@@ -65,8 +66,7 @@ export function LoadingInfoView({ error }: State.LoadingInfoError): VNode {
export function SuccessView(state: State.Success): VNode {
const { i18n } = useTranslationContext();
const currentTosVersionIsAccepted =
- state.currentExchange.tos.acceptedVersion ===
- state.currentExchange.tos.currentVersion;
+ state.currentExchange.tosStatus === ExchangeTosStatus.Accepted;
return (
<WalletAction>
<LogoHeader />