quintodrome/ui/src/user/UserList.js

48 lines
1 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
List,
SearchInput,
SimpleList,
TextField
} from 'react-admin'
import { useMediaQuery } from '@material-ui/core'
const UserFilter = (props) => (
<Filter {...props}>
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}
filters={<UserFilter />}
>
{isXsmall ? (
<SimpleList
primaryText={(record) => record.name}
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-19 16:40:18 -09:00
<BooleanField source="isAdmin" />
<DateField source="lastAccessAt" locales="pt-BR" />
<DateField source="updatedAt" locales="pt-BR" />
</Datagrid>
)}
</List>
)
}
export default UserList