Working on transaction data

This commit is contained in:
mistikk 2018-11-12 23:57:58 +01:00
parent 5c4ff494ec
commit 1034965a06
3 changed files with 104 additions and 10 deletions

View File

@ -22,6 +22,7 @@
"import/prefer-default-export": "off",
"react/prop-types": 0,
"import/no-named-default": "off",
"no-param-reassign": "off"
"no-param-reassign": "off",
"no-case-declarations": "off"
}
}

View File

@ -3,10 +3,14 @@ import { View } from 'react-native';
// Constants
// Utilities
import parseToken from '../../../utils/parseToken';
import parseDate from '../../../utils/parseDate';
import { vestsToSp } from '../../../utils/conversions';
// Components
import { FilterBar } from '../../filterBar';
import { GrayWrapper, WalletLineItem, Card } from '../../basicUIElements';
import { CollapsibleCard } from '../../collapsibleCard';
class TransactionView extends Component {
/* Props
@ -24,8 +28,98 @@ class TransactionView extends Component {
// Component Functions
_handleOnDropdownSelect = () => {};
_getTransactionData = (transaction) => {
const { walletData } = this.props;
const result = {};
result.opName = transaction[1].op[0];
const opData = transaction[1].op[1];
const { timestamp } = transaction[1];
result.transDate = parseDate(timestamp);
result.icon = 'local_activity';
switch (result.opName) {
case 'curation_reward':
const { reward } = opData;
const { comment_author: commentAuthor, comment_permlink: commentPermlink } = opData;
result.value = `${vestsToSp(parseToken(reward), walletData.steemPerMVests)} SP`;
result.details = `@${commentAuthor}/${commentPermlink}`;
break;
case 'author_reward':
case 'comment_benefactor_reward':
let {
sbd_payout: sbdPayout,
steem_payout: steemPayout,
vesting_payout: vestingPayout,
} = opData;
const { author, permlink } = opData;
sbdPayout = parseToken(sbdPayout);
steemPayout = parseToken(steemPayout);
vestingPayout = parseToken(vestingPayout);
result.value = `${sbdPayout > 0 ? `${sbdPayout} SBD` : ''} ${
steemPayout > 0 ? `${steemPayout} steemPayout` : ''
} ${vestingPayout > 0 ? `${vestsToSp(vestingPayout, walletData.steemPerMVests)} SP` : ''}`;
result.details = `@${author}/${permlink}`;
if (result.opName === 'comment_benefactor_reward') {
result.icon = 'comment';
}
break;
case 'claim_reward_balance':
let {
reward_sbd: rewardSdb,
reward_steem: rewardSteem,
reward_vests: rewardVests,
} = opData;
rewardSdb = parseToken(rewardSdb);
rewardSteem = parseToken(rewardSteem);
rewardVests = parseToken(rewardVests);
result.value = `${rewardSdb > 0 ? `${rewardSdb} SBD` : ''} ${
rewardSteem > 0 ? `${rewardSteem} STEEM` : ''
} ${rewardVests > 0 ? `${vestsToSp(rewardVests, walletData.steemPerMVests)} SP` : ''}`;
break;
case 'transfer':
case 'transfer_to_vesting':
const {
amount, memo, from, to,
} = opData;
result.value = `${amount}`;
result.icon = 'compare_arrows';
// details = <span>{memo} <br/><br/> <strong>@{from}</strong> -&gt; <strong>@{to}</strong></span>;
break;
case 'withdraw_vesting':
const { acc } = opData;
let { vesting_shares: opVestingShares } = opData;
opVestingShares = parseToken(opVestingShares);
result.value = `${vestsToSp(opVestingShares, walletData.steemPerMVests)} SP`;
result.icon = 'money';
// details = <span><strong>@{acc}</strong></span>;
break;
case 'fill_order':
const { current_pays: currentPays, open_pays: openPays } = opData;
result.value = `${currentPays} = ${openPays}`;
result.icon = 'reorder';
break;
default:
break;
}
return result;
};
render() {
const { transactions } = this.props;
const { walletData: { transactions } } = this.props;
console.log('transactions :', transactions);
return (
<View>
<FilterBar
@ -39,17 +133,17 @@ class TransactionView extends Component {
<Card>
{transactions
&& transactions.map((item, index) => {
const transactionData = this._getTransactionData(item);
if (index % 2 === 0) {
return (
<WalletLineItem
text={item[1].op[0]}
description="32 minutes ago"
text={transactionData.opName}
isCircleIcon
isThin
circleIconColor="white"
textColor="#3c4449"
iconName="ios-chatboxes"
rightText="18,891.867 STEEM"
rightText={transactionData.value}
tightTextColor="red"
/>
);
@ -57,14 +151,13 @@ class TransactionView extends Component {
return (
<GrayWrapper>
<WalletLineItem
text="Comment Benefactor Reward"
description="32 minutes ago"
text={transactionData.opName}
isCircleIcon
isThin
circleIconColor="white"
textColor="#3c4449"
iconName="ios-chatboxes"
rightText="18,891.867 STEEM"
rightText={transactionData.value}
tightTextColor="red"
/>
</GrayWrapper>

View File

@ -83,7 +83,7 @@ class WalletView extends Component {
{walletData === null ? (
<WalletDetailsPlaceHolder />
) : (
<Transaction transactions={walletData.transactions} />
<Transaction walletData={walletData} />
)}
</ScrollView>
</View>