wallet-core/packages/taler-wallet-webextension/src/wallet/DepositPage.stories.tsx

91 lines
2.3 KiB
TypeScript
Raw Normal View History

2021-12-23 19:17:36 +01:00
/*
This file is part of GNU Taler
2022-06-06 17:05:26 +02:00
(C) 2022 Taler Systems S.A.
2021-12-23 19:17:36 +01:00
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/>
*/
/**
*
* @author Sebastian Javier Marchano (sebasjm)
*/
2022-04-22 21:10:21 +02:00
import { Amounts, Balance, parsePaytoUri } from "@gnu-taler/taler-util";
import type { DepositGroupFees } from "@gnu-taler/taler-wallet-core/src/operations/deposits.js";
2022-03-29 04:41:07 +02:00
import { createExample } from "../test-utils.js";
2022-04-22 21:10:21 +02:00
import {
createLabelsForBankAccount,
View as TestedComponent,
} from "./DepositPage.js";
2021-12-23 19:17:36 +01:00
export default {
title: "wallet/deposit",
component: TestedComponent,
argTypes: {},
};
async function alwaysReturnFeeToOne(): Promise<DepositGroupFees> {
2021-12-23 19:17:36 +01:00
const fee = {
currency: "EUR",
value: 1,
fraction: 0,
};
return { coin: fee, refresh: fee, wire: fee };
}
export const WithEmptyAccountList = createExample(TestedComponent, {
2022-04-22 21:10:21 +02:00
state: {
status: "no-accounts",
cancelHandler: {},
},
// accounts: [],
// balances: [
// {
// available: "USD:10",
// } as Balance,
// ],
// currency: "USD",
// onCalculateFee: alwaysReturnFeeToOne,
2021-12-23 19:17:36 +01:00
});
2022-04-22 21:10:21 +02:00
const ac = parsePaytoUri("payto://iban/ES8877998399652238")!;
const accountMap = createLabelsForBankAccount([ac]);
2021-12-23 19:17:36 +01:00
export const WithSomeBankAccounts = createExample(TestedComponent, {
2022-04-22 21:10:21 +02:00
state: {
status: "ready",
account: {
list: accountMap,
value: accountMap[0],
onChange: async () => {
null;
},
},
currency: "USD",
amount: {
onInput: async () => {
null;
},
value: "10:USD",
},
cancelHandler: {},
depositHandler: {
onClick: async () => {
return;
},
},
2022-04-22 21:10:21 +02:00
totalFee: Amounts.getZero("USD"),
totalToDeposit: Amounts.parseOrThrow("USD:10"),
// onCalculateFee: alwaysReturnFeeToOne,
},
2021-12-23 19:17:36 +01:00
});