Header.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import user from '../materials/user.png'
  2. import { actionFullProfilePageUser } from '../redux/thunk'
  3. import { Avatar, Button } from 'antd'
  4. import { CSearch } from './Search_Users'
  5. import { Link } from 'react-router-dom'
  6. import { connect } from 'react-redux'
  7. import { AddPost } from './NewPost'
  8. import React, { useEffect } from 'react'
  9. import { CLogout } from './LoginRegisterLogout'
  10. export const Feed = () => {
  11. return (
  12. <>
  13. <Link to={`/feed`}>
  14. <a className="button"> Feed </a>
  15. </Link>
  16. </>
  17. )
  18. }
  19. const Recommendations = () => (
  20. <Link to={`/explore`}>
  21. <a size="large" className="button">
  22. {' '}
  23. Explore{' '}
  24. </a>
  25. </Link>
  26. )
  27. const User = ({ my_Id, aboutMe: { _id, login, avatar } = {}, onMyPage }) => {
  28. useEffect(() => onMyPage(_id), [_id])
  29. return (
  30. <Link to={`/profile/${_id}`}>
  31. {avatar?.url ? (
  32. <Avatar src={'/' + avatar?.url} size={60} className="Avatar" />
  33. ) : (
  34. <Avatar src={user} size={60} className="Avatar" />
  35. )}
  36. </Link>
  37. )
  38. }
  39. const CUser = connect(
  40. (state) => ({
  41. my_Id: state.auth?.payload?.sub?.id,
  42. aboutMe: state.profileData.aboutMe,
  43. }),
  44. { onMyPage: actionFullProfilePageUser },
  45. )(User)
  46. export const Header = () => {
  47. return (
  48. <section className="Header">
  49. <CLogout className="button" />
  50. <CSearch />
  51. <Feed />
  52. <AddPost />
  53. <Recommendations />
  54. <CUser />
  55. </section>
  56. )
  57. }