PostShow completed #3

This commit is contained in:
2025-01-28 09:28:56 +01:00
parent 261d957dbd
commit 4d43c53035
5 changed files with 78 additions and 4 deletions

View File

@@ -14,6 +14,10 @@ import {CommentEdit} from "./Components/CommentEdit.tsx";
import {AlbumEdit} from "./Components/AlbumEdit.tsx"; import {AlbumEdit} from "./Components/AlbumEdit.tsx";
import {PhotoEdit} from "./Components/PhotoEdit.tsx"; import {PhotoEdit} from "./Components/PhotoEdit.tsx";
import {MyLayout} from "./Components/MyLayout.tsx"; import {MyLayout} from "./Components/MyLayout.tsx";
import {UserShow} from "./Components/UserShow.tsx";
import {CommentShow} from "./Components/CommentShow.tsx";
import {PostShow} from "./Components/PostShow.tsx";
import {PostList} from "./Components/PostList.tsx";
export const App = () => ( export const App = () => (
<Admin layout={MyLayout} dataProvider={dataProvider}> <Admin layout={MyLayout} dataProvider={dataProvider}>
@@ -21,19 +25,19 @@ export const App = () => (
name="users" name="users"
list={UserList} list={UserList}
edit={UserEdit} edit={UserEdit}
show={ShowGuesser} show={UserShow}
/> />
<Resource <Resource
name="posts" name="posts"
list={ListGuesser} list={PostList}
edit={PostEdit} edit={PostEdit}
show={ShowGuesser} show={PostShow}
/> />
<Resource <Resource
name="comments" name="comments"
list={ListGuesser} list={ListGuesser}
edit={CommentEdit} edit={CommentEdit}
show={ShowGuesser} show={CommentShow}
/> />
<Resource <Resource
name="albums" name="albums"

View File

@@ -0,0 +1,13 @@
import { EmailField, ReferenceField, Show, SimpleShowLayout, TextField,} from 'react-admin';
export const CommentShow = () => (
<Show>
<SimpleShowLayout>
<ReferenceField source="postId" reference="posts" />
<TextField source="id" />
<TextField source="name" />
<EmailField source="email" />
<TextField source="body" />
</SimpleShowLayout>
</Show>
);

View File

@@ -0,0 +1,12 @@
import { Datagrid, List, ReferenceField, TextField,} from 'react-admin';
export const PostList = () => (
<List>
<Datagrid>
<ReferenceField source="userId" reference="users" />
<TextField source="id" />
<TextField source="title" />
<TextField source="body" />
</Datagrid>
</List>
);

View File

@@ -0,0 +1,29 @@
import {
ReferenceManyField,
Show,
TextField,
Datagrid,
EmailField,
SimpleShowLayout,
ReferenceField,
} from "react-admin";
export const PostShow = () => (
<Show>
<SimpleShowLayout>
<ReferenceField source="userId" reference="users" />
<TextField source="id" />
<TextField source="title" />
<TextField source="body" />
<ReferenceManyField target="postId" reference="comments">
<Datagrid>
<TextField source="postId" />
<TextField source="name" />
<TextField source="id" />
<EmailField source="email" />
<TextField source="body" />
</Datagrid>
</ReferenceManyField>
</SimpleShowLayout>
</Show>
);

View File

@@ -0,0 +1,16 @@
import { EmailField, Show, SimpleShowLayout, TextField } from 'react-admin';
export const UserShow = () => (
<Show>
<SimpleShowLayout>
<TextField source="id" />
<TextField source="name" />
<TextField source="username" />
<EmailField source="email" />
<TextField source="address.street" />
<TextField source="phone" />
<TextField source="website" />
<TextField source="company.name" />
</SimpleShowLayout>
</Show>
);