import React from 'react'; import PropTypes from 'prop-types'; import Comment from './UserDetailComment'; import styles from './UserDetail.css'; import {Icon, Button, Drawer, Spinner} from 'coral-ui'; import {Slot} from 'coral-framework/components'; import ButtonCopyToClipboard from './ButtonCopyToClipboard'; import {actionsMap} from '../utils/moderationQueueActionsMap'; import ClickOutside from 'coral-framework/components/ClickOutside'; import LoadMore from '../components/LoadMore'; import cn from 'classnames'; export default class UserDetail extends React.Component { static propTypes = { userId: PropTypes.string.isRequired, hideUserDetail: PropTypes.func.isRequired, root: PropTypes.object.isRequired, bannedWords: PropTypes.array.isRequired, suspectWords: PropTypes.array.isRequired, acceptComment: PropTypes.func.isRequired, rejectComment: PropTypes.func.isRequired, changeStatus: PropTypes.func.isRequired, toggleSelect: PropTypes.func.isRequired, bulkAccept: PropTypes.func.isRequired, bulkReject: PropTypes.func.isRequired, } rejectThenReload = (info) => { this.props.rejectComment(info).then(() => { this.props.data.refetch(); }); } acceptThenReload = (info) => { this.props.acceptComment(info).then(() => { this.props.data.refetch(); }); } showAll = () => { this.props.changeStatus('all'); } showRejected = () => { this.props.changeStatus('rejected'); } renderLoading() { return ( ); } renderLoaded() { const { root: { user, totalComments, rejectedComments, comments: {nodes, hasNextPage} }, activeTab, selectedCommentIds, bannedWords, suspectWords, toggleSelect, bulkAccept, bulkReject, hideUserDetail, viewUserDetail, loadMore, } = this.props; let rejectedPercent = (rejectedComments / totalComments) * 100; if (rejectedPercent === Infinity || isNaN(rejectedPercent)) { // if totalComments is 0, you're dividing by zero, which is naughty rejectedPercent = 0; } return ( {user.username} Member Since: {new Date(user.created_at).toLocaleString()} {user.profiles.map(({id}) => Email: {id} )} Total Comments {totalComments} Reject Rate {`${(rejectedPercent).toFixed(1)}%`} Reports Reliable Data represents the last six months of activity { selectedCommentIds.length === 0 ? ( All Rejected ) : ( {`${selectedCommentIds.length} comments selected`} ) } { nodes.map((comment) => { const status = comment.action_summaries ? 'FLAGGED' : comment.status; const selected = selectedCommentIds.indexOf(comment.id) !== -1; return ; }) } ); } render () { if (this.props.loading) { return this.renderLoading(); } return this.renderLoaded(); } }
Data represents the last six months of activity