HeaderButtons.jsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import user from '../../materials/user.png'
  2. import { actionFullProfilePageUserTypeSaga } from '../../actions/typeSaga/userTypesSaga'
  3. import { Avatar } from 'antd'
  4. import { Link } from 'react-router-dom'
  5. import { connect } from 'react-redux'
  6. import backendURL from '../../helpers/backendUrl'
  7. import {
  8. HomeOutlined,
  9. CompassOutlined,
  10. PlusSquareOutlined,
  11. ImportOutlined,
  12. SearchOutlined
  13. } from '@ant-design/icons'
  14. import React, { useEffect, useState } from 'react'
  15. const DefaultLink = ({ link, tag }) => {
  16. return (
  17. <Link to={`${link}`} className="Links">
  18. {tag}
  19. </Link>
  20. )
  21. }
  22. export const Feed = () =>
  23. <DefaultLink link={'/feed'} tag={<HomeOutlined />} />
  24. export const Explore = () => (
  25. <DefaultLink link={'/explore'} tag={<CompassOutlined />} />
  26. )
  27. export const SearchMobile = () => (
  28. <DefaultLink link={'/search'} tag={<SearchOutlined />} />
  29. )
  30. export const AddPost = ({ children }) => {
  31. const [state, setState] = useState(false)
  32. return (
  33. <>
  34. <Link to={`/edit/post/new`} className="Links">
  35. <PlusSquareOutlined onClick={() => setState(!state)} />
  36. {!state && children}
  37. </Link>
  38. </>
  39. )
  40. }
  41. export const LogOut = ({ onClick }) => (
  42. <ImportOutlined className="Links" onClick={onClick} />
  43. )
  44. const User = ({ my_Id, aboutMe: { _id, avatar } = {}, onMyPage }) => {
  45. useEffect(() => {
  46. if (my_Id) onMyPage(my_Id)
  47. }, [my_Id])
  48. return (
  49. <Link to={`/profile/${my_Id}`} className="Links" >
  50. {avatar?.url ? (
  51. <Avatar src={backendURL + '/' + avatar?.url}
  52. xl={{size:50 }}
  53. className="Avatar" />
  54. ) : (
  55. <Avatar src={user}
  56. // size={50}
  57. className="Avatar" />
  58. )}
  59. </Link>
  60. )
  61. }
  62. export const CUser = connect(
  63. (state) => ({
  64. my_Id: state.auth?.payload?.sub?.id,
  65. aboutMe: state.myData.aboutMe,
  66. }),
  67. { onMyPage: actionFullProfilePageUserTypeSaga },
  68. )(User)