import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import dateFnsFormat from 'date-fns/format'; import UserPicture from '../../User/UserPicture'; import UserMenu from './UserMenu'; import { createSubscribedElement } from '../../UnstatedUtils'; import AppContainer from '../../../services/AppContainer'; class UserTable extends React.Component { constructor(props) { super(props); this.state = { }; this.getUserStatusLabel = this.getUserStatusLabel.bind(this); } /** * user.statusをみてステータスのラベルを返す * @param {string} userStatus * @return ステータスラベル */ getUserStatusLabel(userStatus) { let additionalClassName; let text; switch (userStatus) { case 1: additionalClassName = 'label-info'; text = 'Approval Pending'; break; case 2: additionalClassName = 'label-success'; text = 'Active'; break; case 3: additionalClassName = 'label-warning'; text = 'Suspended'; break; case 4: additionalClassName = 'label-danger'; text = 'Deleted'; break; case 5: additionalClassName = 'label-info'; text = 'Invited'; break; } return ( {text} ); } render() { const { t } = this.props; return (

{ t('User_Management') }

{this.props.users.map((user) => { return ( ); })}
# { t('status') } { t('User') } { t('Name') } { t('Email') } { t('Created') } { t('Last_Login') }
{user.admin && { t('administrator') }} {this.getUserStatusLabel(user.status)} {user.username} {user.name} {user.email} {dateFnsFormat(new Date(user.createdAt), 'YYYY-MM-DD')} { user.lastLoginAt && {dateFnsFormat(new Date(user.lastLoginAt), 'YYYY-MM-DD HH:mm')} }
); } } const UserTableWrapper = (props) => { return createSubscribedElement(UserTable, props, [AppContainer]); }; UserTable.propTypes = { t: PropTypes.func.isRequired, // i18next appContainer: PropTypes.instanceOf(AppContainer).isRequired, users: PropTypes.array.isRequired, onPasswordResetClicked: PropTypes.func.isRequired, }; export default withTranslation()(UserTableWrapper);