-
-
Notifications
You must be signed in to change notification settings - Fork 648
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1e7f2c
commit c9243d6
Showing
4 changed files
with
59 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from "react" | ||
import { VStack } from "@fider/components/layout" | ||
import { actions } from "@fider/services" | ||
import { Post } from "@fider/models" | ||
|
||
export const MostWanted = () => { | ||
const [posts, setPosts] = React.useState<Post[]>([]) | ||
|
||
React.useEffect(() => { | ||
const fetchPosts = async () => { | ||
const result = await actions.searchPosts({ view: "most-wanted", limit: 5 }) | ||
setPosts(result.data) | ||
} | ||
fetchPosts() | ||
}, []) | ||
|
||
return ( | ||
<VStack spacing={4}> | ||
<h1 className="text-title">Most Wanted</h1> | ||
{posts.length > 0 && | ||
posts.map((post) => ( | ||
<div key={post.id} className="pt-1"> | ||
<span className="text-medium">{post.title}</span> | ||
<div className="pt-1 flex"> | ||
<span className="text-muted" style={{ width: "150px" }}>{post.commentsCount} comments</span> | ||
<span className="text-muted">{post.votesCount} votes</span> | ||
</div> | ||
</div> | ||
))} | ||
</VStack> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters