do feed
This commit is contained in:
parent
2586dc87c8
commit
e84cf232a5
13 changed files with 605 additions and 139 deletions
23
src/pages/AuthorPage.tsx
Normal file
23
src/pages/AuthorPage.tsx
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { PostsFeed } from '../components/PostsFeed.tsx'
|
||||
import { useCallback } from 'react'
|
||||
import { useParams } from 'react-router'
|
||||
import { loadPostsForAuthor } from '../api/api.ts'
|
||||
import { useAsyncState } from '../hooks/useAsyncData.ts'
|
||||
import { Post } from '../model/posts/posts.ts'
|
||||
|
||||
export function AuthorPage() {
|
||||
const { username } = useParams()
|
||||
|
||||
const fetchPosts = useCallback(async () => {
|
||||
const result = await loadPostsForAuthor(username!)
|
||||
return result.posts.map((post) => Post.fromDto(post))
|
||||
}, [username])
|
||||
|
||||
const posts = useAsyncState(fetchPosts)
|
||||
|
||||
return (
|
||||
<main className={`w-full max-w-full`}>
|
||||
<PostsFeed posts={posts ?? []} />
|
||||
</main>
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue