HeaderButtons.jsx 1.7 KB

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