wip add button and feed stuff
This commit is contained in:
parent
38d09a582c
commit
1c2d6d60a6
11 changed files with 211 additions and 46 deletions
|
@ -1,25 +1,20 @@
|
|||
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'
|
||||
import './FeedView.css'
|
||||
import FeedView from './FeedView.tsx'
|
||||
|
||||
export function AuthorPage() {
|
||||
export default 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 md:flex md:justify-center`}>
|
||||
<div className="w-full md:w-lg md:max-w-lg md:ml-8">
|
||||
<PostsFeed posts={posts ?? []} />
|
||||
</div>
|
||||
</main>
|
||||
const fetchPosts = useCallback(
|
||||
async (cursor: string | null, amount: number | null) => {
|
||||
const result = await loadPostsForAuthor(username!, cursor, amount)
|
||||
return result.posts.map((post) => Post.fromDto(post))
|
||||
},
|
||||
[username],
|
||||
)
|
||||
|
||||
return <FeedView loadPosts={fetchPosts} />
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue