|
@@ -1,9 +1,106 @@
|
|
|
|
+// import { Avatar, Typography, Box, Stack, CardHeader } from '@mui/material'
|
|
|
|
+// import { useSelector, connect } from 'react-redux'
|
|
|
|
+// import { useHistory } from 'react-router-dom'
|
|
|
|
+
|
|
|
|
+// import { url } from "../../App"
|
|
|
|
+
|
|
|
|
+// function AboutMe({ aboutMe = {} }) {
|
|
|
|
+// let history = useHistory()
|
|
|
|
+
|
|
|
|
+// const myPostsCount = useSelector(state => state?.promise?.MyPostsCount?.payload)
|
|
|
|
+
|
|
|
|
+// function toMyAccount() {
|
|
|
|
+// history.push(`/user/${aboutMe?._id}`)
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// return (
|
|
|
|
+// <Box sx={{
|
|
|
|
+// maxWidth: 400
|
|
|
|
+// }}>
|
|
|
|
+// <CardHeader
|
|
|
|
+// avatar={
|
|
|
|
+// <Avatar
|
|
|
|
+// sx={{ width: 50, height: 50 }}
|
|
|
|
+// alt={aboutMe?.login}
|
|
|
|
+// src={url + aboutMe?.avatar?.url}
|
|
|
|
+// />
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// subheader={
|
|
|
|
+// <Typography
|
|
|
|
+// sx={{
|
|
|
|
+// cursor: 'pointer'
|
|
|
|
+// }}
|
|
|
|
+// variant='h6'
|
|
|
|
+// onClick={toMyAccount}>
|
|
|
|
+// {aboutMe?.login}
|
|
|
|
+// </Typography>
|
|
|
|
+// }
|
|
|
|
+// />
|
|
|
|
+// <Stack
|
|
|
|
+// sx={{
|
|
|
|
+// paddingTop: '5px',
|
|
|
|
+// paddingLeft: '20px',
|
|
|
|
+// flexWrap: 'wrap'
|
|
|
|
+// }}
|
|
|
|
+// direction="row"
|
|
|
|
+// spacing={1}
|
|
|
|
+// padding={2}>
|
|
|
|
+// <Typography>
|
|
|
|
+// {myPostsCount || '0'} публикаций
|
|
|
|
+// </Typography>
|
|
|
|
+// <Typography>
|
|
|
|
+// {aboutMe?.followers?.length || '0'} подписчиков
|
|
|
|
+// </Typography>
|
|
|
|
+// <Typography>
|
|
|
|
+// {aboutMe?.following?.length || '0'} подписок
|
|
|
|
+// </Typography>
|
|
|
|
+// </Stack>
|
|
|
|
+
|
|
|
|
+// {/* вот тут можно добавить список всех юзеров, которые есть в базе: аватар+логин+кнопка подписаться/отписаться */}
|
|
|
|
+
|
|
|
|
+// </Box>
|
|
|
|
+
|
|
|
|
+// )
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+// export const CAboutMe = connect(state => ({ aboutMe: state?.promise?.AboutMe?.payload }))(AboutMe)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
import { Avatar, Typography, Box, Stack, CardHeader } from '@mui/material'
|
|
import { Avatar, Typography, Box, Stack, CardHeader } from '@mui/material'
|
|
import { useSelector, connect } from 'react-redux'
|
|
import { useSelector, connect } from 'react-redux'
|
|
import { useHistory } from 'react-router-dom'
|
|
import { useHistory } from 'react-router-dom'
|
|
|
|
+import React, { useState } from 'react';
|
|
|
|
+
|
|
|
|
+import Backdrop from '@mui/material/Backdrop';
|
|
|
|
+import Modal from '@mui/material/Modal';
|
|
|
|
+import Fade from '@mui/material/Fade';
|
|
|
|
+
|
|
|
|
+import { RecommendedCard } from './recommended';
|
|
|
|
+
|
|
|
|
+import './style.scss'
|
|
|
|
|
|
import { url } from "../../App"
|
|
import { url } from "../../App"
|
|
|
|
|
|
|
|
+
|
|
|
|
+const style = {
|
|
|
|
+ position: 'absolute',
|
|
|
|
+ top: '50%',
|
|
|
|
+ left: '50%',
|
|
|
|
+ transform: 'translate(-50%, -50%)',
|
|
|
|
+ width: 400,
|
|
|
|
+ height: 'auto',
|
|
|
|
+ bgcolor: 'background.paper',
|
|
|
|
+ boxShadow: 24,
|
|
|
|
+ p: 4,
|
|
|
|
+ outline: 0,
|
|
|
|
+ borderRadius: 1.5
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
function AboutMe({ aboutMe = {} }) {
|
|
function AboutMe({ aboutMe = {} }) {
|
|
let history = useHistory()
|
|
let history = useHistory()
|
|
|
|
|
|
@@ -13,6 +110,18 @@ function AboutMe({ aboutMe = {} }) {
|
|
history.push(`/user/${aboutMe?._id}`)
|
|
history.push(`/user/${aboutMe?._id}`)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // функции управления открытием/закрытием модального окна
|
|
|
|
+ const [modalName, setModalName] = useState('')
|
|
|
|
+ const [modalArray, setModalArray] = useState([])
|
|
|
|
+ const [open, setOpen] = useState(false);
|
|
|
|
+ const handleOpen = (param) => {
|
|
|
|
+ setOpen(true)
|
|
|
|
+ setModalArray([...param.arr])
|
|
|
|
+ setModalName(param.name)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const handleClose = () => setOpen(false);
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<Box sx={{
|
|
<Box sx={{
|
|
maxWidth: 400
|
|
maxWidth: 400
|
|
@@ -38,22 +147,82 @@ function AboutMe({ aboutMe = {} }) {
|
|
}
|
|
}
|
|
/>
|
|
/>
|
|
<Stack
|
|
<Stack
|
|
|
|
+ sx={{
|
|
|
|
+ paddingTop: '5px',
|
|
|
|
+ paddingLeft: '20px',
|
|
|
|
+ flexWrap: 'wrap'
|
|
|
|
+ }}
|
|
direction="row"
|
|
direction="row"
|
|
spacing={1}
|
|
spacing={1}
|
|
padding={2}>
|
|
padding={2}>
|
|
- <Typography>
|
|
|
|
|
|
+ <Typography
|
|
|
|
+ sx={{
|
|
|
|
+ cursor: 'pointer'
|
|
|
|
+ }}
|
|
|
|
+ onClick={toMyAccount}
|
|
|
|
+ >
|
|
{myPostsCount || '0'} публикаций
|
|
{myPostsCount || '0'} публикаций
|
|
</Typography>
|
|
</Typography>
|
|
- <Typography>
|
|
|
|
|
|
+ <Typography
|
|
|
|
+ sx={{
|
|
|
|
+ cursor: 'pointer'
|
|
|
|
+ }}
|
|
|
|
+ onClick={() => handleOpen({ arr: aboutMe?.followers, name: 'подписчики' })}
|
|
|
|
+ >
|
|
{aboutMe?.followers?.length || '0'} подписчиков
|
|
{aboutMe?.followers?.length || '0'} подписчиков
|
|
</Typography>
|
|
</Typography>
|
|
- <Typography>
|
|
|
|
|
|
+ <Typography
|
|
|
|
+ sx={{
|
|
|
|
+ cursor: 'pointer'
|
|
|
|
+ }}
|
|
|
|
+ onClick={() => handleOpen({ arr: aboutMe?.following, name: 'подписки' })}
|
|
|
|
+ >
|
|
{aboutMe?.following?.length || '0'} подписок
|
|
{aboutMe?.following?.length || '0'} подписок
|
|
</Typography>
|
|
</Typography>
|
|
</Stack>
|
|
</Stack>
|
|
|
|
|
|
- {/* вот тут можно добавить список всех юзеров, которые есть в базе: аватар+логин+кнопка подписаться/отписаться */}
|
|
|
|
|
|
+ {modalArray && <Modal
|
|
|
|
+ aria-labelledby="transition-modal-title"
|
|
|
|
+ aria-describedby="transition-modal-description"
|
|
|
|
+ open={open}
|
|
|
|
+ onClose={handleClose}
|
|
|
|
+ closeAfterTransition
|
|
|
|
+ slots={{ backdrop: Backdrop }}
|
|
|
|
+ slotProps={{
|
|
|
|
+ backdrop: {
|
|
|
|
+ timeout: 500,
|
|
|
|
+ },
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+ <Fade in={open}>
|
|
|
|
+ <Box sx={style}>
|
|
|
|
+ <Box sx={{
|
|
|
|
+ padding: '0 24px'
|
|
|
|
+ }}>
|
|
|
|
+ <Typography
|
|
|
|
+ variant="subtitle1"
|
|
|
|
+ color='text.secondary'
|
|
|
|
+ gutterBottom
|
|
|
|
+ >
|
|
|
|
+ Ваши {modalName}
|
|
|
|
+ </Typography>
|
|
|
|
+ </Box>
|
|
|
|
+
|
|
|
|
+ <Box
|
|
|
|
+ className='recommendedBox'
|
|
|
|
|
|
|
|
+ sx={{
|
|
|
|
+ margin: '8px 0',
|
|
|
|
+ width: '95%',
|
|
|
|
+ paddingLeft: '8px',
|
|
|
|
+ height: '450px',
|
|
|
|
+ overflowY: 'auto'
|
|
|
|
+ }}>
|
|
|
|
+ {modalArray.map(item => <RecommendedCard key={item._id} data={item} />)}
|
|
|
|
+ </Box>
|
|
|
|
+ </Box>
|
|
|
|
+ </Fade>
|
|
|
|
+ </Modal>}
|
|
</Box>
|
|
</Box>
|
|
|
|
|
|
)
|
|
)
|