WIP: Basic Jodel Application
This commit is contained in:
34
src/components/Post.js
Normal file
34
src/components/Post.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import React, { useState } from 'react';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faCaretUp, faCaretDown } from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
function Post({ post }) {
|
||||
const [upvotes, setUpvotes] = useState(post.upvotes);
|
||||
const [downvotes, setDownvotes] = useState(post.downvotes);
|
||||
|
||||
const handleUpvote = () => {
|
||||
// Logic to handle upvote
|
||||
setUpvotes(upvotes + 1);
|
||||
};
|
||||
|
||||
const handleDownvote = () => {
|
||||
// Logic to handle downvote
|
||||
setDownvotes(downvotes + 1);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="post">
|
||||
<p>{post.content}</p>
|
||||
<div className="vote">
|
||||
<FontAwesomeIcon icon={faCaretUp} onClick={handleUpvote} />
|
||||
{upvotes}
|
||||
</div>
|
||||
<div className="vote">
|
||||
<FontAwesomeIcon icon={faCaretDown} onClick={handleDownvote} />
|
||||
{downvotes}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Post;
|
||||
Reference in New Issue
Block a user