|
@@ -1,14 +1,11 @@
|
|
|
import {connect} from "react-redux";
|
|
|
import styled from 'styled-components';
|
|
|
-import {useEffect, useState} from "react";
|
|
|
+import {useEffect} from "react";
|
|
|
import {setActiveUserAllPostsAsync, setUserDataAsync} from "../store/actionCreators/ActionCreators";
|
|
|
import avatar from "../assets/img/avatarGolub.jpg";
|
|
|
-import picture from "../assets/img/brokenPicture.png";
|
|
|
-import ModalWindow from "./ModalWindow";
|
|
|
-import AutoAwesomeMotionIcon from '@mui/icons-material/AutoAwesomeMotion';
|
|
|
-import Carousel from 'react-material-ui-carousel'
|
|
|
-import CommentsBlock from "./CommentsBlock"
|
|
|
-import AvaLoginBlock from "./AvaLoginBlock";
|
|
|
+import Post from "./Post";
|
|
|
+import UserInfoBlock from "./UserInfoBlock";
|
|
|
+
|
|
|
|
|
|
const UserContentWrapper = styled.div`
|
|
|
margin-top: 30px;
|
|
@@ -42,13 +39,6 @@ const UserInfoBlockWrapper = styled.div`
|
|
|
display: flex;
|
|
|
justify-content: flex-start;
|
|
|
`
|
|
|
-const UserInfoBlockStyled = styled.div`
|
|
|
- display: flex;
|
|
|
- justify-content: center;
|
|
|
- align-items: center;
|
|
|
- margin: 0 40px;
|
|
|
- flex-direction: column;
|
|
|
-`
|
|
|
const AvatarWrapper = styled.div`
|
|
|
width: 100px;
|
|
|
height: 100px;
|
|
@@ -58,132 +48,23 @@ const AvatarWrapper = styled.div`
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
`
|
|
|
-const PostWrapper = styled.div`
|
|
|
- position: relative;
|
|
|
- display: flex;
|
|
|
- min-width: 300px;
|
|
|
- max-width: 300px;
|
|
|
- margin: 15px;
|
|
|
- box-shadow: rgba(0, 0, 0, 0.25) 0px 0.0625em 0.0625em, rgba(0, 0, 0, 0.25) 0px 0.125em 0.5em, rgba(255, 255, 255, 0.1) 0px 0px 0px 1px inset;
|
|
|
-`
|
|
|
-const LogoManyImg = styled.div`
|
|
|
- position: absolute;
|
|
|
- z-index: 2;
|
|
|
- right: 0;
|
|
|
- width: 25px;
|
|
|
- height: 35px;
|
|
|
- transform: scaleX(-1);
|
|
|
-`
|
|
|
-const PicsInModalWrapper = styled.div`
|
|
|
- width: 50%;
|
|
|
- max-height: 100%;
|
|
|
- margin: 30px;
|
|
|
- overflow: hidden;
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
- box-shadow: rgba(0, 0, 0, 0.25) 0px 0.0625em 0.0625em, rgba(0, 0, 0, 0.25) 0px 0.125em 0.5em, rgba(255, 255, 255, 0.1) 0px 0px 0px 1px inset;
|
|
|
-`
|
|
|
-const AvaLoginWrap = styled.div`
|
|
|
- display: flex;
|
|
|
- margin-top: 30px;
|
|
|
- width: 80%;
|
|
|
|
|
|
-`
|
|
|
-const DescriptionPostWrapper = styled.div`
|
|
|
- height: fit-content;
|
|
|
- width: 100%;
|
|
|
- box-shadow: rgba(17, 17, 26, 0.1) 0px 1px 0px;
|
|
|
-`
|
|
|
-const InfoBlockInModalWrapper = styled.div`
|
|
|
- width: 50%;
|
|
|
-`
|
|
|
-const Title = styled.p``
|
|
|
-const Text = styled.p``
|
|
|
const tempUser = "62c1cc5e4535fc62e2a185ad"; // test - should be deleted
|
|
|
|
|
|
|
|
|
function UserContent(props) {
|
|
|
|
|
|
- const [likes, setLikes] = useState(null);
|
|
|
-
|
|
|
useEffect(() => {
|
|
|
if (!props.activeUser) {
|
|
|
props.setUserDataAsync(props.id)
|
|
|
}
|
|
|
if (props.activeUser && !props.activeUserPosts.length) {
|
|
|
|
|
|
- // props.setActiveUserAllPostsAsync(tempUser);
|
|
|
- props.setActiveUserAllPostsAsync(props.activeUser._id)
|
|
|
+ props.setActiveUserAllPostsAsync(tempUser);
|
|
|
+ // props.setActiveUserAllPostsAsync(props.activeUser._id)
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
- const UserInfoBlock = ({count, description}) => {
|
|
|
- return (<UserInfoBlockStyled>
|
|
|
- <p>{count ? count : 0}</p>
|
|
|
- <p>{description}</p>
|
|
|
- </UserInfoBlockStyled>)
|
|
|
- }
|
|
|
- const Post = ({post}) => {
|
|
|
- const [isModal, setModal] = useState(false)
|
|
|
- console.log(post)
|
|
|
- function toggleModalWindow() {
|
|
|
- setModal(!isModal)
|
|
|
- }
|
|
|
-
|
|
|
- const ImgBlock = ({images}) => {
|
|
|
- return (
|
|
|
- <>
|
|
|
- {!images && <img src={picture} alt={"pic"}/>}
|
|
|
- {images && images.length === 1 && <img src={images[0].url} alt={"pic"} style={{width: "100%"}}/>}
|
|
|
- {images && images.length > 1 && <div style={{width: "100%"}}>
|
|
|
- <Carousel autoPlay={false} navButtonsAlwaysVisible={true}>{
|
|
|
- images.map((item, i) => <img src={item.url} key={i} style={{width: "100%"}}
|
|
|
- alt={"picture"}/>)
|
|
|
- }
|
|
|
- </Carousel>
|
|
|
- </div>}
|
|
|
- </>
|
|
|
- // (images?.length && images.length > 1) && console.log("many pics") || (images && images.length === 1) &&
|
|
|
- // <img src={images[0].url} alt={"pic"} style={{width:"100%"}}/> || <img src={picture} alt={"pic"}/>
|
|
|
- // <img src={images[0].url} alt={"pic"}/>
|
|
|
- )
|
|
|
- };
|
|
|
-
|
|
|
- console.log(post)
|
|
|
- return (
|
|
|
- <PostWrapper onClick={() => toggleModalWindow()}>
|
|
|
- <img src={post.images ? post.images[0].url : picture} alt="post" style={{width: "100%"}}/>
|
|
|
- {
|
|
|
- post.images?.length > 1 && <LogoManyImg>
|
|
|
- <AutoAwesomeMotionIcon/>
|
|
|
- </LogoManyImg>
|
|
|
- }
|
|
|
- {isModal &&
|
|
|
- <ModalWindow closeModal={toggleModalWindow}>
|
|
|
- <PicsInModalWrapper>
|
|
|
- <ImgBlock images={post.images}/>
|
|
|
- </PicsInModalWrapper>
|
|
|
- <InfoBlockInModalWrapper>
|
|
|
-
|
|
|
- <AvaLoginWrap>
|
|
|
- <AvaLoginBlock urlAva={props.activeUser.avatar.url} name={props.activeUser.login}/>
|
|
|
-
|
|
|
- </AvaLoginWrap>
|
|
|
- <DescriptionPostWrapper>
|
|
|
- <Title>Title:{post.title}</Title>
|
|
|
- <Text>{post.text}</Text>
|
|
|
- </DescriptionPostWrapper>
|
|
|
-
|
|
|
- <CommentsBlock id={post._id} setLikes={setLikes} isLikesRendered={likes !== null}/>
|
|
|
- {/*<LikeBlock/>*/}
|
|
|
-
|
|
|
- </InfoBlockInModalWrapper>
|
|
|
- </ModalWindow>
|
|
|
- }
|
|
|
- </PostWrapper>
|
|
|
- )
|
|
|
- }
|
|
|
+ console.log(props.activeUserPosts)
|
|
|
return (
|
|
|
<>
|
|
|
{props.activeUser && <UserContentWrapper>
|
|
@@ -205,7 +86,7 @@ function UserContent(props) {
|
|
|
|
|
|
{props.activeUserPosts &&
|
|
|
<PostsContainer>
|
|
|
- {props.activeUserPosts.map((post, index) => <Post post={post} key={index}/>)}
|
|
|
+ {props.activeUserPosts.map((post, index) => <Post activeUser={props.activeUser} postId={post._id} key={index}/>)}
|
|
|
</PostsContainer>}
|
|
|
</UserContentWrapper>
|
|
|
}
|
|
@@ -213,7 +94,6 @@ function UserContent(props) {
|
|
|
)
|
|
|
}
|
|
|
|
|
|
-;
|
|
|
|
|
|
const mapStateToProps = (state) => {
|
|
|
return {
|