quintodrome/ui/src/user/UserList.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.3 KiB
JavaScript
Raw Normal View History

2020-01-19 16:40:18 -09:00
import React from 'react'
import {
BooleanField,
Datagrid,
Filter,
2020-01-19 17:39:37 -09:00
DateField,
2020-01-19 16:40:18 -09:00
SearchInput,
SimpleList,
TextField,
} from 'react-admin'
import { useMediaQuery } from '@material-ui/core'
2020-05-15 06:20:11 -08:00
import { List } from '../common'
2020-01-19 16:40:18 -09:00
const UserFilter = (props) => (
<Filter {...props} variant={'outlined'}>
2020-01-19 17:39:37 -09:00
<SearchInput source="name" alwaysOn />
2020-01-19 16:40:18 -09:00
</Filter>
)
const UserList = (props) => {
const isXsmall = useMediaQuery((theme) => theme.breakpoints.down('xs'))
return (
<List
{...props}
2020-01-20 05:54:29 -09:00
sort={{ field: 'userName', order: 'ASC' }}
2020-01-19 16:40:18 -09:00
exporter={false}
2020-06-10 12:13:02 -08:00
bulkActionButtons={false}
2020-01-19 16:40:18 -09:00
filters={<UserFilter />}
>
{isXsmall ? (
<SimpleList
2020-01-30 16:20:06 -09:00
primaryText={(record) => record.userName}
secondaryText={(record) =>
record.lastLoginAt && new Date(record.lastLoginAt).toLocaleString()
}
2020-01-19 17:39:37 -09:00
tertiaryText={(record) => (record.isAdmin ? '[admin]' : '')}
2020-01-19 16:40:18 -09:00
/>
) : (
2020-01-19 17:39:37 -09:00
<Datagrid rowClick="edit">
2020-01-20 05:54:29 -09:00
<TextField source="userName" />
2020-01-30 16:20:06 -09:00
<TextField source="name" />
2020-01-19 16:40:18 -09:00
<BooleanField source="isAdmin" />
<DateField source="lastLoginAt" sortByOrder={'DESC'} />
<DateField source="updatedAt" sortByOrder={'DESC'} />
2020-01-19 16:40:18 -09:00
</Datagrid>
)}
</List>
)
}
export default UserList