bigbuffet-rw/app/soapbox/features/admin/awaiting_approval.js

66 lines
2 KiB
JavaScript
Raw Normal View History

import PropTypes from 'prop-types';
2020-12-29 13:55:04 -08:00
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
2020-12-29 13:55:04 -08:00
import { defineMessages, injectIntl } from 'react-intl';
import { connect } from 'react-redux';
2021-07-13 15:59:55 -07:00
import { fetchUsers } from 'soapbox/actions/admin';
import ScrollableList from 'soapbox/components/scrollable_list';
2022-01-10 14:01:24 -08:00
import Column from '../ui/components/column';
2022-01-10 14:01:24 -08:00
import UnapprovedAccount from './components/unapproved_account';
2020-12-29 13:55:04 -08:00
const messages = defineMessages({
heading: { id: 'column.admin.awaiting_approval', defaultMessage: 'Awaiting Approval' },
emptyMessage: { id: 'admin.awaiting_approval.empty_message', defaultMessage: 'There is nobody waiting for approval. When a new user signs up, you can review them here.' },
2020-12-29 13:55:04 -08:00
});
2021-07-13 15:59:55 -07:00
const mapStateToProps = state => ({
accountIds: state.getIn(['admin', 'awaitingApproval']),
});
2020-12-29 13:55:04 -08:00
export default @connect(mapStateToProps)
@injectIntl
class AwaitingApproval extends ImmutablePureComponent {
static propTypes = {
intl: PropTypes.object.isRequired,
2021-07-13 15:59:55 -07:00
accountIds: ImmutablePropTypes.orderedSet.isRequired,
2020-12-29 13:55:04 -08:00
};
state = {
isLoading: true,
}
2020-12-29 13:55:04 -08:00
componentDidMount() {
const { dispatch } = this.props;
2021-07-13 15:27:11 -07:00
dispatch(fetchUsers(['local', 'need_approval']))
.then(() => this.setState({ isLoading: false }))
.catch(() => {});
}
2020-12-29 13:55:04 -08:00
render() {
2021-07-13 15:59:55 -07:00
const { intl, accountIds } = this.props;
const { isLoading } = this.state;
2021-07-13 15:59:55 -07:00
const showLoading = isLoading && accountIds.count() === 0;
2020-12-29 13:55:04 -08:00
return (
<Column icon='user' heading={intl.formatMessage(messages.heading)}>
2021-07-13 15:59:55 -07:00
<ScrollableList
isLoading={isLoading}
showLoading={showLoading}
scrollKey='awaiting-approval'
emptyMessage={intl.formatMessage(messages.emptyMessage)}
>
{accountIds.map(id => (
<UnapprovedAccount accountId={id} key={id} />
))}
</ScrollableList>
2020-12-29 13:55:04 -08:00
</Column>
);
}
}