LinkToUser.jsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import user from '../materials/user.png'
  2. import { Link } from 'react-router-dom'
  3. import { Avatar, Col, Row } from 'antd'
  4. import { CSubscribeLinkUser } from '../components/Subscribe'
  5. import backendURL from '../helpers/backendUrl'
  6. export const LinkToUser = ({
  7. _id,
  8. avatar,
  9. login,
  10. size,
  11. font = '15px',
  12. padding = '10px',
  13. onClick,
  14. key,
  15. }) => {
  16. return (
  17. <Row style={{ marginBottom:'5px'}}>
  18. <Link
  19. to={`/profile/${_id}`}
  20. style={{
  21. display: 'flex',
  22. padding: padding,
  23. flexDirection: 'row',
  24. fontSize: font,
  25. fontWeight: 'bold',
  26. color: 'black'
  27. }}
  28. onClick={onClick}
  29. key={key}
  30. >
  31. <Col offset={1} className="gutter-row">
  32. {avatar ? (
  33. <Avatar
  34. size={size}
  35. src={backendURL+'/' + avatar?.url}
  36. />
  37. ) : (
  38. <Avatar size={size} src={user}
  39. // style={{ marginRight: '3px' }}
  40. />
  41. )}
  42. </Col>
  43. <Col offset={3} style={{ marginTop: '5px' }}>
  44. <h3> {login || 'Anon'}</h3>
  45. </Col>
  46. </Link>
  47. </Row>
  48. )
  49. }
  50. export const LinkWithSubscribe = ({
  51. _id,
  52. avatar,
  53. login,
  54. size,
  55. font = '15px',
  56. padding = '10px',
  57. onClick,
  58. key,
  59. myId,
  60. }) => {
  61. return (
  62. <Row style={{ margin: '10px', marginBottom: '20px' }}>
  63. <Link
  64. to={`/profile/${_id}`}
  65. style={{
  66. display: 'flex',
  67. padding: padding,
  68. flexDirection: 'row',
  69. fontSize: font,
  70. fontWeight: 'bold',
  71. color: 'black'
  72. }}
  73. onClick={onClick}
  74. key={key}
  75. >
  76. <Col offset={1} className="gutter-row">
  77. {avatar ? (
  78. <Avatar
  79. size={size}
  80. src={backendURL+'/' + avatar?.url}
  81. style={{ marginRight: '3px' }}
  82. />
  83. ) : (
  84. <Avatar size={size} src={user} style={{ marginRight: '3px' }} />
  85. )}
  86. </Col>
  87. <Col offset={2} style={{ marginTop: '5px' }}>
  88. <h3> {login || 'Anon'}</h3>
  89. </Col>
  90. </Link>
  91. {myId == _id ? null : (
  92. <div
  93. style={{
  94. right: '0',
  95. position: 'absolute',
  96. marginRight: '20px',
  97. }}
  98. >
  99. <CSubscribeLinkUser followId={_id} />
  100. </div>
  101. )}
  102. </Row>
  103. )
  104. }
  105. export default LinkToUser