mirror of
https://github.com/wassname/talk.git
synced 2026-06-30 03:31:01 +08:00
Refactor for setUserStatus to setUserBanStatus
This commit is contained in:
@@ -59,7 +59,7 @@ const Table = ({users, setRole, onHeaderClickHandler, setUserBanStatus, viewUser
|
||||
containerClassName="talk-admin-community-people-dd-status"
|
||||
value={getStatus(row.status)}
|
||||
placeholder={t('community.status')}
|
||||
onChange={(status) => setUserBanStatus({id: row.id, status: status !== 'BANNED'})}>
|
||||
onChange={(status) => setUserBanStatus({id: row.id, status: status === 'BANNED'})}>
|
||||
<Option value={'ACTIVE'} label={t('community.active')} />
|
||||
<Option value={'BANNED'} label={t('community.banned')} />
|
||||
</Dropdown>
|
||||
|
||||
@@ -3,7 +3,7 @@ import {bindActionCreators} from 'redux';
|
||||
import {compose, gql} from 'react-apollo';
|
||||
import withQuery from 'coral-framework/hocs/withQuery';
|
||||
import {getDefinitionName} from 'coral-framework/utils';
|
||||
import {withSetUserBanStatus, withRejectUsername} from 'coral-framework/graphql/mutations';
|
||||
import {withRejectUsername} from 'coral-framework/graphql/mutations';
|
||||
import FlaggedAccounts from '../containers/FlaggedAccounts';
|
||||
import FlaggedUser from '../containers/FlaggedUser';
|
||||
import {hideRejectUsernameDialog} from '../../../actions/community';
|
||||
@@ -48,7 +48,6 @@ const withData = withQuery(gql`
|
||||
|
||||
export default compose(
|
||||
connect(mapStateToProps, mapDispatchToProps),
|
||||
withSetUserBanStatus,
|
||||
withRejectUsername,
|
||||
withData
|
||||
)(Community);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import React from 'react';
|
||||
import {connect} from 'react-redux';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {compose} from 'react-apollo';
|
||||
import People from '../components/People';
|
||||
import PropTypes from 'prop-types';
|
||||
import {withSetUserBanStatus} from 'coral-framework/graphql/mutations';
|
||||
|
||||
import {viewUserDetail} from '../../../actions/userDetail';
|
||||
|
||||
@@ -99,4 +101,7 @@ const mapDispatchToProps = (dispatch) =>
|
||||
setSearchValue,
|
||||
}, dispatch);
|
||||
|
||||
export default connect(null, mapDispatchToProps)(PeopleContainer);
|
||||
export default compose(
|
||||
connect(null, mapDispatchToProps),
|
||||
withSetUserBanStatus,
|
||||
)(PeopleContainer);
|
||||
|
||||
@@ -3,6 +3,7 @@ import {createDefaultResponseFragments} from '../utils';
|
||||
// fragments defined here are automatically registered.
|
||||
export default {
|
||||
...createDefaultResponseFragments(
|
||||
'SetUserBanStatusResponse',
|
||||
'SetUserSuspensionStatusResponse',
|
||||
'SetCommentStatusResponse',
|
||||
'SuspendUserResponse',
|
||||
|
||||
@@ -196,20 +196,19 @@ export const withRejectUsername = withMutation(
|
||||
})
|
||||
});
|
||||
|
||||
export const withsetUserBanStatus = withMutation(
|
||||
export const withSetUserBanStatus = withMutation(
|
||||
gql`
|
||||
mutation SetUserBanStatus($id: ID!, $status: Boolean!) {
|
||||
setUserBanStatus(id: $id, status: $status) {
|
||||
mutation SetUserBanStatus($input: SetUserBanStatusInput!) {
|
||||
setUserBanStatus(input: $input) {
|
||||
...SetUserBanStatusResponse
|
||||
}
|
||||
}
|
||||
`, {
|
||||
props: ({mutate}) => ({
|
||||
setUserBanStatus: ({id, status}) => {
|
||||
setUserBanStatus: (input) => {
|
||||
return mutate({
|
||||
variables: {
|
||||
id,
|
||||
status,
|
||||
input,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -228,7 +227,7 @@ export const withPostComment = withMutation(
|
||||
postComment: (input) => {
|
||||
return mutate({
|
||||
variables: {
|
||||
input
|
||||
input,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user