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>
|
||||
</h2>
|
||||
<h6 className="count">
|
||||
{t('public_figure', subject.associatedPublicFigures.length)}
|
||||
{t('public_figure', subject.publicFigures.length)}
|
||||
</h6>
|
||||
</td>
|
||||
<td style="width:50%; text-align:center;vertical-align:middle;">
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import { connect } from 'react-redux';
|
||||
import { getHomeSubjects } from 'store/selectors';
|
||||
import { onLastStatementsAccess } from 'store/actions/entities';
|
||||
import { onHottestSubjectsAccess } from 'store/actions/entities';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
statements: getHomeSubjects(state),
|
||||
subjects: getHomeSubjects(state),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
onAccess: () => dispatch(onLastStatementsAccess()),
|
||||
onAccess: () => dispatch(onHottestSubjectsAccess()),
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import React, { PropTypes, Component } from 'react';
|
||||
import HomeSubject from './HomeSubject';
|
||||
import connector from './connectors';
|
||||
|
||||
class HomeSubjects extends Component {
|
||||
|
||||
|
|
@ -10,11 +11,15 @@ class HomeSubjects extends Component {
|
|||
render() {
|
||||
if (!this.props.subjects) return <span>loading subjects ...</span>;
|
||||
|
||||
return this.props.subjects.map(
|
||||
return (
|
||||
<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',
|
||||
});
|
||||
|
||||
export const onHotestSubjectsAccess = () => ({
|
||||
export const onHottestSubjectsAccess = () => ({
|
||||
type: actionsTypes.ENTITY_ACCESS,
|
||||
accessType: 'list',
|
||||
entityType: 'subjects',
|
||||
listType: 'hotest',
|
||||
listType: 'hottest',
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,3 +3,5 @@ import { values, pipe } from 'ramda';
|
|||
import { createSelector } from 'reselect';
|
||||
|
||||
export const getSubjects = state => state.entities.subjects;
|
||||
|
||||
export const getHomeSubjects = state => values(getSubjects(state));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue