mirror of
https://github.com/wassname/talk.git
synced 2026-07-02 01:56:20 +08:00
Fix the people tag.
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
import coralApi from '../../../coral-framework/helpers/response';
|
||||
|
||||
export const fetchAccounts = (query = {}) => dispatch => {
|
||||
|
||||
dispatch(requestFetchAccounts());
|
||||
coralApi(`/users?${qs.stringify(query)}`)
|
||||
.then(({result, page, count, limit, totalPages}) =>{
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import React, {Component} from 'react';
|
||||
import {connect} from 'react-redux';
|
||||
import {modUserFlaggedQuery} from 'coral-admin/src/graphql/queries';
|
||||
import {compose} from 'react-apollo';
|
||||
import {
|
||||
fetchAccounts,
|
||||
updateSorting,
|
||||
newPage,
|
||||
fetchFlaggedAccounts,
|
||||
newPage
|
||||
} from '../../actions/community';
|
||||
|
||||
import CommunityMenu from './components/CommunityMenu';
|
||||
@@ -33,6 +34,10 @@ class CommunityContainer extends Component {
|
||||
this.onNewPageHandler = this.onNewPageHandler.bind(this);
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.props.fetchAccounts({});
|
||||
}
|
||||
|
||||
onKeyDownHandler(e) {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
@@ -49,23 +54,15 @@ class CommunityContainer extends Component {
|
||||
search(query = {}) {
|
||||
const {community} = this.props;
|
||||
|
||||
this.props.dispatch(fetchAccounts({
|
||||
this.props.fetchAccounts({
|
||||
value: this.state.searchValue,
|
||||
field: community.fieldPeople,
|
||||
asc: community.ascPeople,
|
||||
...query
|
||||
}));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.props.dispatch(fetchFlaggedAccounts());
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.search();
|
||||
}
|
||||
|
||||
onHeaderClickHandler(sort) {
|
||||
this.props.dispatch(updateSorting(sort));
|
||||
this.search();
|
||||
@@ -76,9 +73,9 @@ class CommunityContainer extends Component {
|
||||
this.search({page});
|
||||
}
|
||||
|
||||
getTabContent(searchValue) {
|
||||
const {community} = this.props;
|
||||
const activeTab = this.props.route.path === ':id' ? 'flagged' : this.props.route.path;
|
||||
getTabContent(searchValue, props) {
|
||||
const {community, data} = props;
|
||||
const activeTab = props.route.path === ':id' ? 'flagged' : props.route.path;
|
||||
|
||||
if (activeTab === 'people') {
|
||||
return (
|
||||
@@ -96,18 +93,18 @@ class CommunityContainer extends Component {
|
||||
|
||||
return (
|
||||
<FlaggedAccounts
|
||||
commenters={community.flaggedAccounts}
|
||||
isFetching={community.isFetchingFlagged}
|
||||
error={community.errorFlagged}
|
||||
commenters={data.usersFlagged}
|
||||
isFetching={data.loading}
|
||||
error={data.error}
|
||||
{...this}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {searchValue, activeTab} = this.state;
|
||||
const {searchValue} = this.state;
|
||||
|
||||
const tab = this.getTabContent(activeTab, searchValue, this.props);
|
||||
const tab = this.getTabContent(searchValue, this.props);
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -124,4 +121,11 @@ const mapStateToProps = state => ({
|
||||
community: state.community.toJS()
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps)(CommunityContainer);
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
fetchAccounts: query => dispatch(fetchAccounts(query))
|
||||
});
|
||||
|
||||
export default compose(
|
||||
connect(mapStateToProps, mapDispatchToProps),
|
||||
modUserFlaggedQuery
|
||||
)(CommunityContainer);
|
||||
|
||||
@@ -6,10 +6,7 @@ import {
|
||||
FETCH_COMMENTERS_SUCCESS,
|
||||
SORT_UPDATE,
|
||||
SET_ROLE,
|
||||
SET_COMMENTER_STATUS,
|
||||
FETCH_FLAGGED_COMMENTERS_REQUEST,
|
||||
FETCH_FLAGGED_COMMENTERS_SUCCESS,
|
||||
FETCH_FLAGGED_COMMENTERS_FAILURE
|
||||
SET_COMMENTER_STATUS
|
||||
} from '../constants/community';
|
||||
|
||||
const initialState = Map({
|
||||
@@ -20,10 +17,7 @@ const initialState = Map({
|
||||
fieldPeople: 'created_at',
|
||||
ascPeople: false,
|
||||
totalPagesPeople: 0,
|
||||
pagePeople: 0,
|
||||
isFetchingFlagged: false,
|
||||
errorFlagged: '',
|
||||
flaggedAccounts: [],
|
||||
pagePeople: 0
|
||||
});
|
||||
|
||||
export default function community (state = initialState, action) {
|
||||
@@ -69,25 +63,6 @@ export default function community (state = initialState, action) {
|
||||
return state
|
||||
.set('fieldPeople', action.sort.field)
|
||||
.set('ascPeople', !state.get('ascPeople'));
|
||||
case FETCH_FLAGGED_COMMENTERS_REQUEST : {
|
||||
return state
|
||||
.set('isFetchingFlagged', true);
|
||||
}
|
||||
case FETCH_FLAGGED_COMMENTERS_SUCCESS : {
|
||||
const {flaggedAccounts, type, ...rest} = action; // eslint-disable-line
|
||||
return state
|
||||
.merge({
|
||||
isFetchingFlagged: false,
|
||||
errorFlagged: '',
|
||||
...rest
|
||||
})
|
||||
.set('flaggedAccounts', flaggedAccounts); // Sets to normal array
|
||||
}
|
||||
case FETCH_FLAGGED_COMMENTERS_FAILURE : {
|
||||
return state
|
||||
.set('isFetchingFlagged', false)
|
||||
.set('errorFlagged', action.error);
|
||||
}
|
||||
default :
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user