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