|
|
|
@ -21,97 +21,68 @@ const Comment = ({ post }) => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
{post.comments.map((comment) => {
|
|
|
|
|
return (
|
|
|
|
|
<div className={comment.commenterId === userData._id ? "comment-friend" : "comment-user"} key={comment._id}>
|
|
|
|
|
<img id="PhotoProfile" alt="ppCommentaire" src={
|
|
|
|
|
!isEmpty(usersData[0]) &&
|
|
|
|
|
usersData.map((user) => {
|
|
|
|
|
if (user._id === comment.commenterId) return user.picture;
|
|
|
|
|
else return null;
|
|
|
|
|
}).join('')
|
|
|
|
|
}/>
|
|
|
|
|
<p>{comment.commenterPseudo}</p>
|
|
|
|
|
{comment.commenterPseudo !== userData._id && (
|
|
|
|
|
<FollowHandler idToFollow={comment.commenterId} type={'suggest'}/>)}
|
|
|
|
|
<span></span>
|
|
|
|
|
{timestampParser(comment.timestamp)}
|
|
|
|
|
<p>{comment.text}</p>
|
|
|
|
|
<ActionComment commentaire={comment} postId={post._Id} />
|
|
|
|
|
return (
|
|
|
|
|
<div className="comments-container">
|
|
|
|
|
{post.comments.map((comment) => {
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
className={
|
|
|
|
|
comment.commenterId === userData._id
|
|
|
|
|
? "comment-container client"
|
|
|
|
|
: "comment-container"
|
|
|
|
|
}
|
|
|
|
|
key={comment._id}
|
|
|
|
|
>
|
|
|
|
|
<div className="left-part">
|
|
|
|
|
<img
|
|
|
|
|
src={
|
|
|
|
|
!isEmpty(usersData[0]) &&
|
|
|
|
|
usersData
|
|
|
|
|
.map((user) => {
|
|
|
|
|
if (user._id === comment.commenterId) return user.picture;
|
|
|
|
|
else return null;
|
|
|
|
|
})
|
|
|
|
|
.join("")
|
|
|
|
|
}
|
|
|
|
|
alt="commenter-pic"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="right-part">
|
|
|
|
|
<div className="comment-header">
|
|
|
|
|
<div className="pseudo">
|
|
|
|
|
<h3>{comment.commenterPseudo}</h3>
|
|
|
|
|
{comment.commenterId !== userData._id && (
|
|
|
|
|
<FollowHandler
|
|
|
|
|
idToFollow={comment.commenterId}
|
|
|
|
|
type={"suggest"}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
{userData._id && (
|
|
|
|
|
<form action="" onSubmit={handleComment} className="form-comment">
|
|
|
|
|
<input type="text" name="text" onChange={(e) => setMessage(e.target.value)} value={message} placeholder="Ajoutez un commentaire" />
|
|
|
|
|
<input type="submit" value="Partager"/>
|
|
|
|
|
</form>
|
|
|
|
|
)}
|
|
|
|
|
<span>{timestampParser(comment.timestamp)}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<p>{comment.text}</p>
|
|
|
|
|
<ActionComment commentaire={comment} postId={post._id} />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
{userData._id && (
|
|
|
|
|
<form action="" onSubmit={handleComment} className="comment-form">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
name="text"
|
|
|
|
|
onChange={(e) => setMessage(e.target.value)}
|
|
|
|
|
value={message}
|
|
|
|
|
placeholder="Laisser un commentaire"
|
|
|
|
|
/>
|
|
|
|
|
<br />
|
|
|
|
|
<input type="submit" value="Envoyer" />
|
|
|
|
|
</form>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// return (
|
|
|
|
|
// <div className="comments-container">
|
|
|
|
|
// {post.comments.map((comment) => {
|
|
|
|
|
// return (
|
|
|
|
|
// <div
|
|
|
|
|
// className={
|
|
|
|
|
// comment.commenterId === userData._id
|
|
|
|
|
// ? "comment-container client"
|
|
|
|
|
// : "comment-container"
|
|
|
|
|
// }
|
|
|
|
|
// key={comment._id}
|
|
|
|
|
// >
|
|
|
|
|
// <div className="left-part">
|
|
|
|
|
// <img
|
|
|
|
|
// src={
|
|
|
|
|
// !isEmpty(usersData[0]) &&
|
|
|
|
|
// usersData
|
|
|
|
|
// .map((user) => {
|
|
|
|
|
// if (user._id === comment.commenterId) return user.picture;
|
|
|
|
|
// else return null;
|
|
|
|
|
// })
|
|
|
|
|
// .join("")
|
|
|
|
|
// }
|
|
|
|
|
// alt="commenter-pic"
|
|
|
|
|
// />
|
|
|
|
|
// </div>
|
|
|
|
|
// <div className="right-part">
|
|
|
|
|
// <div className="comment-header">
|
|
|
|
|
// <div className="pseudo">
|
|
|
|
|
// <h3>{comment.commenterPseudo}</h3>
|
|
|
|
|
// {comment.commenterId !== userData._id && (
|
|
|
|
|
// <FollowHandler
|
|
|
|
|
// idToFollow={comment.commenterId}
|
|
|
|
|
// type={"card"}
|
|
|
|
|
// />
|
|
|
|
|
// )}
|
|
|
|
|
// </div>
|
|
|
|
|
// <span>{timestampParser(comment.timestamp)}</span>
|
|
|
|
|
// </div>
|
|
|
|
|
// <p>{comment.text}</p>
|
|
|
|
|
// <ActionComment comment={comment} postId={post._id} />
|
|
|
|
|
// </div>
|
|
|
|
|
// </div>
|
|
|
|
|
// );
|
|
|
|
|
// })}
|
|
|
|
|
// {userData._id && (
|
|
|
|
|
// <form action="" onSubmit={handleComment} className="comment-form">
|
|
|
|
|
// <input
|
|
|
|
|
// type="text"
|
|
|
|
|
// name="text"
|
|
|
|
|
// onChange={(e) => setMessage(e.target.value)}
|
|
|
|
|
// value={message}
|
|
|
|
|
// placeholder="Laisser un commentaire"
|
|
|
|
|
// />
|
|
|
|
|
// <br />
|
|
|
|
|
// <input type="submit" value="Envoyer" />
|
|
|
|
|
// </form>
|
|
|
|
|
// )}
|
|
|
|
|
// </div>
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default Comment;
|