Header.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 React, { useEffect,useState } from 'react'
  8. export const AddPost = ({ children }) => {
  9. const [state, setState] = useState(false)
  10. return (
  11. <>
  12. <Link to={`/edit/post/new`}>
  13. <a className="button" onClick={() => setState(!state)}>
  14. {' '}
  15. +{' '}
  16. </a>
  17. {!state && children}
  18. </Link>
  19. </>
  20. )
  21. }
  22. export const Feed = () => {
  23. return (
  24. <>
  25. <Link to={`/feed`}>
  26. <a className="button"> Feed </a>
  27. </Link>
  28. </>
  29. )
  30. }
  31. export const Explore = () => (
  32. <Link to={`/explore`}>
  33. <a size="large" className="button">
  34. {' '}
  35. Explore{' '}
  36. </a>
  37. </Link>
  38. )
  39. const User = ({ my_Id, aboutMe: { _id, login, avatar } = {}, onMyPage }) => {
  40. useEffect(() => onMyPage(_id), [_id])
  41. return (
  42. <Link to={`/profile/${_id}`}>
  43. {avatar?.url ? (
  44. <Avatar src={'/' + avatar?.url} size={60} className="Avatar" />
  45. ) : (
  46. <Avatar src={user} size={60} className="Avatar" />
  47. )}
  48. </Link>
  49. )
  50. }
  51. export const CUser = connect(
  52. (state) => ({
  53. my_Id: state.auth?.payload?.sub?.id,
  54. aboutMe: state.profileData.aboutMe,
  55. }),
  56. { onMyPage: actionFullProfilePageUser },
  57. )(User)