-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathApp.js.example
52 lines (49 loc) · 1.52 KB
/
App.js.example
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
// in src/App.js
import React from 'react';
import { Admin, Resource } from 'react-admin';
import postgrestClient from 'aor-postgrest-client';
import { List, Datagrid, TextField, NumberField } from 'react-admin';
import { ShowButton, EditButton, Edit, SimpleForm, DisabledInput, TextInput, NumberInput } from 'react-admin';
import { Create} from 'react-admin';
import { Show, SimpleShowLayout } from 'react-admin';
const BookList = (props) => (
<List {...props}>
<Datagrid>
<ShowButton />
<EditButton />
<TextField source="author" />
<NumberField source="count" />
</Datagrid>
</List>
);
export const BookShow = (props) => (
<Show {...props}>
<SimpleShowLayout>
<TextField source="author" />
<NumberField source="count" />
</SimpleShowLayout>
</Show>
);
export const BookEdit = (props) => (
<Edit {...props}>
<SimpleForm>
<DisabledInput source="id" />
<TextInput source="author" />
<NumberInput source="count" />
</SimpleForm>
</Edit>
);
export const BookCreate = (props) => (
<Create {...props}>
<SimpleForm>
<TextInput source="author" />
<NumberInput source="count" />
</SimpleForm>
</Create>
);
const App = () => (
<Admin dataProvider={postgrestClient('http://localhost:3000')}>
<Resource name="books" show={BookShow} create={BookCreate} edit={BookEdit} list={BookList} />
</Admin>
);
export default App;