Loading assets and adding to store.

This commit is contained in:
David Jay
2016-12-14 19:58:04 -05:00
parent 78c81aeaf4
commit faafbfa78c
4 changed files with 28 additions and 4 deletions
@@ -0,0 +1 @@
export const ASSETS_FETCH = 'ASSETS_FETCH';
@@ -1,6 +1,8 @@
import React, {Component} from 'react';
import styles from './Streams.css';
import {connect} from 'react-redux';
import I18n from 'coral-framework/modules/i18n/i18n';
import {ASSETS_FETCH} from '../../constants/assets';
import translations from '../../translations.json';
import {
RadioGroup,
@@ -18,6 +20,10 @@ class Streams extends Component {
statusFilter: 'all'
}
componentDidMount () {
this.props.fetchAssets(0, 25, '', 'desc');
}
onSettingChange = (setting) => (e) => {
this.setState({[setting]: e.target.value});
}
@@ -90,6 +96,21 @@ class Streams extends Component {
}
}
export default Streams;
const mapStateToProps = () => {};
const mapDispatchToProps = (dispatch) => {
return {
fetchAssets: (skip, limit, search, sort) => {
dispatch({
type: ASSETS_FETCH,
skip,
limit,
search,
sort
});
}
};
};
export default connect(mapStateToProps, mapDispatchToProps)(Streams);
const lang = new I18n(translations);
+3 -1
View File
@@ -4,6 +4,7 @@ import settings from 'reducers/settings';
import community from 'reducers/community';
import users from 'reducers/users';
import auth from 'reducers/auth';
import assets from 'reducers/assets';
// Combine all reducers into a main one
export default combineReducers({
@@ -11,5 +12,6 @@ export default combineReducers({
comments,
community,
auth,
users
users,
assets
});
+2 -2
View File
@@ -20,8 +20,8 @@ router.get('/', (req, res, next) => {
Asset
.search(search)
.sort({[field]: (sort === 'asc') ? 1 : -1})
.skip(skip)
.limit(limit),
.skip(parseInt(skip))
.limit(parseInt(limit)),
Asset
.search(search)
.count()