-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
79 additions
and
288 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,24 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import _ from 'lodash'; | ||
import { connect } from 'react-redux'; | ||
import { getIsAuthenticated, getRecommendations } from '../../reducers'; | ||
import { getCryptoDetails } from '../../helpers/cryptosHelper'; | ||
import { updateRecommendations } from '../../user/userActions'; | ||
import InterestingPeople from './InterestingPeople'; | ||
import InterestingPeopleContainer from '../../containers/InterestingPeopleContainer'; | ||
import CryptoTrendingCharts from './CryptoTrendingCharts'; | ||
|
||
@connect( | ||
state => ({ | ||
authenticated: getIsAuthenticated(state), | ||
recommendations: getRecommendations(state), | ||
}), | ||
{ updateRecommendations }, | ||
) | ||
class FeedSidebar extends React.Component { | ||
static propTypes = { | ||
authenticated: PropTypes.bool.isRequired, | ||
recommendations: PropTypes.arrayOf(PropTypes.shape({ name: PropTypes.string })).isRequired, | ||
updateRecommendations: PropTypes.func.isRequired, | ||
}; | ||
const FeedSidebar = ({ match }) => { | ||
const currentTag = _.get(match, 'params.tag', ''); | ||
const currentCrypto = getCryptoDetails(currentTag); | ||
|
||
constructor(props) { | ||
super(props); | ||
this.handleInterestingPeopleRefresh = this.handleInterestingPeopleRefresh.bind(this); | ||
} | ||
return ( | ||
<div> | ||
{!_.isEmpty(currentCrypto) && <CryptoTrendingCharts cryptos={[currentTag]} />} | ||
<InterestingPeopleContainer /> | ||
</div> | ||
); | ||
}; | ||
|
||
handleInterestingPeopleRefresh() { | ||
this.props.updateRecommendations(); | ||
} | ||
|
||
render() { | ||
const { authenticated, recommendations } = this.props; | ||
const isAuthenticated = authenticated && recommendations.length > 0; | ||
const currentTag = _.get(this.props, 'match.params.tag', ''); | ||
const currentCrypto = getCryptoDetails(currentTag); | ||
|
||
return ( | ||
<div> | ||
{!_.isEmpty(currentCrypto) && <CryptoTrendingCharts cryptos={[currentTag]} />} | ||
{isAuthenticated && ( | ||
<InterestingPeople | ||
users={recommendations} | ||
onRefresh={this.handleInterestingPeopleRefresh} | ||
/> | ||
)} | ||
</div> | ||
); | ||
} | ||
} | ||
FeedSidebar.propTypes = { | ||
match: PropTypes.shape().isRequired, | ||
}; | ||
|
||
export default FeedSidebar; |
137 changes: 0 additions & 137 deletions
137
src/client/components/Sidebar/InterestingPeopleWithAPI.js
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { connect } from 'react-redux'; | ||
import { getRecommendations } from '../reducers'; | ||
import { updateRecommendations } from '../user/userActions'; | ||
import InterestingPeople from '../components/Sidebar/InterestingPeople'; | ||
|
||
const mapStateToProps = state => ({ | ||
users: getRecommendations(state), | ||
}); | ||
|
||
const mapDispatchToProps = dispatch => ({ | ||
onRefresh: () => dispatch(updateRecommendations()), | ||
}); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(InterestingPeople); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { connect } from 'react-redux'; | ||
import { getIsAuthFetching } from '../reducers'; | ||
import PostRecommendation from '../components/Sidebar/PostRecommendation'; | ||
|
||
const mapStateToProps = state => ({ | ||
isAuthFetching: getIsAuthFetching(state), | ||
}); | ||
|
||
export default connect(mapStateToProps)(PostRecommendation); |
Oops, something went wrong.