import { Button, Col, List, Row } from 'antd' import Modal from 'antd/lib/modal/Modal' import React, { useEffect, useState } from 'react' import { connect } from 'react-redux' import { Link } from 'react-router-dom' import { actionRemovePostsAC } from '../../actions' import { backURL } from '../../helpers' import { actionFullProfilePageData, actionFullSubscribe, actionFullUnSubscribe, actionProfilePageData } from '../../redux/redux-thunk' import { UserAvatar } from '../header/Header' const ModalFolower = ({ statusModal, data, title }) => { const handleCancel = () => statusModal(false); return ( <> ( {item.nick || item.login || 'No Name'} )} /> ) } const CModalFollowers = connect(state => ({ data: state?.profileData?.userData?.followers || [] }))(ModalFolower) const CModalFollowing = connect(state => ({ data: state?.profileData?.userData?.following || [] }))(ModalFolower) const ProfileSetting = ({ myID, userId, followers, onSubsuscribe, onUnSubsuscribe }) => { const followCheck = followers.find(f => f._id === myID && true) return ( {!!followCheck ? : } ) } const CProfileSetting = connect(state => ({ myID: state?.auth?.payload?.sub.id, followers: state?.profileData?.userData?.followers || [] }), { onSubsuscribe: actionFullSubscribe, onUnSubsuscribe: actionFullUnSubscribe })(ProfileSetting) const ProfilePageData = ({ data: { _id, avatar, login, nick, followers, following }, posts, setFollowing, setFollowers }) => { return (

{nick || login || 'No Name'}

{login || '----'} < CProfileSetting userId={_id} />
{posts?.length || '0'} Posts
) } const CProfilePageData = connect(state => ({ data: state?.profileData?.userData || {}, posts: state?.profileData?.userPosts || [] }))(ProfilePageData) const ProfilePagePosts = ({ posts }) => { return ( {posts.map(p => {console.log(p)} {p.images && p.images[0] && p.images[0].url && post Img} ) } ) } export const CProfilePagePosts = connect(state => ({ posts: state.profileData?.userPosts || [] }))(ProfilePagePosts) const ProfilePage = ({ match: { params: { _id } }, getProfileUser }) => { const [followers, setFollowers] = useState(false) const [following, setFollowing] = useState(false) useEffect(() => { getProfileUser(_id) return () => { // actionRemovePrfilePageAC } }, [_id]) return ( <> {followers && < CModalFollowers statusModal={setFollowers} title={'Followers'} />} {following && < CModalFollowing statusModal={setFollowing} title={'Following'} />} ) } export const CProfilePage = connect(null, { getProfileUser: actionFullProfilePageData, })(ProfilePage)