This commit is contained in:
Dan Zajdband
2016-11-14 17:03:31 -05:00
parent 9c41adf224
commit e53ac55e6b
3 changed files with 12 additions and 13 deletions
+4 -5
View File
@@ -42,9 +42,8 @@ export const newPage = () => ({
});
export const setRole = (id, role) => dispatch => {
return fetch(`${base}/user/${id}/role`, getInit('POST', { role }))
return fetch(`${base}/user/${id}/role`, getInit('POST', {role}))
.then(() => {
return dispatch({ type: SET_ROLE, id, role });
})
}
return dispatch({type: SET_ROLE, id, role});
});
};
@@ -1,10 +1,10 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { SelectField, Option } from 'react-mdl-selectfield';
import React, {Component} from 'react';
import {connect} from 'react-redux';
import {SelectField, Option} from 'react-mdl-selectfield';
import styles from './Community.css';
import I18n from 'coral-framework/i18n/i18n';
import translations from '../../translations';
import { setRole } from '../../actions/community';
import {setRole} from '../../actions/community';
const lang = new I18n(translations);
@@ -20,7 +20,7 @@ class Table extends Component {
}
render () {
const { headers, commenters, onHeaderClickHandler } = this.props;
const {headers, commenters, onHeaderClickHandler} = this.props;
return (
<table className={`mdl-data-table ${styles.dataTable}`}>
@@ -63,4 +63,4 @@ class Table extends Component {
}
}
export default connect(state => ({ commenters: state.community.get('commenters') }))(Table);
export default connect(state => ({commenters: state.community.get('commenters')}))(Table);
+2 -2
View File
@@ -38,11 +38,11 @@ export default function community (state = initialState, action) {
})
.set('commenters', commenters); // Sets to normal array
}
case SET_ROLE:
case SET_ROLE :
const commenters = state.get('commenters');
const idx = commenters.findIndex(el => el.id === action.id);
commenters[idx].roles[0] = action.role
commenters[idx].roles[0] = action.role;
return state.set('commenters', commenters);
case SORT_UPDATE :
return state