diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/cta')
6 files changed, 44 insertions, 36 deletions
diff --git a/packages/taler-wallet-webextension/src/cta/Pay.stories.tsx b/packages/taler-wallet-webextension/src/cta/Pay.stories.tsx index c2d360d3b..a1288c337 100644 --- a/packages/taler-wallet-webextension/src/cta/Pay.stories.tsx +++ b/packages/taler-wallet-webextension/src/cta/Pay.stories.tsx @@ -34,13 +34,13 @@ export const NoBalance = createExample(TestedComponent, { status: PreparePayResultType.InsufficientBalance, noncePriv: "", proposalId: "proposal1234", - contractTerms: ({ + contractTerms: { merchant: { name: "someone", }, summary: "some beers", amount: "USD:10", - } as Partial<ContractTerms>) as any, + } as Partial<ContractTerms> as any, amountRaw: "USD:10", }, }); @@ -50,13 +50,13 @@ export const NoEnoughBalance = createExample(TestedComponent, { status: PreparePayResultType.InsufficientBalance, noncePriv: "", proposalId: "proposal1234", - contractTerms: ({ + contractTerms: { merchant: { name: "someone", }, summary: "some beers", amount: "USD:10", - } as Partial<ContractTerms>) as any, + } as Partial<ContractTerms> as any, amountRaw: "USD:10", }, balance: { @@ -67,42 +67,40 @@ export const NoEnoughBalance = createExample(TestedComponent, { }); export const PaymentPossible = createExample(TestedComponent, { - uri: - "taler://pay/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0", + uri: "taler://pay/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0", payStatus: { status: PreparePayResultType.PaymentPossible, amountEffective: "USD:10", amountRaw: "USD:10", noncePriv: "", - contractTerms: ({ + contractTerms: { nonce: "123213123", merchant: { name: "someone", }, amount: "USD:10", summary: "some beers", - } as Partial<ContractTerms>) as any, + } as Partial<ContractTerms> as any, contractTermsHash: "123456", proposalId: "proposal1234", }, }); export const PaymentPossibleWithFee = createExample(TestedComponent, { - uri: - "taler://pay/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0", + uri: "taler://pay/merchant-backend.taler/2021.242-01G2X4275RBWG/?c=66BE594PDZR24744J6EQK52XM0", payStatus: { status: PreparePayResultType.PaymentPossible, amountEffective: "USD:10.20", amountRaw: "USD:10", noncePriv: "", - contractTerms: ({ + contractTerms: { nonce: "123213123", merchant: { name: "someone", }, amount: "USD:10", summary: "some beers", - } as Partial<ContractTerms>) as any, + } as Partial<ContractTerms> as any, contractTermsHash: "123456", proposalId: "proposal1234", }, @@ -113,7 +111,7 @@ export const AlreadyConfirmedWithFullfilment = createExample(TestedComponent, { status: PreparePayResultType.AlreadyConfirmed, amountEffective: "USD:10", amountRaw: "USD:10", - contractTerms: ({ + contractTerms: { merchant: { name: "someone", }, @@ -121,7 +119,7 @@ export const AlreadyConfirmedWithFullfilment = createExample(TestedComponent, { "congratulations! you are looking at the fulfillment message! ", summary: "some beers", amount: "USD:10", - } as Partial<ContractTerms>) as any, + } as Partial<ContractTerms> as any, contractTermsHash: "123456", proposalId: "proposal1234", paid: false, @@ -135,13 +133,13 @@ export const AlreadyConfirmedWithoutFullfilment = createExample( status: PreparePayResultType.AlreadyConfirmed, amountEffective: "USD:10", amountRaw: "USD:10", - contractTerms: ({ + contractTerms: { merchant: { name: "someone", }, summary: "some beers", amount: "USD:10", - } as Partial<ContractTerms>) as any, + } as Partial<ContractTerms> as any, contractTermsHash: "123456", proposalId: "proposal1234", paid: false, @@ -154,7 +152,7 @@ export const AlreadyPaid = createExample(TestedComponent, { status: PreparePayResultType.AlreadyConfirmed, amountEffective: "USD:10", amountRaw: "USD:10", - contractTerms: ({ + contractTerms: { merchant: { name: "someone", }, @@ -162,7 +160,7 @@ export const AlreadyPaid = createExample(TestedComponent, { "congratulations! you are looking at the fulfillment message! ", summary: "some beers", amount: "USD:10", - } as Partial<ContractTerms>) as any, + } as Partial<ContractTerms> as any, contractTermsHash: "123456", proposalId: "proposal1234", paid: true, diff --git a/packages/taler-wallet-webextension/src/cta/Pay.tsx b/packages/taler-wallet-webextension/src/cta/Pay.tsx index 7b7d940c7..d7419d410 100644 --- a/packages/taler-wallet-webextension/src/cta/Pay.tsx +++ b/packages/taler-wallet-webextension/src/cta/Pay.tsx @@ -135,7 +135,9 @@ export function PayPage({ ? Amounts.parseOrThrow(foundBalance.available) : undefined; // We use a string here so that dependency tracking for useEffect works properly - const foundAmountStr = foundAmount ? Amounts.stringify(foundAmount) : undefined; + const foundAmountStr = foundAmount + ? Amounts.stringify(foundAmount) + : undefined; useEffect(() => { if (!talerPayUri) return; diff --git a/packages/taler-wallet-webextension/src/cta/Refund.stories.tsx b/packages/taler-wallet-webextension/src/cta/Refund.stories.tsx index a0abcea58..e71170ff1 100644 --- a/packages/taler-wallet-webextension/src/cta/Refund.stories.tsx +++ b/packages/taler-wallet-webextension/src/cta/Refund.stories.tsx @@ -35,10 +35,10 @@ export const Complete = createExample(TestedComponent, { amountRefundGone: "USD:0", amountRefundGranted: "USD:2", contractTermsHash: "QWEASDZXC", - info: ({ + info: { summary: "tasty cold beer", contractTermsHash: "QWEASDZXC", - } as Partial<OrderShortInfo>) as any, + } as Partial<OrderShortInfo> as any, pendingAtExchange: false, proposalId: "proposal123", }, @@ -50,10 +50,10 @@ export const Partial = createExample(TestedComponent, { amountRefundGone: "USD:1", amountRefundGranted: "USD:2", contractTermsHash: "QWEASDZXC", - info: ({ + info: { summary: "tasty cold beer", contractTermsHash: "QWEASDZXC", - } as Partial<OrderShortInfo>) as any, + } as Partial<OrderShortInfo> as any, pendingAtExchange: false, proposalId: "proposal123", }, @@ -65,10 +65,10 @@ export const InProgress = createExample(TestedComponent, { amountRefundGone: "USD:1", amountRefundGranted: "USD:2", contractTermsHash: "QWEASDZXC", - info: ({ + info: { summary: "tasty cold beer", contractTermsHash: "QWEASDZXC", - } as Partial<OrderShortInfo>) as any, + } as Partial<OrderShortInfo> as any, pendingAtExchange: true, proposalId: "proposal123", }, diff --git a/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx b/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx index 5109055e8..584da6d29 100644 --- a/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx +++ b/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx @@ -10,7 +10,7 @@ import { WarningBox, WarningText, } from "../components/styled"; -import { TermsState } from "../utils"; +import { TermsState } from "../utils/index"; interface Props { reviewing: boolean; diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw.stories.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw.stories.tsx index 3915dc126..3f548366a 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw.stories.tsx +++ b/packages/taler-wallet-webextension/src/cta/Withdraw.stories.tsx @@ -24,12 +24,16 @@ import { createExample } from "../test-utils"; import { termsHtml, termsPdf, termsPlain, termsXml } from "./termsExample"; import { View as TestedComponent } from "./Withdraw"; +function parseFromString(s: string): Document { + if (typeof window === "undefined") { + return {} as Document; + } + return new window.DOMParser().parseFromString(s, "text/xml"); +} + export default { title: "cta/withdraw", component: TestedComponent, - argTypes: { - onSwitchExchange: { action: "onRetry" }, - }, }; const exchangeList: ExchangeListItem[] = [ @@ -77,7 +81,7 @@ export const NewTerms = createExample(TestedComponent, { terms: { content: { type: "xml", - document: new DOMParser().parseFromString(termsXml, "text/xml"), + document: parseFromString(termsXml), }, status: "new", version: "", @@ -192,7 +196,7 @@ export const TermsReviewingXML = createExample(TestedComponent, { terms: { content: { type: "xml", - document: new DOMParser().parseFromString(termsXml, "text/xml"), + document: parseFromString(termsXml), }, status: "new", version: "", @@ -219,7 +223,7 @@ export const NewTermsAccepted = createExample(TestedComponent, { terms: { content: { type: "xml", - document: new DOMParser().parseFromString(termsXml, "text/xml"), + document: parseFromString(termsXml), }, status: "new", version: "", @@ -247,7 +251,7 @@ export const TermsShowAgainXML = createExample(TestedComponent, { terms: { content: { type: "xml", - document: new DOMParser().parseFromString(termsXml, "text/xml"), + document: parseFromString(termsXml), }, version: "", status: "new", @@ -276,7 +280,7 @@ export const TermsChanged = createExample(TestedComponent, { terms: { content: { type: "xml", - document: new DOMParser().parseFromString(termsXml, "text/xml"), + document: parseFromString(termsXml), }, version: "", status: "changed", @@ -351,7 +355,7 @@ export const WithoutFee = createExample(TestedComponent, { terms: { content: { type: "xml", - document: new DOMParser().parseFromString(termsXml, "text/xml"), + document: parseFromString(termsXml), }, status: "accepted", version: "", diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx index 4703492cf..0a06bd577 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx +++ b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx @@ -40,7 +40,11 @@ import { WalletAction, } from "../components/styled"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook"; -import { amountToString, buildTermsOfServiceState, TermsState } from "../utils"; +import { + amountToString, + buildTermsOfServiceState, + TermsState, +} from "../utils/index"; import * as wxApi from "../wxApi"; import { TermsOfServiceSection } from "./TermsOfServiceSection"; |