@@ -5,6 +5,8 @@ import { FaBars } from "react-icons/fa";
55import { AiOutlineSearch } from "react-icons/ai" ;
66import { MdNotifications , MdApps } from "react-icons/md" ;
77import { useHistory } from "react-router" ;
8+ import { useSelector } from "react-redux" ;
9+ import { Link } from "react-router-dom" ;
810
911const Header = ( { handleToggleSidebar } ) => {
1012 const [ input , setInput ] = useState ( "" ) ;
@@ -14,21 +16,25 @@ const Header = ({ handleToggleSidebar }) => {
1416 const handleSubmit = ( e ) => {
1517 e . preventDefault ( ) ;
1618
17- history . push ( `/search/${ input } ` )
19+ history . push ( `/search/${ input } ` ) ;
1820 } ;
1921
22+ const { photoUrl } = useSelector ( ( state ) => state . auth ?. user ) ;
23+
2024 return (
2125 < div className = "header" >
2226 < FaBars
2327 className = "header__menu"
2428 size = { 26 }
2529 onClick = { ( ) => handleToggleSidebar ( ) }
2630 />
27- < img
28- src = "http://pngimg.com/uploads/youtube/youtube_PNG2.png"
29- alt = "Youtube Logo"
30- className = "header__logo"
31- />
31+ < Link to = "/" >
32+ < img
33+ src = "http://pngimg.com/uploads/youtube/youtube_PNG2.png"
34+ alt = "Youtube Logo"
35+ className = "header__logo"
36+ />
37+ </ Link >
3238 < form onSubmit = { handleSubmit } >
3339 < input
3440 type = "text"
@@ -44,10 +50,7 @@ const Header = ({ handleToggleSidebar }) => {
4450 < div className = "header__icons" >
4551 < MdNotifications size = { 28 } />
4652 < MdApps size = { 28 } />
47- < img
48- src = "https://cdn.icon-icons.com/icons2/1736/PNG/512/4043260-avatar-male-man-portrait_113269.png"
49- alt = "avatar"
50- />
53+ < img src = { photoUrl } alt = "avatar" />
5154 </ div >
5255 </ div >
5356 ) ;
0 commit comments