HeaderButtons.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import user from '../materials/user.png'
  2. import { actionFullProfilePageUser } from '../redux/saga'
  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. // console.log('_id in user', _id)
  41. useEffect(() => {
  42. if (my_Id)
  43. onMyPage(my_Id)
  44. }, [my_Id])
  45. return (
  46. <Link to={`/profile/${_id}`}>
  47. {avatar?.url ? (
  48. <Avatar src={'/' + avatar?.url} size={60} className="Avatar" />
  49. ) : (
  50. <Avatar src={user} size={60} className="Avatar" />
  51. )}
  52. </Link>
  53. )
  54. }
  55. export const CUser = connect(
  56. (state) => ({
  57. my_Id: state.auth?.payload?.sub?.id,
  58. aboutMe: state.myData.aboutMe,
  59. }),
  60. { onMyPage: actionFullProfilePageUser },
  61. )(User)