From 0bfd4523b3408d9c841a1f25fd9ec86e81d6dd8f Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 24 Nov 2021 08:57:26 -0300 Subject: [PATCH] adding tos information in settings and return to manual withdraw when adding an exchange --- .../src/components/styled/index.tsx | 8 + .../src/cta/TermsOfServiceSection.tsx | 21 ++- .../src/cta/Withdraw.stories.tsx | 172 ++++-------------- .../src/cta/Withdraw.tsx | 30 ++- .../src/popup/Settings.tsx | 16 -- .../src/utils/index.ts | 18 +- .../src/wallet/CreateManualWithdraw.tsx | 11 +- .../src/wallet/ExchangeAddConfirm.tsx | 9 - .../src/wallet/ExchangeAddPage.tsx | 2 +- .../src/wallet/ExchangeAddSetUrl.stories.tsx | 6 + .../src/wallet/ManualWithdrawPage.tsx | 13 +- .../src/wallet/Settings.stories.tsx | 46 +++++ .../src/wallet/Settings.tsx | 105 ++++++----- .../taler-wallet-webextension/src/wxApi.ts | 6 +- 14 files changed, 223 insertions(+), 240 deletions(-) diff --git a/packages/taler-wallet-webextension/src/components/styled/index.tsx b/packages/taler-wallet-webextension/src/components/styled/index.tsx index 7cef8789b..4c2367008 100644 --- a/packages/taler-wallet-webextension/src/components/styled/index.tsx +++ b/packages/taler-wallet-webextension/src/components/styled/index.tsx @@ -613,6 +613,14 @@ export const LightText = styled.div` color: gray; `; +export const SuccessText = styled.div` + color: #388e3c; +`; + +export const DestructiveText = styled.div` + color: rgb(202, 60, 60); +`; + export const WarningText = styled.div` color: rgb(223, 117, 20); `; diff --git a/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx b/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx index 5eddde64f..5109055e8 100644 --- a/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx +++ b/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx @@ -8,6 +8,7 @@ import { LinkSuccess, TermsOfService, WarningBox, + WarningText, } from "../components/styled"; import { TermsState } from "../utils"; @@ -28,10 +29,27 @@ export function TermsOfServiceSection({ if (!reviewing) { if (!reviewed) { if (!onReview) { - return
Terms of service status: {terms.status}
; + return ( + + {terms.status === "notfound" && ( +
+ + {i18n.str`Exchange doesn't have terms of service`} + +
+ )} +
+ ); } return ( + {terms.status === "notfound" && ( +
+ + {i18n.str`Exchange doesn't have terms of service`} + +
+ )} {terms.status === "new" && (
onReview(true)}> @@ -64,7 +82,6 @@ export function TermsOfServiceSection({ enabled={reviewed} label={i18n.str`I accept the exchange terms of service`} onToggle={() => { - console.log("asdasd", reviewed); onAccept(!reviewed); if (onReview) onReview(false); }} diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw.stories.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw.stories.tsx index fbbecd6f3..3915dc126 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw.stories.tsx +++ b/packages/taler-wallet-webextension/src/cta/Withdraw.stories.tsx @@ -19,7 +19,7 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { amountFractionalBase } from "@gnu-taler/taler-util"; +import { amountFractionalBase, ExchangeListItem } from "@gnu-taler/taler-util"; import { createExample } from "../test-utils"; import { termsHtml, termsPdf, termsPlain, termsXml } from "./termsExample"; import { View as TestedComponent } from "./Withdraw"; @@ -32,24 +32,38 @@ export default { }, }; +const exchangeList: ExchangeListItem[] = [ + { + currency: "USD", + exchangeBaseUrl: "exchange.demo.taler.net", + tos: { + currentVersion: "1", + acceptedVersion: "1", + content: "terms of service content", + contentType: "text/plain", + }, + paytoUris: ["asd"], + }, + { + currency: "USD", + exchangeBaseUrl: "exchange.test.taler.net", + tos: { + currentVersion: "1", + acceptedVersion: "1", + content: "terms of service content", + contentType: "text/plain", + }, + paytoUris: ["asd"], + }, +]; + export const NewTerms = createExample(TestedComponent, { - knownExchanges: [ - { - currency: "USD", - exchangeBaseUrl: "exchange.demo.taler.net", - paytoUris: ["asd"], - }, - { - currency: "USD", - exchangeBaseUrl: "exchange.test.taler.net", - paytoUris: ["asd"], - }, - ], + knownExchanges: exchangeList, exchangeBaseUrl: "exchange.demo.taler.net", withdrawalFee: { currency: "USD", fraction: 0, - value: 0, + value: 1, }, amount: { currency: "USD", @@ -71,18 +85,7 @@ export const NewTerms = createExample(TestedComponent, { }); export const TermsReviewingPLAIN = createExample(TestedComponent, { - knownExchanges: [ - { - currency: "USD", - exchangeBaseUrl: "exchange.demo.taler.net", - paytoUris: ["asd"], - }, - { - currency: "USD", - exchangeBaseUrl: "exchange.test.taler.net", - paytoUris: ["asd"], - }, - ], + knownExchanges: exchangeList, exchangeBaseUrl: "exchange.demo.taler.net", withdrawalFee: { currency: "USD", @@ -110,18 +113,7 @@ export const TermsReviewingPLAIN = createExample(TestedComponent, { }); export const TermsReviewingHTML = createExample(TestedComponent, { - knownExchanges: [ - { - currency: "USD", - exchangeBaseUrl: "exchange.demo.taler.net", - paytoUris: ["asd"], - }, - { - currency: "USD", - exchangeBaseUrl: "exchange.test.taler.net", - paytoUris: ["asd"], - }, - ], + knownExchanges: exchangeList, exchangeBaseUrl: "exchange.demo.taler.net", withdrawalFee: { currency: "USD", @@ -151,18 +143,7 @@ export const TermsReviewingHTML = createExample(TestedComponent, { }); export const TermsReviewingPDF = createExample(TestedComponent, { - knownExchanges: [ - { - currency: "USD", - exchangeBaseUrl: "exchange.demo.taler.net", - paytoUris: ["asd"], - }, - { - currency: "USD", - exchangeBaseUrl: "exchange.test.taler.net", - paytoUris: ["asd"], - }, - ], + knownExchanges: exchangeList, exchangeBaseUrl: "exchange.demo.taler.net", withdrawalFee: { currency: "USD", @@ -192,18 +173,7 @@ export const TermsReviewingPDF = createExample(TestedComponent, { }); export const TermsReviewingXML = createExample(TestedComponent, { - knownExchanges: [ - { - currency: "USD", - exchangeBaseUrl: "exchange.demo.taler.net", - paytoUris: ["asd"], - }, - { - currency: "USD", - exchangeBaseUrl: "exchange.test.taler.net", - paytoUris: ["asd"], - }, - ], + knownExchanges: exchangeList, exchangeBaseUrl: "exchange.demo.taler.net", withdrawalFee: { currency: "USD", @@ -231,18 +201,7 @@ export const TermsReviewingXML = createExample(TestedComponent, { }); export const NewTermsAccepted = createExample(TestedComponent, { - knownExchanges: [ - { - currency: "USD", - exchangeBaseUrl: "exchange.demo.taler.net", - paytoUris: ["asd"], - }, - { - currency: "USD", - exchangeBaseUrl: "exchange.test.taler.net", - paytoUris: ["asd"], - }, - ], + knownExchanges: exchangeList, exchangeBaseUrl: "exchange.demo.taler.net", withdrawalFee: { currency: "USD", @@ -269,18 +228,7 @@ export const NewTermsAccepted = createExample(TestedComponent, { }); export const TermsShowAgainXML = createExample(TestedComponent, { - knownExchanges: [ - { - currency: "USD", - exchangeBaseUrl: "exchange.demo.taler.net", - paytoUris: ["asd"], - }, - { - currency: "USD", - exchangeBaseUrl: "exchange.test.taler.net", - paytoUris: ["asd"], - }, - ], + knownExchanges: exchangeList, exchangeBaseUrl: "exchange.demo.taler.net", withdrawalFee: { currency: "USD", @@ -309,18 +257,7 @@ export const TermsShowAgainXML = createExample(TestedComponent, { }); export const TermsChanged = createExample(TestedComponent, { - knownExchanges: [ - { - currency: "USD", - exchangeBaseUrl: "exchange.demo.taler.net", - paytoUris: ["asd"], - }, - { - currency: "USD", - exchangeBaseUrl: "exchange.test.taler.net", - paytoUris: ["asd"], - }, - ], + knownExchanges: exchangeList, exchangeBaseUrl: "exchange.demo.taler.net", withdrawalFee: { currency: "USD", @@ -347,18 +284,7 @@ export const TermsChanged = createExample(TestedComponent, { }); export const TermsNotFound = createExample(TestedComponent, { - knownExchanges: [ - { - currency: "USD", - exchangeBaseUrl: "exchange.demo.taler.net", - paytoUris: ["asd"], - }, - { - currency: "USD", - exchangeBaseUrl: "exchange.test.taler.net", - paytoUris: ["asd"], - }, - ], + knownExchanges: exchangeList, exchangeBaseUrl: "exchange.demo.taler.net", withdrawalFee: { currency: "USD", @@ -382,18 +308,7 @@ export const TermsNotFound = createExample(TestedComponent, { }); export const TermsAlreadyAccepted = createExample(TestedComponent, { - knownExchanges: [ - { - currency: "USD", - exchangeBaseUrl: "exchange.demo.taler.net", - paytoUris: ["asd"], - }, - { - currency: "USD", - exchangeBaseUrl: "exchange.test.taler.net", - paytoUris: ["asd"], - }, - ], + knownExchanges: exchangeList, exchangeBaseUrl: "exchange.demo.taler.net", withdrawalFee: { currency: "USD", @@ -417,18 +332,7 @@ export const TermsAlreadyAccepted = createExample(TestedComponent, { }); export const WithoutFee = createExample(TestedComponent, { - knownExchanges: [ - { - currency: "USD", - exchangeBaseUrl: "exchange.demo.taler.net", - paytoUris: ["asd"], - }, - { - currency: "USD", - exchangeBaseUrl: "exchange.test.taler.net", - paytoUris: ["asd"], - }, - ], + knownExchanges: exchangeList, exchangeBaseUrl: "exchange.demo.taler.net", withdrawalFee: { currency: "USD", diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx index 4ebbe11c6..eead51690 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx +++ b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx @@ -38,7 +38,6 @@ import { ButtonWarning, LinkSuccess, WalletAction, - WarningText, } from "../components/styled"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook"; import { amountToString, buildTermsOfServiceState, TermsState } from "../utils"; @@ -98,17 +97,19 @@ export function View({ text={amountToString(Amounts.sub(amount, withdrawalFee).amount)} kind="positive" /> - {Amounts.isNonZero(withdrawalFee) && ( - + + + + )} {exchangeBaseUrl && ( @@ -140,13 +141,6 @@ export function View({ )}
)} - {terms.status === "notfound" && ( -
- - {i18n.str`Exchange doesn't have terms of service`} - -
- )} ); } @@ -37,15 +33,11 @@ export function SettingsPage(): VNode { export interface ViewProps { permissionsEnabled: boolean; togglePermissions: () => void; - developerMode: boolean; - toggleDeveloperMode: () => void; } export function SettingsView({ permissionsEnabled, togglePermissions, - developerMode, - toggleDeveloperMode, }: ViewProps): VNode { return ( @@ -60,14 +52,6 @@ export function SettingsView({ enabled={permissionsEnabled} onToggle={togglePermissions} /> -

Config

-