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'; import AdminUsersContainer from '../../../services/AdminUsersContainer'; class UserTable extends React.Component { constructor(props) { super(props); this.state = { }; this.getUserStatusLabel = this.getUserStatusLabel.bind(this); } /** * return status label element by `userStatus` * @param {string} userStatus * @return status label element */ 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} ); } /** * sorting */ renderSortIcon(columnName) { return (
| # |
{t('status')}
{ this.renderSortIcon('status') }
|
username
|
{t('Name')}
{ this.renderSortIcon('name')}
|
{t('Email')}
{ this.renderSortIcon('email')}
|
{t('Created')}
{ this.renderSortIcon('createdAt')}
|
{t('Last_Login')}
{ this.renderSortIcon('lastLoginAt')}
|
|
|---|---|---|---|---|---|---|---|
|
|
{this.getUserStatusLabel(user.status)} {this.getUserAdminLabel(user.admin)} | {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')}} |
|