Skip to content

Commit

Permalink
Add Category create
Browse files Browse the repository at this point in the history
  • Loading branch information
alimpens committed Apr 30, 2024
1 parent e3ae954 commit 053c03c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
9 changes: 8 additions & 1 deletion apps/admin/src/components/admin/Admin/Admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fakeDataProvider from 'ra-data-fakerest'
import { Admin as ReactAdmin, Resource } from 'react-admin'

// import { dataProvider } from '../../dataProvider'
import { CategoryCreate } from '../../category/CategoryCreate/CategoryCreate'
import { CategoryEdit } from '../../category/CategoryEdit'
import { CategoryList } from '../../category/CategoryList'
import { FormCreate } from '../../form/FormCreate'
Expand Down Expand Up @@ -69,6 +70,12 @@ export const Admin = () => (
create={<FormCreate />}
options={{ label: 'Vragenlijsten' }}
/>
<Resource name="categories" list={<CategoryList />} edit={<CategoryEdit />} options={{ label: 'Categorieën' }} />
<Resource
name="categories"
list={<CategoryList />}
edit={<CategoryEdit />}
create={<CategoryCreate />}
options={{ label: 'Categorieën' }}
/>
</ReactAdmin>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Create, SaveButton, SimpleForm, TextInput, Toolbar, ToolbarClasses } from 'react-admin'

export const CategoryCreate = () => (
<Create redirect="list">
<SimpleForm
toolbar={
<Toolbar>
<div className={ToolbarClasses.defaultToolbar}>
<SaveButton alwaysEnable />
</div>
</Toolbar>
}
>
<TextInput source="name" />
</SimpleForm>
</Create>
)
13 changes: 11 additions & 2 deletions apps/admin/src/components/category/CategoryEdit/CategoryEdit.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { Edit, SimpleForm, TextInput } from 'react-admin'
import { DeleteButton, Edit, SaveButton, SimpleForm, TextInput, Toolbar, ToolbarClasses } from 'react-admin'

export const CategoryEdit = () => (
<Edit>
<SimpleForm>
<SimpleForm
toolbar={
<Toolbar>
<div className={ToolbarClasses.defaultToolbar}>
<SaveButton alwaysEnable />
<DeleteButton />
</div>
</Toolbar>
}
>
<TextInput source="name" />
</SimpleForm>
</Edit>
Expand Down

0 comments on commit 053c03c

Please sign in to comment.