|
@@ -1,23 +1,36 @@
|
|
|
import React, { useState } from 'react';
|
|
|
-import AppBar from '@mui/material/AppBar';
|
|
|
-import Box from '@mui/material/Box';
|
|
|
-import Toolbar from '@mui/material/Toolbar';
|
|
|
-import IconButton from '@mui/material/IconButton';
|
|
|
-import Typography from '@mui/material/Typography';
|
|
|
-import Menu from '@mui/material/Menu';
|
|
|
-import Container from '@mui/material/Container';
|
|
|
-import Avatar from '@mui/material/Avatar';
|
|
|
-import Tooltip from '@mui/material/Tooltip';
|
|
|
-import MenuItem from '@mui/material/MenuItem';
|
|
|
-import InstagramIcon from '@mui/icons-material/Instagram';
|
|
|
-import AddAPhotoRounded from '@mui/icons-material/AddAPhotoRounded';
|
|
|
+import { useHistory, Link } from 'react-router-dom';
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
+import { AppBar, Box, Toolbar, Typography, Menu, Container, Avatar, Tooltip, MenuItem, IconButton } from '@mui/material'
|
|
|
+import { Instagram, AddAPhotoRounded } from '@mui/icons-material';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
// отрисовываем логин
|
|
|
const UserName = ({ login }) => <span>{login}</span>
|
|
|
const CUserName = connect(state => ({ login: state.auth.payload?.sub?.login }))(UserName)
|
|
|
|
|
|
+// отрисовывваем логин вариант 2
|
|
|
+const UserName2 = ({ user }) =>
|
|
|
+ <MenuItem key={1} >
|
|
|
+ <Typography textAlign="center" onClick={() => console.log('click login')}>
|
|
|
+ <span>{user.login}</span>
|
|
|
+ </Typography>
|
|
|
+ </MenuItem>
|
|
|
+
|
|
|
+const CUserName2 = connect(state => ({ user: state.auth.payload?.sub }))(UserName2)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// ====================
|
|
|
function ResponsiveAppBar() {
|
|
|
+ let history = useHistory()
|
|
|
+
|
|
|
+ function goToMyAccount() {
|
|
|
+ history.push('/user/63f8d0c273ca650acb9353f3');
|
|
|
+ }
|
|
|
+
|
|
|
const [anchorElUser, setAnchorElUser] = useState(null);
|
|
|
|
|
|
const handleOpenUserMenu = (event) => {
|
|
@@ -28,95 +41,12 @@ function ResponsiveAppBar() {
|
|
|
setAnchorElUser(null);
|
|
|
};
|
|
|
|
|
|
- // const consolling = () => {
|
|
|
- // console.log('click')
|
|
|
- // // < Redirect to = '/' />
|
|
|
- // }
|
|
|
-
|
|
|
- // return (
|
|
|
- // <AppBar position="sticky" top='0' color='inherit'>
|
|
|
- // <Container maxWidth="xl">
|
|
|
- // <Toolbar disableGutters>
|
|
|
-
|
|
|
- // <InstagramIcon sx={{ display: { xs: 'flex' }, mr: 1 }} />
|
|
|
-
|
|
|
- // <Typography
|
|
|
- // variant="h6"
|
|
|
- // noWrap
|
|
|
- // component="a"
|
|
|
- // href="/"
|
|
|
- // sx={{
|
|
|
- // mr: 2,
|
|
|
- // display: { xs: 'none', md: 'flex' },
|
|
|
- // fontFamily: 'monospace',
|
|
|
- // fontWeight: 700,
|
|
|
- // letterSpacing: '.3rem',
|
|
|
- // color: 'inherit',
|
|
|
- // textDecoration: 'none',
|
|
|
- // }}
|
|
|
- // >
|
|
|
- // Hipstagram
|
|
|
-
|
|
|
- // {/* отрисовка логина */}
|
|
|
- // {/* <CUserName /> */}
|
|
|
-
|
|
|
- // </Typography>
|
|
|
-
|
|
|
- // <Box sx={{ flexGrow: 1, display: { xs: 'none', md: 'flex' } }} />
|
|
|
-
|
|
|
- // <Box sx={{ flexGrow: 0 }}>
|
|
|
- // <Tooltip >
|
|
|
- // <IconButton onClick={handleOpenUserMenu} sx={{ p: 0 }}>
|
|
|
- // <Avatar alt="Remy Sharp" src="/static/images/avatar/2.jpg" />
|
|
|
- // </IconButton>
|
|
|
- // </Tooltip>
|
|
|
- // <Menu
|
|
|
- // sx={{ mt: '45px' }}
|
|
|
- // id="menu-appbar"
|
|
|
- // anchorEl={anchorElUser}
|
|
|
- // anchorOrigin={{
|
|
|
- // vertical: 'top',
|
|
|
- // horizontal: 'right',
|
|
|
- // }}
|
|
|
- // keepMounted
|
|
|
- // transformOrigin={{
|
|
|
- // vertical: 'top',
|
|
|
- // horizontal: 'right',
|
|
|
- // }}
|
|
|
- // open={Boolean(anchorElUser)}
|
|
|
- // onClose={handleCloseUserMenu}
|
|
|
- // >
|
|
|
- // {/* {settings.map((setting) => (
|
|
|
- // // <MenuItem key={setting} onClick={handleCloseUserMenu}>
|
|
|
- // <MenuItem key={setting} onClick={handleCloseUserMenu}>
|
|
|
- // <Typography textAlign="center">{setting}</Typography>
|
|
|
- // </MenuItem>
|
|
|
- // ))} */}
|
|
|
- // <MenuItem key={1} onClick={() => console.log('click user')}>
|
|
|
- // <Typography textAlign="center">
|
|
|
- // <CUserName />
|
|
|
- // </Typography>
|
|
|
- // </MenuItem>
|
|
|
- // <MenuItem key={2} onClick={() => console.log('click user')}>
|
|
|
- // <Typography textAlign="center">
|
|
|
- // Выйти
|
|
|
- // </Typography>
|
|
|
- // </MenuItem>
|
|
|
-
|
|
|
- // </Menu>
|
|
|
- // </Box>
|
|
|
- // </Toolbar>
|
|
|
- // </Container>
|
|
|
- // </AppBar >
|
|
|
- // );
|
|
|
-
|
|
|
-
|
|
|
return (
|
|
|
<AppBar position='sticky' color='inherit'>
|
|
|
<Container maxWidth="xl">
|
|
|
<Toolbar disableGutters>
|
|
|
<IconButton edge='start'>
|
|
|
- <InstagramIcon sx={{
|
|
|
+ <Instagram sx={{
|
|
|
display: { xs: 'flex' },
|
|
|
mr: 1,
|
|
|
color: 'black'
|
|
@@ -142,11 +72,13 @@ function ResponsiveAppBar() {
|
|
|
</Typography>
|
|
|
|
|
|
<IconButton>
|
|
|
- <AddAPhotoRounded sx={{
|
|
|
- display: { xs: 'flex' },
|
|
|
- mr: 1,
|
|
|
- // color: 'black'
|
|
|
- }} />
|
|
|
+ <Link to='/createpost'>
|
|
|
+ <AddAPhotoRounded sx={{
|
|
|
+ display: { xs: 'flex' },
|
|
|
+ mr: 1,
|
|
|
+ // color: 'black'
|
|
|
+ }} />
|
|
|
+ </Link>
|
|
|
</IconButton>
|
|
|
|
|
|
<Box sx={{ flexGrow: 0 }}>
|
|
@@ -171,11 +103,14 @@ function ResponsiveAppBar() {
|
|
|
open={Boolean(anchorElUser)}
|
|
|
onClose={handleCloseUserMenu}
|
|
|
>
|
|
|
- <MenuItem key={1} onClick={() => console.log('click user')}>
|
|
|
+ {/* <CUserName2 /> */}
|
|
|
+
|
|
|
+ <MenuItem key={1} onClick={goToMyAccount}>
|
|
|
<Typography textAlign="center">
|
|
|
<CUserName />
|
|
|
</Typography>
|
|
|
</MenuItem>
|
|
|
+
|
|
|
<MenuItem key={2} onClick={() => console.log('click logout')}>
|
|
|
<Typography textAlign="center">
|
|
|
<span>Выйти</span>
|