import React from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCaretUp, faCaretDown, faCommentAlt, faComments, faAngleUp, faAngleDown } from '@fortawesome/free-solid-svg-icons'; import {faMessage} from "@fortawesome/free-solid-svg-icons/faMessage"; import {postApi} from "../api/posts.api"; const Post = ({ post, recursionDepth, selectPost, reload }) => { const [showComments, setShowComments] = React.useState(false); const upvote = () => { if (post.reaction === true) { revokeVote(); return; } postApi.reactToPost(post.id, true).then(reload); } const downVote = () => { if (post.reaction === false) { revokeVote(); return; } postApi.reactToPost(post.id, false).then(reload); } const revokeVote = () => { postApi.reactToPost(post.id, null).then(reload); } return (
setShowComments(!showComments)}>
{post.id === post.parent &&

{post.title}

}

{post.content}

{post.comments.length}
{post.date.slice(8, 10) + "." + post.date.slice(5, 7) + "." + post.date.slice(0, 4)}
{post.reactions.positive - post.reactions.negative}
{recursionDepth !== 0 && }
{recursionDepth !== 0 && showComments && post.comments.map(post => )}
) ; }; export default Post;