import { Router, Route, Link, Redirect, Switch } from 'react-router-dom'
import {
actionAllPosts, actionOnePost, actionFindLikes, actionAddFullComment, actionGetFindLiked, actionFindSubComment,
actionAddSubFullComment, actionDeleteFullLike, actionAddFullLike, actionAddLike, actionDeleteLike
} from '../actions'
import photoNotFound from '../materials/photoNotFound.png'
import { LeftCircleFilled, RightCircleFilled, HeartOutlined,HeartTwoTone,HeartFilled } from '@ant-design/icons'
import { Carousel,Avatar,Tooltip } from 'antd'
import user from '../materials/user1.png'
import { Provider, connect } from 'react-redux'
import { Row, Col } from 'antd';
import { Divider, Input, Button, Modal } from 'antd';
import { EditOutlined } from '@ant-design/icons'
import moment from 'moment';
import {CComments, AddComment} from '../components/Post_Comment'
import { ConstructorModal} from '../helpers'
import React, { useMemo, useState, useEffect } from 'react'
// const postId="625afa1d069dca48a822ffb0"
export const Card = ({ post, onPost }) => (
<>
{/* onPost(postId)}> */}
{/* {console.log('post id', post?._id)}
onClick={() => onPost(post?._id)}
*/}
{post?.images && post?.images[0] && post.images[0]?.url ? (
) : (
)}
{/* {console.log(post?._id)} */}
>
)
const SampleNextArrow = (props) => {
const { className, style, onClick } = props
return (
)
}
const SamplePrevArrow = (props) => {
const { className, style, onClick } = props
return (
)
}
export const MyCarousel = ({ images = [] }) => {
// console.log('IMAGES', images)
return (
<>
}
prevArrow={
}
>
{
images
?
(images.map((i, index) =>
i?.url && (
)
))
: (
)
}
>
)
}
const Likes = ({ likes }) =>
{
return (
<>
{
likes &&
likes?.map(({ owner:{_id, login, avatar} }) => (
//
>
)
}
const Like = ({ my_Id, postId, addLike, deleteLike, likes=[], children }) =>
{
const likeId = likes.find(like => like?.owner?._id === my_Id)?._id
const changeLike = () => likeId ? deleteLike(likeId, postId) : addLike(postId)
// console.log('likeId', likeId)
const [isModalVisible, setIsModalVisible] = useState(false);
const showModal = () => {
setIsModalVisible(true);
};
return(
<>
{likeId ?
:
}
{likes.length ?
{likes.length} likes
:
'0 likes'}
>
)
}
export const PagePost = ({ my_Id, onePost, likes, addComment,
addCommentReply, addLike, findSubComment, deleteLike,
match: { params: { _id } },
aboutUser: { avatar, login } = {}, onPost }) => {
useEffect(() => {
onPost(_id)
console.log('ONE POST _ID',onePost?._id)
}, [_id])
return (
<>
{/* */}
Created Post: {new Intl.DateTimeFormat('en-GB').format(onePost?.createdAt)}
{/*
*/}
{/* */}
{avatar ? (
) : (
)
}
{login}
Title: {onePost?.title || ''}
Text: {onePost?.text || ''}
Comments
{/*
*/}
>
)
}
export const CPost = connect((state) => ({
onePost: state.promise.onePost?.payload,
my_Id: state.auth.payload.sub.id || '',
aboutUser: state.profilePage?.aboutUser,
addComment: state.promise?.addComment?.payload,
addSubComment: state.promise?.addSubComment,
}), {
addLike: actionAddFullLike,
findLikes: actionGetFindLiked,
deleteLike: actionDeleteFullLike,
addComment: actionAddFullComment,
addCommentReply: actionAddSubFullComment,
findLikes: actionFindLikes,
onPost:actionOnePost
})(PagePost)