HeaderButtons.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 {
  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. {/* <HomeOutlined /> */ }
  26. export const Explore = () =>
  27. <DefaultLink link={"/explore"} tag={<CompassOutlined />} />
  28. {/* <CompassOutlined /> */}
  29. // export const Feed = () => {
  30. // return (
  31. // <>
  32. // <Link to={`/feed`} onClick={()=>console.log('щас фид')}>
  33. // <a className="button"> Feed </a>
  34. // </Link>
  35. // </>
  36. // )
  37. // }
  38. export const AddPost = ({ children }) => {
  39. const [state, setState] = useState(false)
  40. return (
  41. <>
  42. <Link to={`/edit/post/new`}
  43. className="Links">
  44. <PlusSquareOutlined onClick={() => setState(!state)}/>
  45. {!state && children}
  46. </Link>
  47. </>
  48. )
  49. }
  50. export const LogOut = ({onClick}) =>
  51. <ImportOutlined className="Links" onClick={onClick} />
  52. // export const Feed = () => {
  53. // return (
  54. // <>
  55. // <Link to={`/feed`} onClick={()=>console.log('щас фид')}>
  56. // <a className="button"> Feed </a>
  57. // </Link>
  58. // </>
  59. // )
  60. // }
  61. // export const Explore = () => (
  62. // <Link to={`/explore`}>
  63. // <a size="large" className="button">
  64. // {' '}
  65. // Explore{' '}
  66. // </a>
  67. // </Link>
  68. // )
  69. const User = ({ my_Id, aboutMe: { _id, login, avatar } = {}, onMyPage }) => {
  70. // console.log('_id in user', _id)
  71. useEffect(() => {
  72. if (my_Id)
  73. onMyPage(my_Id)
  74. }, [my_Id])
  75. return (
  76. <Link to={`/profile/${_id}`} onClick={()=>console.log('щас юзер')}>
  77. {avatar?.url ? (
  78. <Avatar src={'/' + avatar?.url} size={50} className="Avatar" />
  79. ) : (
  80. <Avatar src={user} size={50} className="Avatar" />
  81. )}
  82. </Link>
  83. )
  84. }
  85. export const CUser = connect(
  86. (state) => ({
  87. my_Id: state.auth?.payload?.sub?.id,
  88. aboutMe: state.myData.aboutMe,
  89. }),
  90. { onMyPage: actionFullProfilePageUser },
  91. )(User)