Update PostItem.js
This commit is contained in:
@@ -1,8 +1,4 @@
|
|||||||
<<<<<<< HEAD
|
|
||||||
import React from 'react';
|
|
||||||
=======
|
|
||||||
import React, { Fragment } from 'react';
|
import React, { Fragment } from 'react';
|
||||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import formatDate from '../../utils/formatDate';
|
import formatDate from '../../utils/formatDate';
|
||||||
@@ -14,12 +10,7 @@ const PostItem = ({
|
|||||||
removeLike,
|
removeLike,
|
||||||
deletePost,
|
deletePost,
|
||||||
auth,
|
auth,
|
||||||
<<<<<<< HEAD
|
|
||||||
post: { _id, text, name, avatar, user, likes, comments, date }
|
post: { _id, text, name, avatar, user, likes, comments, date }
|
||||||
=======
|
|
||||||
post: { _id, text, name, avatar, user, likes, comments, date },
|
|
||||||
showActions
|
|
||||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
|
||||||
}) => (
|
}) => (
|
||||||
<div className="post bg-white p-1 my-1">
|
<div className="post bg-white p-1 my-1">
|
||||||
<div>
|
<div>
|
||||||
@@ -31,8 +22,6 @@ const PostItem = ({
|
|||||||
<div>
|
<div>
|
||||||
<p className="my-1">{text}</p>
|
<p className="my-1">{text}</p>
|
||||||
<p className="post-date">Posted on {formatDate(date)}</p>
|
<p className="post-date">Posted on {formatDate(date)}</p>
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<button
|
<button
|
||||||
onClick={() => addLike(_id)}
|
onClick={() => addLike(_id)}
|
||||||
type="button"
|
type="button"
|
||||||
@@ -62,64 +51,17 @@ const PostItem = ({
|
|||||||
>
|
>
|
||||||
<i className="fas fa-times" />
|
<i className="fas fa-times" />
|
||||||
</button>
|
</button>
|
||||||
=======
|
|
||||||
{showActions && (
|
|
||||||
<Fragment>
|
|
||||||
<button
|
|
||||||
onClick={() => addLike(_id)}
|
|
||||||
type="button"
|
|
||||||
className="btn btn-light"
|
|
||||||
>
|
|
||||||
<i className="fas fa-thumbs-up" />{' '}
|
|
||||||
<span>{likes.length > 0 && <span>{likes.length}</span>}</span>
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() => removeLike(_id)}
|
|
||||||
type="button"
|
|
||||||
className="btn btn-light"
|
|
||||||
>
|
|
||||||
<i className="fas fa-thumbs-down" />
|
|
||||||
</button>
|
|
||||||
<Link to={`/posts/${_id}`} className="btn btn-primary">
|
|
||||||
Discussion{' '}
|
|
||||||
{comments.length > 0 && (
|
|
||||||
<span className="comment-count">{comments.length}</span>
|
|
||||||
)}
|
|
||||||
</Link>
|
|
||||||
{!auth.loading && user === auth.user._id && (
|
|
||||||
<button
|
|
||||||
onClick={() => deletePost(_id)}
|
|
||||||
type="button"
|
|
||||||
className="btn btn-danger"
|
|
||||||
>
|
|
||||||
<i className="fas fa-times" />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</Fragment>
|
|
||||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
PostItem.defaultProps = {
|
|
||||||
showActions: true
|
|
||||||
};
|
|
||||||
|
|
||||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
|
||||||
PostItem.propTypes = {
|
PostItem.propTypes = {
|
||||||
post: PropTypes.object.isRequired,
|
post: PropTypes.object.isRequired,
|
||||||
auth: PropTypes.object.isRequired,
|
auth: PropTypes.object.isRequired,
|
||||||
addLike: PropTypes.func.isRequired,
|
addLike: PropTypes.func.isRequired,
|
||||||
removeLike: PropTypes.func.isRequired,
|
removeLike: PropTypes.func.isRequired,
|
||||||
<<<<<<< HEAD
|
|
||||||
deletePost: PropTypes.func.isRequired
|
deletePost: PropTypes.func.isRequired
|
||||||
=======
|
|
||||||
deletePost: PropTypes.func.isRequired,
|
|
||||||
showActions: PropTypes.bool
|
|
||||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = (state) => ({
|
const mapStateToProps = (state) => ({
|
||||||
@@ -128,8 +70,5 @@ const mapStateToProps = (state) => ({
|
|||||||
|
|
||||||
export default connect(mapStateToProps, { addLike, removeLike, deletePost })(
|
export default connect(mapStateToProps, { addLike, removeLike, deletePost })(
|
||||||
PostItem
|
PostItem
|
||||||
<<<<<<< HEAD
|
|
||||||
);
|
);
|
||||||
=======
|
|
||||||
);
|
|
||||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
|
||||||
|
|||||||
Reference in New Issue
Block a user