|
@@ -1,26 +1,15 @@
|
|
|
import * as React from 'react';
|
|
|
import { useEffect } from 'react';
|
|
|
import { useParams } from 'react-router-dom';
|
|
|
-// import { useParams } from 'react-router';
|
|
|
import { connect } from 'react-redux';
|
|
|
import { store } from '../redux';
|
|
|
|
|
|
-import Box from '@mui/material/Box';
|
|
|
-import Container from '@mui/material/Container';
|
|
|
-import StandardImageList from './gallery';
|
|
|
-import Divider from '@mui/material/Divider';
|
|
|
-import Grid from '@mui/material/Unstable_Grid2';
|
|
|
-import BasicCard from './user_data';
|
|
|
-import AddAPhotoRoundedIcon from '@mui/icons-material/AddAPhotoRounded';
|
|
|
-import Button from '@mui/material/Button';
|
|
|
-import { Link } from 'react-router-dom';
|
|
|
-import ImageAvatars from './avatar';
|
|
|
+import { Box, Container, Divider } from '@mui/material';
|
|
|
|
|
|
-// import { actionFindUserOne } from '../redux/action';
|
|
|
-// import { actionFindUserOne } from '../requests/userFindOne';
|
|
|
+import BasicCard from './userData';
|
|
|
import { actionFindUserOne } from '../redux/action';
|
|
|
|
|
|
-// console.log('action: ', actionFindUserOne)
|
|
|
+import StandardImageList from './gallery';
|
|
|
|
|
|
function User({ user = {}, loadUser }) {
|
|
|
|
|
@@ -28,11 +17,12 @@ function User({ user = {}, loadUser }) {
|
|
|
useEffect(() => { loadUser(userId) }, [userId])
|
|
|
|
|
|
|
|
|
- // собираем все _id подписчиков в один массив
|
|
|
+ // собираем все _id подписчиков в один массив - !!!!!!!!!!!!!!!!!!!!!! РАБОТАЕТ НЕКОРРЕКТНО
|
|
|
const promiceStatus = store.getState().promise.UserFindOne.status
|
|
|
const followingsArr = []
|
|
|
|
|
|
- if (promiceStatus === 'FULFILLED') {
|
|
|
+ if (promiceStatus === 'FULFILLED' && user.following) {
|
|
|
+ console.log(999, user.following)
|
|
|
for (let id of (user.following)) {
|
|
|
for (let [key, value] of Object.entries(id)) {
|
|
|
if (key === '_id') {
|
|
@@ -42,47 +32,21 @@ function User({ user = {}, loadUser }) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- // console.log('userID: ', { userId })
|
|
|
- // console.log('user: ', user)
|
|
|
-
|
|
|
return (
|
|
|
<React.Fragment>
|
|
|
<Container sx={{ minHeight: '100vh' }} maxWidth="100%" >
|
|
|
- <Box sx={{ margin: "30px 10px" }}>
|
|
|
- <Grid container spacing={2}>
|
|
|
- <Grid xs={3}>
|
|
|
- <Container>
|
|
|
- <ImageAvatars userData={user} />
|
|
|
- </Container>
|
|
|
- </Grid>
|
|
|
- <Grid xs={9}>
|
|
|
- {/* <BasicCard userData={{ user, followingsArr }} /> */}
|
|
|
- <BasicCard userData={user} />
|
|
|
- </Grid>
|
|
|
-
|
|
|
- <Container>
|
|
|
- <Link to="/createpost" style={{ textDecoration: 'none' }}>
|
|
|
- <Button variant="contained" color='primary' startIcon={<AddAPhotoRoundedIcon />} onClick={() => (console.log('click add'))}>
|
|
|
- Добавить пост
|
|
|
- </Button>
|
|
|
- </Link>
|
|
|
- </Container>
|
|
|
- </Grid>
|
|
|
+ <Box sx={{ margin: "30px 50px" }}>
|
|
|
+ <BasicCard userData={user} />
|
|
|
</Box>
|
|
|
|
|
|
<Divider />
|
|
|
|
|
|
<Box >
|
|
|
<StandardImageList />
|
|
|
-
|
|
|
- {/* <StandardImageList userData={user} /> */}
|
|
|
</Box>
|
|
|
</Container>
|
|
|
</React.Fragment >
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-export const CUser = connect(state => ({ user: state?.promise?.UserFindOne?.payload }), { loadUser: actionFindUserOne })(User)
|
|
|
-
|
|
|
+export const CUser = connect(state => ({ user: state?.promise?.UserFindOne?.payload }), { loadUser: actionFindUserOne })(User)
|