Add UserList in UI
This commit is contained in:
+4
-3
@@ -1,12 +1,13 @@
|
||||
// in src/App.js
|
||||
import React from 'react'
|
||||
import { Admin, ListGuesser, Resource } from 'react-admin'
|
||||
import { Admin, Resource } from 'react-admin'
|
||||
import jsonServerProvider from 'ra-data-json-server'
|
||||
import user from './user'
|
||||
|
||||
const dataProvider = jsonServerProvider('http://jsonplaceholder.typicode.com')
|
||||
const dataProvider = jsonServerProvider('/app/api')
|
||||
const App = () => (
|
||||
<Admin dataProvider={dataProvider}>
|
||||
<Resource name="users" list={ListGuesser} />
|
||||
<Resource name="user" {...user} />
|
||||
</Admin>
|
||||
)
|
||||
export default App
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import React from 'react'
|
||||
import {
|
||||
BooleanField,
|
||||
Datagrid,
|
||||
DateField,
|
||||
Filter,
|
||||
List,
|
||||
SearchInput,
|
||||
SimpleList,
|
||||
TextField
|
||||
} from 'react-admin'
|
||||
import { useMediaQuery } from '@material-ui/core'
|
||||
|
||||
const UserFilter = (props) => (
|
||||
<Filter {...props}>
|
||||
<SearchInput source="q" alwaysOn />
|
||||
</Filter>
|
||||
)
|
||||
|
||||
const UserList = (props) => {
|
||||
const isXsmall = useMediaQuery((theme) => theme.breakpoints.down('xs'))
|
||||
|
||||
return (
|
||||
<List
|
||||
{...props}
|
||||
sort={{ field: 'name', order: 'ASC' }}
|
||||
exporter={false}
|
||||
filters={<UserFilter />}
|
||||
>
|
||||
{isXsmall ? (
|
||||
<SimpleList
|
||||
primaryText={(record) => record.name}
|
||||
secondaryText={(record) => record.email}
|
||||
/>
|
||||
) : (
|
||||
<Datagrid>
|
||||
<TextField source="name" />
|
||||
<BooleanField source="isAdmin" />
|
||||
<DateField source="lastLoginAt" locales="pt-BR" />
|
||||
<DateField source="lastAccessAt" locales="pt-BR" />
|
||||
<DateField source="updatedAt" locales="pt-BR" />
|
||||
</Datagrid>
|
||||
)}
|
||||
</List>
|
||||
)
|
||||
}
|
||||
|
||||
export default UserList
|
||||
@@ -0,0 +1,11 @@
|
||||
import SupervisedUserCircleIcon from '@material-ui/icons/SupervisedUserCircle'
|
||||
import UserList from './UserList'
|
||||
// import UserEdit from './UserEdit'
|
||||
// import UserCreate from './UserCreate'
|
||||
|
||||
export default {
|
||||
list: UserList,
|
||||
// edit: UserEdit,
|
||||
// create: UserCreate,
|
||||
icon: SupervisedUserCircleIcon
|
||||
}
|
||||
Reference in New Issue
Block a user