Added: Connected HomeSubjects
This commit is contained in:
parent
7222bd7b0e
commit
91806aaebb
5 changed files with 16 additions and 9 deletions
|
|
@ -22,7 +22,7 @@ const HomeSubject = ({ subject, t }) => (
|
||||||
</Link>
|
</Link>
|
||||||
</h2>
|
</h2>
|
||||||
<h6 className="count">
|
<h6 className="count">
|
||||||
{t('public_figure', subject.associatedPublicFigures.length)}
|
{t('public_figure', subject.publicFigures.length)}
|
||||||
</h6>
|
</h6>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:50%; text-align:center;vertical-align:middle;">
|
<td style="width:50%; text-align:center;vertical-align:middle;">
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { getHomeSubjects } from 'store/selectors';
|
import { getHomeSubjects } from 'store/selectors';
|
||||||
import { onLastStatementsAccess } from 'store/actions/entities';
|
import { onHottestSubjectsAccess } from 'store/actions/entities';
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
statements: getHomeSubjects(state),
|
subjects: getHomeSubjects(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
onAccess: () => dispatch(onLastStatementsAccess()),
|
onAccess: () => dispatch(onHottestSubjectsAccess()),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps);
|
export default connect(mapStateToProps, mapDispatchToProps);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import React, { PropTypes, Component } from 'react';
|
import React, { PropTypes, Component } from 'react';
|
||||||
import HomeSubject from './HomeSubject';
|
import HomeSubject from './HomeSubject';
|
||||||
|
import connector from './connectors';
|
||||||
|
|
||||||
class HomeSubjects extends Component {
|
class HomeSubjects extends Component {
|
||||||
|
|
||||||
|
|
@ -10,11 +11,15 @@ class HomeSubjects extends Component {
|
||||||
render() {
|
render() {
|
||||||
if (!this.props.subjects) return <span>loading subjects ...</span>;
|
if (!this.props.subjects) return <span>loading subjects ...</span>;
|
||||||
|
|
||||||
return this.props.subjects.map(
|
return (
|
||||||
s => <HomeSubject subject={s} />
|
<div> {/* TODO Bootstrap */}
|
||||||
|
{this.props.subjects.map(
|
||||||
|
s => <HomeSubject subject={s} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default HomeSubjects;
|
export default connector(HomeSubjects);
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ export const onLastStatementsAccess = () => ({
|
||||||
listType: 'latest',
|
listType: 'latest',
|
||||||
});
|
});
|
||||||
|
|
||||||
export const onHotestSubjectsAccess = () => ({
|
export const onHottestSubjectsAccess = () => ({
|
||||||
type: actionsTypes.ENTITY_ACCESS,
|
type: actionsTypes.ENTITY_ACCESS,
|
||||||
accessType: 'list',
|
accessType: 'list',
|
||||||
entityType: 'subjects',
|
entityType: 'subjects',
|
||||||
listType: 'hotest',
|
listType: 'hottest',
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,5 @@ import { values, pipe } from 'ramda';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
|
||||||
export const getSubjects = state => state.entities.subjects;
|
export const getSubjects = state => state.entities.subjects;
|
||||||
|
|
||||||
|
export const getHomeSubjects = state => values(getSubjects(state));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue