|
@@ -2,7 +2,8 @@ import { HeartFilled, HeartOutlined } from "@ant-design/icons"
|
|
|
import { Button, Col, Row, Tooltip } from "antd"
|
|
|
import { useState } from "react"
|
|
|
import { connect } from "react-redux"
|
|
|
-import { actionDelLikePost, actionLikePost } from "../../../actions"
|
|
|
+import { actionDelLikePost, actionHandlerUpsertCollection, actionLikePost, } from "../../../actions"
|
|
|
+import { CollectionEmptySvg, CollectionSvgFill } from "../../../helpers"
|
|
|
import { CModalPostLiked } from "../profilePage/ModalFollow"
|
|
|
|
|
|
|
|
@@ -18,16 +19,17 @@ const HeartLike = ({ styleFontSize, likeStatus, changeLike }) =>
|
|
|
}
|
|
|
/>
|
|
|
|
|
|
-const PostUserPanel = ({ myID, postId = '', likes = [], styleFontSize, addLikePost, removeLikePost }) => {
|
|
|
+const PostUserPanel = ({ myID, postId = '', likes = [], collections, styleFontSize, addLikePost, removeLikePost, handlerCollection }) => {
|
|
|
const [open, setOpen] = useState(false)
|
|
|
- let likeStatus =false
|
|
|
+ let likeStatus = false
|
|
|
let likeId
|
|
|
likes.find(l => {
|
|
|
if (l?.owner?._id === myID) {
|
|
|
likeStatus = true
|
|
|
likeId = l._id
|
|
|
- }
|
|
|
+ }
|
|
|
})
|
|
|
+ const flag = collections?.posts.find(c => c._id === postId)
|
|
|
|
|
|
const changeLike = () => likeStatus ? removeLikePost(likeId, postId) : addLikePost(postId)
|
|
|
|
|
@@ -35,24 +37,37 @@ const PostUserPanel = ({ myID, postId = '', likes = [], styleFontSize, addLikePo
|
|
|
return (
|
|
|
<>
|
|
|
{open && <CModalPostLiked statusModal={setOpen} title={'Liked'} id={postId} />}
|
|
|
- <Row className="Post__panel-btn" align="middle">
|
|
|
- <Col className='Post__heart'>
|
|
|
- <HeartLike
|
|
|
- changeLike={changeLike}
|
|
|
- likeStatus={likeStatus}
|
|
|
- styleFontSize={styleFontSize} />
|
|
|
+ <Row className="Post__panel-btn" justify="space-between" align="middle">
|
|
|
+ <Col flex={'50%'}>
|
|
|
+ <Row align="middle" wrap={false}>
|
|
|
+ <Col className='Post__heart' >
|
|
|
+ <HeartLike
|
|
|
+ changeLike={changeLike}
|
|
|
+ likeStatus={likeStatus}
|
|
|
+ styleFontSize={styleFontSize} />
|
|
|
+ </Col>
|
|
|
+ <Col offset={1}>
|
|
|
+ {!!likes.length && <button onClick={() => { setOpen(true) }}>Likes:<strong>{` ${likes.length}`}</strong></button>}
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
</Col>
|
|
|
- <Col offset={0.5}>
|
|
|
- {!!likes.length && <button onClick={() => { setOpen(true) }}>Likes:<strong>{` ${likes.length}`}</strong></button>}
|
|
|
+ <Col flex={'10%'} className='Post__collection'>
|
|
|
+ <Button type="none"
|
|
|
+ shape="circle" onClick={() => handlerCollection(postId, flag)}>
|
|
|
+ {flag ? <CollectionSvgFill /> : <CollectionEmptySvg />}
|
|
|
+ </Button>
|
|
|
</Col>
|
|
|
</Row>
|
|
|
+
|
|
|
</>
|
|
|
)
|
|
|
}
|
|
|
|
|
|
export const CPostUserPanel = connect(state => ({
|
|
|
- myID: state.auth.payload.sub.id || ''
|
|
|
+ myID: state.auth.payload.sub.id || '',
|
|
|
+ collections: state.myData?.collections
|
|
|
}), {
|
|
|
addLikePost: actionLikePost,
|
|
|
removeLikePost: actionDelLikePost,
|
|
|
+ handlerCollection: actionHandlerUpsertCollection,
|
|
|
})(PostUserPanel)
|