Created
September 15, 2017 17:16
-
-
Save itsjoekent/c87e3cbf2d355ace02ac0f3273bbaf07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* view the diff here https://imgur.com/a/cdHwP | |
*/ | |
import { connect } from 'react-redux'; | |
import { Connector as PuckConnector } from 'puck-client'; | |
import Feed from './Feed'; | |
import { clickedViewMore, clickedSignUp } from '../../actions'; | |
import { | |
getBlocksWithReportbacks, | |
getVisibleBlocks, | |
getBlockOffset, | |
getMaximumOffset, | |
} from '../../selectors/feed'; | |
/** | |
* Provide state from the Redux store as props for this component. | |
*/ | |
const mapStateToProps = state => ({ | |
blocks: getBlocksWithReportbacks(getVisibleBlocks(state), state), | |
canLoadMorePages: getBlockOffset(state) < getMaximumOffset(state), | |
campaignId: state.campaign.legacyCampaignId, | |
callToAction: state.campaign.callToAction, | |
signedUp: state.signups.data.includes(state.campaign.legacyCampaignId), | |
hasNewSignup: state.signups.thisSession, | |
hasPendingSignup: state.signups.isPending, | |
isAuthenticated: state.user.id !== null, | |
}); | |
/** | |
* Provide pre-bound functions that allow the component to dispatch | |
* actions to the Redux store as props for this component. | |
*/ | |
const actionCreators = { | |
clickedViewMore, | |
clickedSignUp, | |
}; | |
const mapPropsToEvents = (trackEvent) => ({ | |
clickedViewMore: props => ( | |
trackEvent('feed clicked view more', { campaignId: props.campaignId }) | |
), | |
}); | |
// Export the container component. | |
export default connect(mapStateToProps, actionCreators)(PuckConnector(Feed, mapPropsToEvents)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment