This commit is contained in:
john 2025-05-03 20:18:08 +02:00
parent 2586dc87c8
commit e84cf232a5
13 changed files with 605 additions and 139 deletions

23
src/pages/AuthorPage.tsx Normal file
View 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>
)
}