All files / web/modules/admin/users/list UserList.tsx

0% Statements 0/20
0% Branches 0/2
0% Functions 0/5
0% Lines 0/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65                                                                                                                                 
import * as moment from 'moment';
import * as React from 'react';
import { Query } from 'react-apollo';
import Table from '../../../components/Table';
import UserRole from '../../../components/UserRole';
import CreateUser from '../create/CreateUser';
import DeleteUser from '../delete/DeleteUser';
import EditUser from '../edit/EditUser';
import { USERS } from '../queries';
 
const columns = [
  {
    title: 'Uživatelské jméno',
    dataIndex: 'username',
  },
  {
    title: 'Expirace',
    dataIndex: 'expirationDateTime',
    render: (text: string) => (text ? moment(text).format('DD.MM.YYYY') : null),
  },
  {
    title: 'E-mail',
    dataIndex: 'email',
  },
  {
    title: 'Role',
    dataIndex: 'role',
    render: (text: string) => <UserRole value={text} />,
  },
  {
    title: 'Akce',
    dataIndex: 'id',
    render: (text: string, record: any) => (
      <React.Fragment>
        <EditUser user={record} />
        <DeleteUser user={record} />
      </React.Fragment>
    ),
  },
];
 
const UserList = () => (
  <Query query={USERS}>
    {({ loading, error, data }) => {
      if (error) {
        return null;
      }
 
      return (
        <React.Fragment>
          <CreateUser />
          <Table
            rowKey="id"
            loading={loading}
            dataSource={data.users}
            columns={columns}
          />
        </React.Fragment>
      );
    }}
  </Query>
);
 
export default UserList;