wallet-core/packages/taler-wallet-webextension/src/cta/Withdraw.stories.tsx

456 lines
9.0 KiB
TypeScript
Raw Normal View History

2021-05-31 16:34:48 +02:00
/*
This file is part of GNU Taler
(C) 2021 Taler Systems S.A.
GNU Taler is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3, or (at your option) any later version.
GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
2021-11-15 15:18:58 +01:00
*
* @author Sebastian Javier Marchano (sebasjm)
*/
2021-05-31 16:34:48 +02:00
2021-11-16 17:59:53 +01:00
import { amountFractionalBase } from "@gnu-taler/taler-util";
2021-11-15 15:18:58 +01:00
import { createExample } from "../test-utils";
2021-11-22 21:34:27 +01:00
import { termsHtml, termsPdf, termsPlain, termsXml } from "./termsExample";
2021-11-15 15:18:58 +01:00
import { View as TestedComponent } from "./Withdraw";
2021-05-31 16:34:48 +02:00
export default {
2021-11-15 15:18:58 +01:00
title: "cta/withdraw",
component: TestedComponent,
2021-05-31 16:34:48 +02:00
argTypes: {
2021-11-15 15:18:58 +01:00
onSwitchExchange: { action: "onRetry" },
2021-05-31 16:34:48 +02:00
},
};
2021-10-12 20:18:29 +02:00
export const NewTerms = createExample(TestedComponent, {
2021-11-15 15:18:58 +01:00
knownExchanges: [
{
currency: "USD",
exchangeBaseUrl: "exchange.demo.taler.net",
paytoUris: ["asd"],
},
{
currency: "USD",
exchangeBaseUrl: "exchange.test.taler.net",
paytoUris: ["asd"],
},
],
exchangeBaseUrl: "exchange.demo.taler.net",
2021-10-13 19:26:18 +02:00
withdrawalFee: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-13 19:26:18 +02:00
fraction: 0,
2021-11-15 15:18:58 +01:00
value: 0,
2021-10-13 19:26:18 +02:00
},
2021-10-11 20:59:55 +02:00
amount: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-11 20:59:55 +02:00
value: 2,
2021-11-15 15:18:58 +01:00
fraction: 10000000,
2021-10-11 20:59:55 +02:00
},
2021-11-16 17:59:53 +01:00
onSwitchExchange: async () => {
null;
},
2021-09-13 18:32:58 +02:00
terms: {
2021-11-22 21:34:27 +01:00
content: {
2021-11-15 15:18:58 +01:00
type: "xml",
2021-09-13 18:32:58 +02:00
document: new DOMParser().parseFromString(termsXml, "text/xml"),
},
2021-11-15 15:18:58 +01:00
status: "new",
2021-11-22 21:34:27 +01:00
version: "",
2021-09-13 18:32:58 +02:00
},
2021-11-15 15:18:58 +01:00
});
2021-09-13 18:32:58 +02:00
2021-10-12 20:18:29 +02:00
export const TermsReviewingPLAIN = createExample(TestedComponent, {
2021-11-15 15:18:58 +01:00
knownExchanges: [
{
currency: "USD",
exchangeBaseUrl: "exchange.demo.taler.net",
paytoUris: ["asd"],
},
{
currency: "USD",
exchangeBaseUrl: "exchange.test.taler.net",
paytoUris: ["asd"],
},
],
exchangeBaseUrl: "exchange.demo.taler.net",
2021-10-13 19:26:18 +02:00
withdrawalFee: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-13 19:26:18 +02:00
fraction: 0,
2021-11-15 15:18:58 +01:00
value: 0,
2021-10-13 19:26:18 +02:00
},
2021-10-12 20:18:29 +02:00
amount: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-12 20:18:29 +02:00
value: 2,
2021-11-15 15:18:58 +01:00
fraction: 10000000,
2021-10-12 20:18:29 +02:00
},
2021-11-16 17:59:53 +01:00
onSwitchExchange: async () => {
null;
},
2021-10-12 20:18:29 +02:00
terms: {
2021-11-22 21:34:27 +01:00
content: {
2021-11-15 15:18:58 +01:00
type: "plain",
content: termsPlain,
2021-10-12 20:18:29 +02:00
},
2021-11-15 15:18:58 +01:00
status: "new",
2021-11-22 21:34:27 +01:00
version: "",
2021-10-12 20:18:29 +02:00
},
2021-11-15 15:18:58 +01:00
reviewing: true,
});
2021-10-12 20:18:29 +02:00
export const TermsReviewingHTML = createExample(TestedComponent, {
2021-11-15 15:18:58 +01:00
knownExchanges: [
{
currency: "USD",
exchangeBaseUrl: "exchange.demo.taler.net",
paytoUris: ["asd"],
},
{
currency: "USD",
exchangeBaseUrl: "exchange.test.taler.net",
paytoUris: ["asd"],
},
],
exchangeBaseUrl: "exchange.demo.taler.net",
2021-10-13 19:26:18 +02:00
withdrawalFee: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-13 19:26:18 +02:00
fraction: 0,
2021-11-15 15:18:58 +01:00
value: 0,
2021-10-13 19:26:18 +02:00
},
2021-10-12 20:18:29 +02:00
amount: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-12 20:18:29 +02:00
value: 2,
2021-11-15 15:18:58 +01:00
fraction: 10000000,
2021-10-12 20:18:29 +02:00
},
2021-11-16 17:59:53 +01:00
onSwitchExchange: async () => {
null;
},
2021-10-12 20:18:29 +02:00
terms: {
2021-11-22 21:34:27 +01:00
content: {
2021-11-15 15:18:58 +01:00
type: "html",
href: new URL(
`data:text/html;base64,${Buffer.from(termsHtml).toString("base64")}`,
),
2021-10-12 20:18:29 +02:00
},
2021-11-22 21:34:27 +01:00
version: "",
2021-11-15 15:18:58 +01:00
status: "new",
2021-10-12 20:18:29 +02:00
},
2021-11-15 15:18:58 +01:00
reviewing: true,
});
2021-10-12 20:18:29 +02:00
export const TermsReviewingPDF = createExample(TestedComponent, {
2021-11-15 15:18:58 +01:00
knownExchanges: [
{
currency: "USD",
exchangeBaseUrl: "exchange.demo.taler.net",
paytoUris: ["asd"],
},
{
currency: "USD",
exchangeBaseUrl: "exchange.test.taler.net",
paytoUris: ["asd"],
},
],
exchangeBaseUrl: "exchange.demo.taler.net",
2021-10-13 19:26:18 +02:00
withdrawalFee: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-13 19:26:18 +02:00
fraction: 0,
2021-11-15 15:18:58 +01:00
value: 0,
2021-10-13 19:26:18 +02:00
},
2021-10-12 20:18:29 +02:00
amount: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-12 20:18:29 +02:00
value: 2,
2021-11-15 15:18:58 +01:00
fraction: 10000000,
2021-10-12 20:18:29 +02:00
},
2021-11-16 17:59:53 +01:00
onSwitchExchange: async () => {
null;
},
2021-10-12 20:18:29 +02:00
terms: {
2021-11-22 21:34:27 +01:00
content: {
2021-11-15 15:18:58 +01:00
type: "pdf",
location: new URL(
`data:text/html;base64,${Buffer.from(termsPdf).toString("base64")}`,
),
2021-10-12 20:18:29 +02:00
},
2021-11-15 15:18:58 +01:00
status: "new",
2021-11-22 21:34:27 +01:00
version: "",
2021-10-12 20:18:29 +02:00
},
2021-11-15 15:18:58 +01:00
reviewing: true,
});
2021-10-12 20:18:29 +02:00
export const TermsReviewingXML = createExample(TestedComponent, {
2021-11-15 15:18:58 +01:00
knownExchanges: [
{
currency: "USD",
exchangeBaseUrl: "exchange.demo.taler.net",
paytoUris: ["asd"],
},
{
currency: "USD",
exchangeBaseUrl: "exchange.test.taler.net",
paytoUris: ["asd"],
},
],
exchangeBaseUrl: "exchange.demo.taler.net",
2021-10-13 19:26:18 +02:00
withdrawalFee: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-13 19:26:18 +02:00
fraction: 0,
2021-11-15 15:18:58 +01:00
value: 0,
2021-10-13 19:26:18 +02:00
},
2021-10-11 20:59:55 +02:00
amount: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-11 20:59:55 +02:00
value: 2,
2021-11-15 15:18:58 +01:00
fraction: 10000000,
2021-10-11 20:59:55 +02:00
},
2021-11-16 17:59:53 +01:00
onSwitchExchange: async () => {
null;
},
2021-09-13 18:32:58 +02:00
terms: {
2021-11-22 21:34:27 +01:00
content: {
2021-11-15 15:18:58 +01:00
type: "xml",
2021-09-13 18:32:58 +02:00
document: new DOMParser().parseFromString(termsXml, "text/xml"),
},
2021-11-15 15:18:58 +01:00
status: "new",
2021-11-22 21:34:27 +01:00
version: "",
2021-09-13 18:32:58 +02:00
},
2021-11-15 15:18:58 +01:00
reviewing: true,
});
2021-09-13 18:32:58 +02:00
2021-10-12 20:18:29 +02:00
export const NewTermsAccepted = createExample(TestedComponent, {
2021-11-15 15:18:58 +01:00
knownExchanges: [
{
currency: "USD",
exchangeBaseUrl: "exchange.demo.taler.net",
paytoUris: ["asd"],
},
{
currency: "USD",
exchangeBaseUrl: "exchange.test.taler.net",
paytoUris: ["asd"],
},
],
exchangeBaseUrl: "exchange.demo.taler.net",
2021-10-13 19:26:18 +02:00
withdrawalFee: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-13 19:26:18 +02:00
fraction: 0,
2021-11-15 15:18:58 +01:00
value: 0,
2021-10-13 19:26:18 +02:00
},
2021-10-11 20:59:55 +02:00
amount: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-11 20:59:55 +02:00
value: 2,
2021-11-15 15:18:58 +01:00
fraction: 10000000,
2021-10-11 20:59:55 +02:00
},
2021-11-16 17:59:53 +01:00
onSwitchExchange: async () => {
null;
},
2021-09-13 18:32:58 +02:00
terms: {
2021-11-22 21:34:27 +01:00
content: {
2021-11-15 15:18:58 +01:00
type: "xml",
2021-09-13 18:32:58 +02:00
document: new DOMParser().parseFromString(termsXml, "text/xml"),
},
2021-11-15 15:18:58 +01:00
status: "new",
2021-11-22 21:34:27 +01:00
version: "",
2021-09-13 18:32:58 +02:00
},
2021-11-15 15:18:58 +01:00
reviewed: true,
});
2021-09-13 18:32:58 +02:00
2021-10-12 20:18:29 +02:00
export const TermsShowAgainXML = createExample(TestedComponent, {
2021-11-15 15:18:58 +01:00
knownExchanges: [
{
currency: "USD",
exchangeBaseUrl: "exchange.demo.taler.net",
paytoUris: ["asd"],
},
{
currency: "USD",
exchangeBaseUrl: "exchange.test.taler.net",
paytoUris: ["asd"],
},
],
exchangeBaseUrl: "exchange.demo.taler.net",
2021-10-13 19:26:18 +02:00
withdrawalFee: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-13 19:26:18 +02:00
fraction: 0,
2021-11-15 15:18:58 +01:00
value: 0,
2021-10-13 19:26:18 +02:00
},
2021-10-11 20:59:55 +02:00
amount: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-11 20:59:55 +02:00
value: 2,
2021-11-15 15:18:58 +01:00
fraction: 10000000,
2021-10-11 20:59:55 +02:00
},
2021-11-16 17:59:53 +01:00
onSwitchExchange: async () => {
null;
},
2021-09-13 18:32:58 +02:00
terms: {
2021-11-22 21:34:27 +01:00
content: {
2021-11-15 15:18:58 +01:00
type: "xml",
2021-09-13 18:32:58 +02:00
document: new DOMParser().parseFromString(termsXml, "text/xml"),
},
2021-11-22 21:34:27 +01:00
version: "",
2021-11-15 15:18:58 +01:00
status: "new",
2021-09-13 18:32:58 +02:00
},
2021-10-13 19:26:18 +02:00
reviewed: true,
2021-09-13 18:32:58 +02:00
reviewing: true,
2021-11-15 15:18:58 +01:00
});
2021-09-13 18:32:58 +02:00
2021-10-12 20:18:29 +02:00
export const TermsChanged = createExample(TestedComponent, {
2021-11-15 15:18:58 +01:00
knownExchanges: [
{
currency: "USD",
exchangeBaseUrl: "exchange.demo.taler.net",
paytoUris: ["asd"],
},
{
currency: "USD",
exchangeBaseUrl: "exchange.test.taler.net",
paytoUris: ["asd"],
},
],
exchangeBaseUrl: "exchange.demo.taler.net",
2021-10-13 19:26:18 +02:00
withdrawalFee: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-13 19:26:18 +02:00
fraction: 0,
2021-11-15 15:18:58 +01:00
value: 0,
2021-10-13 19:26:18 +02:00
},
2021-10-11 20:59:55 +02:00
amount: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-11 20:59:55 +02:00
value: 2,
2021-11-15 15:18:58 +01:00
fraction: 10000000,
2021-10-11 20:59:55 +02:00
},
2021-11-16 17:59:53 +01:00
onSwitchExchange: async () => {
null;
},
2021-09-13 18:32:58 +02:00
terms: {
2021-11-22 21:34:27 +01:00
content: {
2021-11-15 15:18:58 +01:00
type: "xml",
2021-09-13 18:32:58 +02:00
document: new DOMParser().parseFromString(termsXml, "text/xml"),
},
2021-11-22 21:34:27 +01:00
version: "",
2021-11-15 15:18:58 +01:00
status: "changed",
2021-09-13 18:32:58 +02:00
},
2021-11-15 15:18:58 +01:00
});
2021-09-13 18:32:58 +02:00
2021-10-12 20:18:29 +02:00
export const TermsNotFound = createExample(TestedComponent, {
2021-11-15 15:18:58 +01:00
knownExchanges: [
{
currency: "USD",
exchangeBaseUrl: "exchange.demo.taler.net",
paytoUris: ["asd"],
},
{
currency: "USD",
exchangeBaseUrl: "exchange.test.taler.net",
paytoUris: ["asd"],
},
],
exchangeBaseUrl: "exchange.demo.taler.net",
2021-10-13 19:26:18 +02:00
withdrawalFee: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-13 19:26:18 +02:00
fraction: 0,
2021-11-15 15:18:58 +01:00
value: 0,
2021-10-13 19:26:18 +02:00
},
2021-10-11 20:59:55 +02:00
amount: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-11 20:59:55 +02:00
value: 2,
2021-11-15 15:18:58 +01:00
fraction: 10000000,
2021-10-11 20:59:55 +02:00
},
2021-11-16 17:59:53 +01:00
onSwitchExchange: async () => {
null;
},
2021-09-13 18:32:58 +02:00
terms: {
2021-11-22 21:34:27 +01:00
content: undefined,
2021-11-15 15:18:58 +01:00
status: "notfound",
2021-11-22 21:34:27 +01:00
version: "",
2021-09-13 18:32:58 +02:00
},
2021-11-15 15:18:58 +01:00
});
2021-09-13 18:32:58 +02:00
2021-10-12 20:18:29 +02:00
export const TermsAlreadyAccepted = createExample(TestedComponent, {
2021-11-15 15:18:58 +01:00
knownExchanges: [
{
currency: "USD",
exchangeBaseUrl: "exchange.demo.taler.net",
paytoUris: ["asd"],
},
{
currency: "USD",
exchangeBaseUrl: "exchange.test.taler.net",
paytoUris: ["asd"],
},
],
exchangeBaseUrl: "exchange.demo.taler.net",
2021-10-13 19:26:18 +02:00
withdrawalFee: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-13 19:26:18 +02:00
fraction: amountFractionalBase * 0.5,
2021-11-15 15:18:58 +01:00
value: 0,
2021-10-13 19:26:18 +02:00
},
2021-10-11 20:59:55 +02:00
amount: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-11 20:59:55 +02:00
value: 2,
2021-11-15 15:18:58 +01:00
fraction: 10000000,
2021-10-11 20:59:55 +02:00
},
2021-11-16 17:59:53 +01:00
onSwitchExchange: async () => {
null;
},
2021-09-13 18:32:58 +02:00
terms: {
2021-11-15 15:18:58 +01:00
status: "accepted",
2021-11-22 21:34:27 +01:00
content: undefined,
version: "",
2021-09-13 18:32:58 +02:00
},
2021-11-15 15:18:58 +01:00
});
2021-09-13 18:32:58 +02:00
2021-10-12 20:18:29 +02:00
export const WithoutFee = createExample(TestedComponent, {
2021-11-15 15:18:58 +01:00
knownExchanges: [
{
currency: "USD",
exchangeBaseUrl: "exchange.demo.taler.net",
paytoUris: ["asd"],
},
{
currency: "USD",
exchangeBaseUrl: "exchange.test.taler.net",
paytoUris: ["asd"],
},
],
exchangeBaseUrl: "exchange.demo.taler.net",
2021-10-13 19:26:18 +02:00
withdrawalFee: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-13 19:26:18 +02:00
fraction: 0,
value: 0,
},
2021-10-11 20:59:55 +02:00
amount: {
2021-11-15 15:18:58 +01:00
currency: "USD",
2021-10-11 20:59:55 +02:00
value: 2,
2021-11-15 15:18:58 +01:00
fraction: 10000000,
2021-10-11 20:59:55 +02:00
},
2021-11-16 17:59:53 +01:00
onSwitchExchange: async () => {
null;
},
2021-09-13 18:32:58 +02:00
terms: {
2021-11-22 21:34:27 +01:00
content: {
2021-11-15 15:18:58 +01:00
type: "xml",
2021-09-13 18:32:58 +02:00
document: new DOMParser().parseFromString(termsXml, "text/xml"),
},
2021-11-15 15:18:58 +01:00
status: "accepted",
2021-11-22 21:34:27 +01:00
version: "",
2021-11-15 15:18:58 +01:00
},
});