import React, { useEffect, useState } from 'react'
import { Row, Col, Divider } from 'antd';
import { connect } from 'react-redux'
import PostImage from '../components/main/postsFeed/PostImage'
import { PostTitle, PostDescription } from './MainPostsFeed';
import Text from 'antd/lib/typography/Text';
import { CFieldCommentSend } from '../components/main/postsFeed/FieldComment';
import { CPostUserPanel } from '../components/main/postsFeed/PostUserPanel';
import { Comment, Tooltip, Avatar } from 'antd';
import moment from 'moment';
import { UserAvatar } from './Header';
import { Link } from 'react-router-dom';
import { LikeFilled, LikeOutlined } from '@ant-design/icons';
import { actionLikeComment, actionAddLikeCommentAC, actionFindLikeComment, actionDelLikeComment } from '../actions';
const PostPageTitle = ({ data: { owner } }) =>
const CPostPageTitle = connect(state => ({ data: state?.postsFeed?.posts || {} }))(PostPageTitle)
//
const PostCommentAuthor = ({ owner }) => {
return (
{owner?.nick ? owner.nick : owner?.login ? owner.login : 'Null'}
)
}
const PostComment = ({ myID, data: { _id, answerTo, answers, createdAt, likes = [], text, owner }, addLikeComment, removeLikeComment, children }) => {
const [open, setOpen] = useState(false);
let likeStatus
let likeId
likes.find(l => {
if (l?.owner?._id === myID) {
likeStatus = true
likeId = l._id
} else {
likeStatus = false
}
})
const changeLike = () => likeStatus ? removeLikeComment(likeId, _id) : addLikeComment(_id)
const actions = [
{likeStatus ? : }
{likes.length ? likes.length : ''}
,
setOpen(true)}>Reply to,
open &&
];
return (
}
avatar={< UserAvatar avatar={owner.avatar} avatarSize={'35px'} />}
content={
{text}
}
datetime={
< Tooltip title={moment(new Date(+createdAt)).format('DD-MM-YYYY HH:mm:ss')} >
{moment(new Date(+createdAt)).startOf('seconds').fromNow()}
Tooltip>
}
>
{children}
)
}
const CPostComment = connect(state => ({
myID: state.auth.payload.sub.id || ''
}), {
addLikeComment: actionLikeComment,
removeLikeComment: actionDelLikeComment,
}
)(PostComment)
const PostComments = ({ comments }) => {
return (
<>
{
comments.map(c => )
}
>
)
}
const CPostComments = connect(state => ({
comments: state?.postsFeed?.posts?.comments || []
}))(PostComments)
const PostPageDescrption = ({ data: { _id, likes, text, title, createdAt, } }) =>
const CPostPageDescrption = connect(state => ({ data: state?.postsFeed?.posts || {} }))(PostPageDescrption)
const PostPage = ({ data: { images } }) =>
export const CPostPage = connect(state => ({ data: state?.postsFeed?.posts || {} }))(PostPage)
// xs={{ span: 24 }} sm={{ span: 20 }} md={{ span: 16 }} lg={{ span: 16 }}A