2021-06-03 06:07:29 +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 / >
* /
/ * *
*
* @author Sebastian Javier Marchano ( sebasjm )
* /
2021-06-08 21:01:41 +02:00
import {
PaymentStatus ,
TransactionCommon , TransactionDeposit , TransactionPayment ,
TransactionRefresh , TransactionRefund , TransactionTip , TransactionType ,
TransactionWithdrawal ,
WithdrawalType
} from '@gnu-taler/taler-util' ;
2021-08-23 21:51:49 +02:00
import { createExample } from '../test-utils' ;
2021-06-16 23:21:03 +02:00
import { TransactionView as TestedComponent } from './Transaction' ;
2021-06-03 06:07:29 +02:00
export default {
2021-08-24 18:29:37 +02:00
title : 'wallet/history/details' ,
2021-06-16 23:21:03 +02:00
component : TestedComponent ,
2021-06-28 16:38:29 +02:00
argTypes : {
onRetry : { action : 'onRetry' } ,
onDelete : { action : 'onDelete' } ,
onBack : { action : 'onBack' } ,
}
2021-06-03 06:07:29 +02:00
} ;
const commonTransaction = {
2021-08-24 20:16:11 +02:00
amountRaw : 'KUDOS:11' ,
amountEffective : 'KUDOS:9.2' ,
2021-06-03 06:07:29 +02:00
pending : false ,
timestamp : {
t_ms : new Date ( ) . getTime ( )
} ,
transactionId : '12' ,
} as TransactionCommon
const exampleData = {
withdraw : {
. . . commonTransaction ,
type : TransactionType . Withdrawal ,
exchangeBaseUrl : 'http://exchange.taler' ,
withdrawalDetails : {
confirmed : false ,
exchangePaytoUris : [ 'payto://x-taler-bank/bank/account' ] ,
type : WithdrawalType . ManualTransfer ,
}
} as TransactionWithdrawal ,
payment : {
. . . commonTransaction ,
2021-08-24 20:16:11 +02:00
amountEffective : 'KUDOS:11' ,
2021-06-03 06:07:29 +02:00
type : TransactionType . Payment ,
info : {
contractTermsHash : 'ASDZXCASD' ,
merchant : {
name : 'the merchant' ,
} ,
2021-06-21 01:37:35 +02:00
orderId : '2021.167-03NPY6MCYMVGT' ,
2021-06-03 06:07:29 +02:00
products : [ ] ,
2021-06-21 15:07:56 +02:00
summary : "Essay: Why the Devil's Advocate Doesn't Help Reach the Truth" ,
2021-06-03 06:07:29 +02:00
fulfillmentMessage : '' ,
} ,
2021-06-04 15:46:47 +02:00
proposalId : '1EMJJH8EP1NX3XF7733NCYS2DBEJW4Q2KA5KEB37MCQJQ8Q5HMC0' ,
2021-06-03 06:07:29 +02:00
status : PaymentStatus.Accepted ,
} as TransactionPayment ,
deposit : {
. . . commonTransaction ,
type : TransactionType . Deposit ,
depositGroupId : '#groupId' ,
targetPaytoUri : 'payto://x-taler-bank/bank/account' ,
} as TransactionDeposit ,
refresh : {
. . . commonTransaction ,
type : TransactionType . Refresh ,
exchangeBaseUrl : 'http://exchange.taler' ,
} as TransactionRefresh ,
tip : {
. . . commonTransaction ,
type : TransactionType . Tip ,
merchantBaseUrl : 'http://merchant.taler' ,
} as TransactionTip ,
refund : {
. . . commonTransaction ,
type : TransactionType . Refund ,
2021-06-04 15:46:47 +02:00
refundedTransactionId : 'payment:1EMJJH8EP1NX3XF7733NCYS2DBEJW4Q2KA5KEB37MCQJQ8Q5HMC0' ,
2021-06-03 06:07:29 +02:00
info : {
contractTermsHash : 'ASDZXCASD' ,
merchant : {
name : 'the merchant' ,
} ,
2021-06-21 01:37:35 +02:00
orderId : '2021.167-03NPY6MCYMVGT' ,
2021-06-03 06:07:29 +02:00
products : [ ] ,
summary : 'the summary' ,
fulfillmentMessage : '' ,
} ,
} as TransactionRefund ,
}
2021-06-28 16:38:29 +02:00
const transactionError = {
code : 2000 ,
details : "details" ,
hint : "this is a hint for the error" ,
message : 'message'
}
2021-06-21 01:37:35 +02:00
export const Withdraw = createExample ( TestedComponent , {
2021-06-03 06:07:29 +02:00
transaction : exampleData.withdraw
} ) ;
2021-06-28 16:38:29 +02:00
export const WithdrawError = createExample ( TestedComponent , {
transaction : {
. . . exampleData . withdraw ,
error : transactionError ,
} ,
} ) ;
2021-06-21 01:37:35 +02:00
export const WithdrawPending = createExample ( TestedComponent , {
2021-06-03 06:07:29 +02:00
transaction : { . . . exampleData . withdraw , pending : true } ,
} ) ;
2021-06-21 01:37:35 +02:00
export const Payment = createExample ( TestedComponent , {
2021-06-03 06:07:29 +02:00
transaction : exampleData.payment
} ) ;
2021-06-28 16:38:29 +02:00
export const PaymentError = createExample ( TestedComponent , {
transaction : {
. . . exampleData . payment ,
error : transactionError
} ,
} ) ;
2021-06-21 01:37:35 +02:00
export const PaymentWithoutFee = createExample ( TestedComponent , {
transaction : {
. . . exampleData . payment ,
2021-08-24 20:16:11 +02:00
amountRaw : 'KUDOS:11' ,
2021-06-21 01:37:35 +02:00
}
} ) ;
export const PaymentPending = createExample ( TestedComponent , {
2021-06-03 06:07:29 +02:00
transaction : { . . . exampleData . payment , pending : true } ,
} ) ;
2021-06-21 01:37:35 +02:00
export const PaymentWithProducts = createExample ( TestedComponent , {
2021-06-03 06:07:29 +02:00
transaction : {
. . . exampleData . payment ,
info : {
. . . exampleData . payment . info ,
2021-06-21 01:37:35 +02:00
summary : 'this order has 5 products' ,
2021-06-03 06:07:29 +02:00
products : [ {
description : 't-shirt' ,
2021-06-21 01:37:35 +02:00
unit : 'shirts' ,
quantity : 1 ,
} , {
description : 't-shirt' ,
unit : 'shirts' ,
quantity : 1 ,
} , {
description : 'e-book' ,
} , {
description : 'beer' ,
unit : 'pint' ,
quantity : 15 ,
} , {
description : 'beer' ,
unit : 'pint' ,
quantity : 15 ,
} ]
}
} as TransactionPayment ,
} ) ;
export const PaymentWithLongSummary = createExample ( TestedComponent , {
transaction : {
. . . exampleData . payment ,
info : {
. . . exampleData . payment . info ,
summary : 'this is a very long summary that will occupy severals lines, this is a very long summary that will occupy severals lines, this is a very long summary that will occupy severals lines, this is a very long summary that will occupy severals lines, ' ,
products : [ {
description : 'an xl sized t-shirt with some drawings on it, color pink' ,
unit : 'shirts' ,
quantity : 1 ,
2021-06-03 06:07:29 +02:00
} , {
description : 'beer' ,
2021-06-21 01:37:35 +02:00
unit : 'pint' ,
quantity : 15 ,
2021-06-03 06:07:29 +02:00
} ]
}
} as TransactionPayment ,
} ) ;
2021-06-21 01:37:35 +02:00
export const Deposit = createExample ( TestedComponent , {
2021-06-03 06:07:29 +02:00
transaction : exampleData.deposit
} ) ;
2021-06-28 16:38:29 +02:00
export const DepositError = createExample ( TestedComponent , {
transaction : {
. . . exampleData . deposit ,
error : transactionError
} ,
} ) ;
2021-06-21 01:37:35 +02:00
export const DepositPending = createExample ( TestedComponent , {
2021-06-03 06:07:29 +02:00
transaction : { . . . exampleData . deposit , pending : true }
} ) ;
2021-06-21 01:37:35 +02:00
export const Refresh = createExample ( TestedComponent , {
2021-06-03 06:07:29 +02:00
transaction : exampleData.refresh
} ) ;
2021-06-28 16:38:29 +02:00
export const RefreshError = createExample ( TestedComponent , {
transaction : {
. . . exampleData . refresh ,
error : transactionError
} ,
} ) ;
2021-06-21 01:37:35 +02:00
export const Tip = createExample ( TestedComponent , {
2021-06-03 06:07:29 +02:00
transaction : exampleData.tip
} ) ;
2021-06-28 16:38:29 +02:00
export const TipError = createExample ( TestedComponent , {
transaction : {
. . . exampleData . tip ,
error : transactionError
} ,
} ) ;
2021-06-21 01:37:35 +02:00
export const TipPending = createExample ( TestedComponent , {
2021-06-03 06:07:29 +02:00
transaction : { . . . exampleData . tip , pending : true }
} ) ;
2021-06-21 01:37:35 +02:00
export const Refund = createExample ( TestedComponent , {
2021-06-03 06:07:29 +02:00
transaction : exampleData.refund
} ) ;
2021-06-28 16:38:29 +02:00
export const RefundError = createExample ( TestedComponent , {
transaction : {
. . . exampleData . refund ,
error : transactionError
} ,
} ) ;
2021-06-21 01:37:35 +02:00
export const RefundPending = createExample ( TestedComponent , {
2021-06-08 21:01:41 +02:00
transaction : { . . . exampleData . refund , pending : true }
2021-06-03 06:07:29 +02:00
} ) ;
2021-06-21 01:37:35 +02:00
export const RefundWithProducts = createExample ( TestedComponent , {
2021-06-03 06:07:29 +02:00
transaction : {
. . . exampleData . refund ,
info : {
. . . exampleData . refund . info ,
products : [ {
description : 't-shirt' ,
} , {
description : 'beer' ,
} ]
}
} as TransactionRefund ,
} ) ;