import { Card, Col, Row, Carousel, Empty } from 'antd' import Meta from 'antd/lib/card/Meta' import React, { createRef, useEffect } from 'react' import { connect } from 'react-redux' import { Link } from 'react-router-dom' import { myFolowingPosts } from '../../actions' import { backURL } from '../../helpers' import { UserAvatar } from '../header/Header' import nodata from '../../images/nodata.png' import { LeftCircleOutlined, RightCircleOutlined } from '@ant-design/icons' const PostTitle = ({ owner }) => {owner?.nick ? owner.nick : owner?.login ? owner.login : 'Null'} class PostImage extends React.Component { constructor(props) { super(props); this.carouselRef = createRef(); this.state = { movePrev: false, moveNext: false } } handleNext = () => this.carouselRef.current.next(this); handlePrev = () => this.carouselRef.current.prev(this); moveOnDivArray = (length, index) => { if (length === 1) { this.setState({ movePrev: false, moveNext: false }) } else if (index === 0) { this.setState({ movePrev: false, moveNext: true }) } else if (index === length - 1 && length > 1) { this.setState({ movePrev: true, moveNext: false }) } else { this.setState({ movePrev: true, moveNext: true }) } } downOnDivArray = () => this.setState({ movePrev: false, moveNext: false }) render() { const { images } = this.props return ( {!!images ? images.map((i, index) => i?.url ?
this.moveOnDivArray(images.length, index)} onMouseLeave={this.downOnDivArray}>
: ) : }
); } } const Post = ({ postData: { text, title, owner, images, createdAt, comments } }) => { const date = new Date(createdAt * 1) const resultDate = new Intl.DateTimeFormat('default').format(date) return (
} cover={} >
) } const MainPostFeed = ({ posts, postsFollowing }) => { useEffect(() => { postsFollowing() }, []) return ( <> {posts.map(p => )} ) } export const CMainPostFeed = connect(state => ({ posts: state.promise?.followingPosts?.payload || [] }), { postsFollowing: myFolowingPosts })(MainPostFeed)