import React, {PropTypes} from 'react'; import {Button, Drawer} from 'coral-ui'; import styles from './UserDetail.css'; import {compose} from 'react-apollo'; import {getUserDetail} from 'coral-admin/src/graphql/queries'; import Slot from 'coral-framework/components/Slot'; class UserDetail extends React.Component { static propTypes = { id: PropTypes.string.isRequired, hideUserDetail: PropTypes.func.isRequired } copyPermalink = () => { this.profile.select(); try { document.execCommand('copy'); } catch (e) { /* nothing */ } } render () { const {data, hideUserDetail} = this.props; if (!('user' in data)) { return null; } const {user, totalComments, rejectedComments} = data; const localProfile = user.profiles.find((p) => p.provider === 'local'); let profile; if (localProfile) { profile = localProfile.id; } let rejectedPercent = rejectedComments / totalComments; if (rejectedPercent === Infinity || isNaN(rejectedPercent)) { // if totalComments is 0, you're dividing by zero, which is naughty rejectedPercent = 0; } return (

{user.username}

{profile && this.profile = ref} value={profile} />}

Member since {new Date(user.created_at).toLocaleString()}


Account summary
Data represents the last six months of activity

Total Comments

{totalComments}

Reject Rate

{`${(rejectedPercent).toFixed(1)}%`}

); } } export default compose( getUserDetail )(UserDetail);