Skip to content

Commit

Permalink
Merge pull request #108 from debtcollective/feat/total-donation-amount
Browse files Browse the repository at this point in the history
feat/total-donation-amount
  • Loading branch information
castrolem authored Oct 15, 2019
2 parents 71ae227 + 1f07869 commit 4fff9d4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/javascript/bundles/User/components/DonationsHistory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,28 @@ const DONATION_TYPES = {
SUBSCRIPTION: 'Monthly Subscription'
}

const calcDonationTotal = donations => {
return donations.reduce((acc, donation) => (acc += donation), 0)
}

function DonationsView ({ activePlan, donations }) {
const classes = useStyles()
const donatedAmount = calcDonationTotal(
donations.map(donation => Number(donation.amount))
)

return (
<Paper className={classes.root}>
<h3>Your Donations History</h3>
{activePlan && (
<p>
Your're <strong>currently subscribed to {activePlan.name}</strong>.
You're <strong>currently subscribed to {activePlan.name}</strong>.
</p>
)}
<p>
You have donated:{' '}
<strong>{numeral(donatedAmount).format('$0,0.00')}</strong>
</p>
<Table className={classes.table}>
<TableHead>
<TableRow>
Expand Down

0 comments on commit 4fff9d4

Please sign in to comment.