HeaderButtons.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 = () =>
  51. <DefaultLink
  52. tag={<ImportOutlined />}/>
  53. // export const Feed = () => {
  54. // return (
  55. // <>
  56. // <Link to={`/feed`} onClick={()=>console.log('щас фид')}>
  57. // <a className="button"> Feed </a>
  58. // </Link>
  59. // </>
  60. // )
  61. // }
  62. // export const Explore = () => (
  63. // <Link to={`/explore`}>
  64. // <a size="large" className="button">
  65. // {' '}
  66. // Explore{' '}
  67. // </a>
  68. // </Link>
  69. // )
  70. const User = ({ my_Id, aboutMe: { _id, login, avatar } = {}, onMyPage }) => {
  71. // console.log('_id in user', _id)
  72. useEffect(() => {
  73. if (my_Id)
  74. onMyPage(my_Id)
  75. }, [my_Id])
  76. return (
  77. <Link to={`/profile/${_id}`} onClick={()=>console.log('щас юзер')}>
  78. {avatar?.url ? (
  79. <Avatar src={'/' + avatar?.url} size={50} className="Avatar" />
  80. ) : (
  81. <Avatar src={user} size={50} className="Avatar" />
  82. )}
  83. </Link>
  84. )
  85. }
  86. export const CUser = connect(
  87. (state) => ({
  88. my_Id: state.auth?.payload?.sub?.id,
  89. aboutMe: state.myData.aboutMe,
  90. }),
  91. { onMyPage: actionFullProfilePageUser },
  92. )(User)