import { Avatar, Col, Row } from 'antd' import { ConstructorModal } from '../helpers' import { Link } from 'react-router-dom' import user from '../materials/user.png' import { HeartOutlined, HeartFilled } from '@ant-design/icons' import React, { useState } from 'react' import { LinkToUser } from './LinkToUser' import { actionChangeLike } from '../redux/saga' import { connect } from 'react-redux' export const Likes = ({ likes }) => { return ( <>
{likes && likes?.map(({owner:{_id,login, avatar}}) => ( ))}
) } export const Like = ({ my_Id, postId, addLike, deleteLike, likes = [], changeLike, children, }) => { const likeId = likes.find((like) => like?.owner?._id === my_Id)?._id // const changeLike = () => // likeId ? deleteLike(likeId, postId) : addLike(postId) console.log('like id in component', likeId) const [isModalVisible, setIsModalVisible] = useState(false) const showModal = () => { setIsModalVisible(true) } return ( <>

changeLike(likeId, postId)}> {likeId ? ( ) : ( )}

{likes.length ? (

{' '} {likes.length} likes

) : (

0 likes

)}
) } const AllLikeComponent = ({ my_Id, likes,changeLike, postId }) => ( ) export const CLike = connect( (state) => ({ my_Id: state.auth?.payload?.sub?.id || '', }), { changeLike: actionChangeLike }, )(AllLikeComponent)