fix(donate): extract active donors from selectors

This commit is contained in:
Mrugesh Mohapatra
2019-02-07 21:59:01 +05:30
committed by Stuart Taylor
parent 02e6e711cf
commit 66d628ff2f
2 changed files with 39 additions and 23 deletions

View File

@ -1,7 +1,21 @@
import React, { Component } from 'react'; import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
class DonateText extends Component { import { activeDonationsSelector } from '../../../redux';
render() {
const propTypes = {
activeDonations: PropTypes.number
};
const mapStateToProps = createSelector(
activeDonationsSelector,
activeDonations => ({ activeDonations })
);
const DonateText = ({ activeDonations }) => {
const donationsLocale = activeDonations.toLocaleString();
return ( return (
<div className='text-center'> <div className='text-center'>
<p> <p>
@ -9,7 +23,7 @@ class DonateText extends Component {
people learn to code for free. people learn to code for free.
</p> </p>
<p> <p>
Join <strong>4,180</strong> supporters. Join <strong>{donationsLocale}</strong> supporters.
</p> </p>
<p> <p>
Your $5 / month donation will help keep tech education free and Your $5 / month donation will help keep tech education free and
@ -17,7 +31,9 @@ class DonateText extends Component {
</p> </p>
</div> </div>
); );
} };
}
export default DonateText; DonateText.displayName = 'DonateText';
DonateText.propTypes = propTypes;
export default connect(mapStateToProps)(DonateText);

View File

@ -62,8 +62,8 @@ function Supporters({ isDonating, activeDonations }) {
them to join the community. them to join the community.
</Fragment> </Fragment>
) : ( ) : (
`Join ${donationsLocale} supporters. Your $5 / month donation will help ` + `Join ${donationsLocale} supporters. Your $5 / month` +
'keep tech education free and open.' 'donation will help keep tech education free and open.'
)} )}
</p> </p>
</b> </b>