@@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
4
4
import styled from 'styled-components' ;
5
5
import { Button } from 'antd' ;
6
6
import { useAuth } from 'common/context/Auth/useAuth' ;
7
+ import { useSelector } from 'react-redux' ;
8
+ import { selectProfile } from 'features/profile/profileSlice' ;
7
9
8
10
const StyledMenu = styled . ul `
9
11
list-style: none;
@@ -20,10 +22,29 @@ const StyledMenu = styled.ul`
20
22
}
21
23
` ;
22
24
25
+ const StyledAvatar = styled . div `
26
+ & > img {
27
+ width: 50px;
28
+ height: 50px;
29
+ border-radius: 50%;
30
+ cursor: pointer;
31
+ }
32
+ ` ;
33
+
34
+ const Line = styled . hr `
35
+ margin-top: 10px;
36
+ width: 90%;
37
+ border: 0;
38
+ height: 1px;
39
+ background: #333;
40
+ background-image: linear-gradient(to right, #ccc, #333, #ccc);
41
+ ` ;
42
+
23
43
const AdaptiveMenu = ( { toggleMobileMenu, mobileMenu } ) => {
24
44
const location = useLocation ( ) ;
25
45
const history = useHistory ( ) ;
26
46
const { token, executeLoggingInProcess, logout } = useAuth ( ) ;
47
+ const profile = useSelector ( selectProfile ) ;
27
48
28
49
const handleAddQuestion = useCallback ( ( ) => {
29
50
history . push ( '/create' ) ;
@@ -54,19 +75,36 @@ const AdaptiveMenu = ({ toggleMobileMenu, mobileMenu }) => {
54
75
{
55
76
id : 2 ,
56
77
protected : true ,
78
+ jsx : (
79
+ < >
80
+ < Link to = "/profile" >
81
+ < div className = "d-flex align-items-center" >
82
+ < StyledAvatar >
83
+ < img className = "m-auto" src = { profile . avatar ?. thumbnail } alt = "" />
84
+ </ StyledAvatar >
85
+ < span className = "nameUser mx-2" > Профиль @{ profile . name } </ span >
86
+ </ div >
87
+ </ Link >
88
+ < Line />
89
+ </ >
90
+ ) ,
91
+ } ,
92
+ {
93
+ id : 3 ,
94
+ protected : true ,
57
95
jsx : (
58
96
< div >
59
97
< Link to = "/favorites" > Избранные</ Link >
60
98
</ div >
61
99
) ,
62
100
} ,
63
101
{
64
- id : 3 ,
102
+ id : 4 ,
65
103
protected : true ,
66
104
jsx : < Link to = "/cart" > Корзина</ Link > ,
67
105
} ,
68
106
{
69
- id : 4 ,
107
+ id : 5 ,
70
108
protected : true ,
71
109
jsx : (
72
110
< Link to = "/" onClick = { logout } >
@@ -75,7 +113,7 @@ const AdaptiveMenu = ({ toggleMobileMenu, mobileMenu }) => {
75
113
) ,
76
114
} ,
77
115
{
78
- id : 5 ,
116
+ id : 6 ,
79
117
guest : true ,
80
118
jsx : (
81
119
< Button
@@ -99,7 +137,7 @@ const AdaptiveMenu = ({ toggleMobileMenu, mobileMenu }) => {
99
137
100
138
return true ;
101
139
} ) ;
102
- } , [ executeLoggingInProcess , handleAddQuestion , logout , token ] ) ;
140
+ } , [ executeLoggingInProcess , handleAddQuestion , logout , profile , token ] ) ;
103
141
104
142
if ( ! mobileMenu ) return null ;
105
143
0 commit comments