show anonymousID in Posts and Comments
This commit is contained in:
@@ -23,7 +23,7 @@ const App = () => {
|
|||||||
if(selectedPost) {
|
if(selectedPost) {
|
||||||
selectPost(posts.find(post => post.id === selectedPost.id));
|
selectPost(posts.find(post => post.id === selectedPost.id));
|
||||||
}
|
}
|
||||||
}, [posts]);
|
}, [posts, selectedPost]);
|
||||||
|
|
||||||
|
|
||||||
const reload = async () => {
|
const reload = async () => {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import {
|
|||||||
faAngleUp,
|
faAngleUp,
|
||||||
faAngleDown
|
faAngleDown
|
||||||
} from '@fortawesome/free-solid-svg-icons';
|
} from '@fortawesome/free-solid-svg-icons';
|
||||||
import {faMessage} from "@fortawesome/free-solid-svg-icons/faMessage";
|
|
||||||
import {postApi} from "../api/posts.api";
|
import {postApi} from "../api/posts.api";
|
||||||
|
|
||||||
const Post = ({ post, recursionDepth, selectPost, reload }) => {
|
const Post = ({ post, recursionDepth, selectPost, reload }) => {
|
||||||
@@ -45,7 +44,10 @@ const Post = ({ post, recursionDepth, selectPost, reload }) => {
|
|||||||
<div className="post" onClick={click => {if (!(click.target instanceof HTMLButtonElement)) setShowComments(!showComments)}}>
|
<div className="post" onClick={click => {if (!(click.target instanceof HTMLButtonElement)) setShowComments(!showComments)}}>
|
||||||
<div className="post-container">
|
<div className="post-container">
|
||||||
{post.id === post.parent && <div className="post-title">
|
{post.id === post.parent && <div className="post-title">
|
||||||
<h3>{post.title}</h3>
|
<h3>{post.title}<span style={{color: 'gray'}}> von {post.anonymousID}</span></h3>
|
||||||
|
</div>}
|
||||||
|
{post.id !== post.parent && <div className="post-title">
|
||||||
|
<h3>Kommentar<span style={{color: 'gray'}}> von {post.anonymousID}</span></h3>
|
||||||
</div>}
|
</div>}
|
||||||
<div className="post-content">
|
<div className="post-content">
|
||||||
<p>{post.content}</p>
|
<p>{post.content}</p>
|
||||||
@@ -57,37 +59,35 @@ const Post = ({ post, recursionDepth, selectPost, reload }) => {
|
|||||||
</div>}
|
</div>}
|
||||||
<div className="post-right">
|
<div className="post-right">
|
||||||
<div className="post-date">
|
<div className="post-date">
|
||||||
{post.date.slice(8, 10) + "." + post.date.slice(5, 7) + "." + post.date.slice(0, 4)}
|
{post.date.slice(8, 10) + "." + post.date.slice(5, 7) + "." + post.date.slice(0, 4)}
|
||||||
</div>
|
|
||||||
<div className="row">
|
|
||||||
<div className="votes">
|
|
||||||
<button onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
upvote();
|
|
||||||
}}>
|
|
||||||
{post.reaction === true ? <FontAwesomeIcon icon={faCaretUp}/> : <FontAwesomeIcon icon={faAngleUp} />}
|
|
||||||
</button>
|
|
||||||
<span>{post.reactions.positive - post.reactions.negative}</span>
|
|
||||||
<button onClick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
downVote();
|
|
||||||
}}>
|
|
||||||
{post.reaction === false ? <FontAwesomeIcon icon={faCaretDown}/> : <FontAwesomeIcon icon={faAngleDown} />}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{recursionDepth !== 0 && <button onClick={() => selectPost(post)}>Antworten</button>}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div className="row">
|
||||||
<div className="comment">
|
<div className="votes">
|
||||||
{recursionDepth !== 0 && showComments && post.comments.map(post => <Post key={post.id} post={post}
|
<button onClick={(e) => {
|
||||||
recursionDepth={recursionDepth - 1}
|
e.stopPropagation();
|
||||||
selectPost={selectPost}
|
upvote();
|
||||||
reload={reload} />)}
|
}}>
|
||||||
|
{post.reaction === true ? <FontAwesomeIcon icon={faCaretUp}/> : <FontAwesomeIcon icon={faAngleUp} />}
|
||||||
|
</button>
|
||||||
|
<span>{post.reactions.positive - post.reactions.negative}</span>
|
||||||
|
<button onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
downVote();
|
||||||
|
}}>
|
||||||
|
{post.reaction === false ? <FontAwesomeIcon icon={faCaretDown}/> : <FontAwesomeIcon icon={faAngleDown} />}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{recursionDepth !== 0 && <button onClick={() => selectPost(post)}>Antworten</button>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
<div className="comment">
|
||||||
;
|
{recursionDepth !== 0 && showComments && post.comments.map(post =>
|
||||||
|
<Post key={post.id} post={post} recursionDepth={recursionDepth - 1} selectPost={selectPost} reload={reload} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Post;
|
export default Post;
|
||||||
|
|||||||
Reference in New Issue
Block a user