added edit button to comments and made create to posts
This commit is contained in:
27
src/App.tsx
27
src/App.tsx
@@ -4,20 +4,21 @@ import { dataProvider } from "./dataProvider";
|
|||||||
import { authProvider } from "./authProvider";
|
import { authProvider } from "./authProvider";
|
||||||
import { UserList } from "./components/users/UserList.tsx";
|
import { UserList } from "./components/users/UserList.tsx";
|
||||||
import { UserEdit } from "./components/users/UserEdit.tsx";
|
import { UserEdit } from "./components/users/UserEdit.tsx";
|
||||||
import { PostEdit } from "./components/posts/PostEdit.tsx";
|
|
||||||
import { CommentEdit } from "./components/comments/CommentEdit.tsx";
|
|
||||||
import { AlbumEdit } from "./components/albums/AlbumEdit.tsx";
|
|
||||||
import { PhotoEdit } from "./components/photos/PhotoEdit.tsx";
|
|
||||||
import { MyLayout } from "./components/MyLayout.tsx";
|
|
||||||
import { UserShow } from "./components/users/UserShow.tsx";
|
import { UserShow } from "./components/users/UserShow.tsx";
|
||||||
import { CommentShow } from "./components/comments/CommentShow.tsx";
|
|
||||||
import { PostShow } from "./components/posts/PostShow.tsx";
|
|
||||||
import { PostList } from "./components/posts/PostList.tsx";
|
import { PostList } from "./components/posts/PostList.tsx";
|
||||||
|
import { PostEdit } from "./components/posts/PostEdit.tsx";
|
||||||
|
import { PostShow } from "./components/posts/PostShow.tsx";
|
||||||
|
import { PostCreate } from "./components/posts/PostCreate.tsx";
|
||||||
import { CommentList } from "./components/comments/CommentList.tsx";
|
import { CommentList } from "./components/comments/CommentList.tsx";
|
||||||
|
import { CommentEdit } from "./components/comments/CommentEdit.tsx";
|
||||||
|
import { CommentShow } from "./components/comments/CommentShow.tsx";
|
||||||
|
import { MyLayout } from "./components/MyLayout.tsx";
|
||||||
import { AlbumList } from "./components/albums/AlbumList.tsx";
|
import { AlbumList } from "./components/albums/AlbumList.tsx";
|
||||||
import { PhotoList } from "./components/photos/PhotoList.tsx";
|
import { AlbumEdit } from "./components/albums/AlbumEdit.tsx";
|
||||||
import { PhotoShow } from "./components/photos/PhotoShow.tsx";
|
|
||||||
import { AlbumShow } from "./components/albums/AlbumShow.tsx";
|
import { AlbumShow } from "./components/albums/AlbumShow.tsx";
|
||||||
|
import { PhotoList } from "./components/photos/PhotoList.tsx";
|
||||||
|
import { PhotoEdit } from "./components/photos/PhotoEdit.tsx";
|
||||||
|
import { PhotoShow } from "./components/photos/PhotoShow.tsx";
|
||||||
import { TodoList } from "./components/todos/TodoList.tsx";
|
import { TodoList } from "./components/todos/TodoList.tsx";
|
||||||
import { TodoEdit } from "./components/todos/TodoEdit.tsx";
|
import { TodoEdit } from "./components/todos/TodoEdit.tsx";
|
||||||
import { TodoShow } from "./components/todos/TodoShow.tsx";
|
import { TodoShow } from "./components/todos/TodoShow.tsx";
|
||||||
@@ -30,7 +31,13 @@ export const App = () => (
|
|||||||
requireAuth
|
requireAuth
|
||||||
>
|
>
|
||||||
<Resource name="users" list={UserList} edit={UserEdit} show={UserShow} />
|
<Resource name="users" list={UserList} edit={UserEdit} show={UserShow} />
|
||||||
<Resource name="posts" list={PostList} edit={PostEdit} show={PostShow} />
|
<Resource
|
||||||
|
name="posts"
|
||||||
|
list={PostList}
|
||||||
|
edit={PostEdit}
|
||||||
|
show={PostShow}
|
||||||
|
create={PostCreate}
|
||||||
|
/>
|
||||||
<Resource
|
<Resource
|
||||||
name="comments"
|
name="comments"
|
||||||
list={CommentList}
|
list={CommentList}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Datagrid, EmailField, List, ReferenceField, TextField } from 'react-admin';
|
import { Datagrid, EmailField, List, ReferenceField, TextField, EditButton} from 'react-admin';
|
||||||
|
|
||||||
export const CommentList = () => (
|
export const CommentList = () => (
|
||||||
<List>
|
<List>
|
||||||
@@ -8,6 +8,7 @@ export const CommentList = () => (
|
|||||||
<TextField source="name" />
|
<TextField source="name" />
|
||||||
<EmailField source="email" />
|
<EmailField source="email" />
|
||||||
<TextField source="body" />
|
<TextField source="body" />
|
||||||
|
<EditButton />
|
||||||
</Datagrid>
|
</Datagrid>
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
13
src/components/posts/PostCreate.tsx
Normal file
13
src/components/posts/PostCreate.tsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import {Create, ReferenceInput, SimpleForm, TextInput, } from "react-admin";
|
||||||
|
|
||||||
|
export const PostCreate = () => {
|
||||||
|
return (
|
||||||
|
<Create>
|
||||||
|
<SimpleForm>
|
||||||
|
<ReferenceInput source="userId" reference="users" />
|
||||||
|
<TextInput source="title" />
|
||||||
|
<TextInput source="body" multiline rows={5} />
|
||||||
|
</SimpleForm>
|
||||||
|
</Create>
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user