User.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import {backendURL,actionAllPosts,actionOnePost,actionAboutMe} from '../actions'
  2. import user from '../materials/user.png'
  3. import React, { useMemo, useState, useEffect } from 'react'
  4. import {Card} from '../components/Post'
  5. import { Provider, connect } from 'react-redux'
  6. import { Avatar, Image, Divider, Radio } from 'antd'
  7. import { store } from '../reducers'
  8. const PageAboutUser = ({
  9. aboutMe: { _id, login, nick, createdAt, avatar, followers, following } = {},
  10. allPosts,
  11. onPosts,
  12. onPost,
  13. onAboutUser
  14. }) => {
  15. useEffect(() => {
  16. onAboutUser(_id)
  17. onPosts()
  18. }, [])
  19. // console.log('CREATED AT',new Intl.DateTimeFormat().format(createdAt));
  20. return (
  21. <section className="AboutMe">
  22. <Avatar
  23. style={{ width: '150px', height: '150px', position: 'absolute' }}
  24. src={backendURL + '/' + avatar?.url || user}
  25. />
  26. <div className="Info">
  27. <h1> {login}</h1>
  28. <h3>
  29. {' '}
  30. Created Account: {new Intl.DateTimeFormat('en-GB').format(createdAt)}
  31. </h3>
  32. <div style={{ display: 'flex' }}>
  33. {/* {allPosts?.length} style={{display: 'flex',justifyContent: 'space-between'}}*/}
  34. <h3> {allPosts?.length} posts </h3>
  35. <h3 style={{ marginLeft: '20px' }}>
  36. {' '}
  37. {followers?.length} followers{' '}
  38. </h3>
  39. <h3 style={{ marginLeft: '20px' }}>
  40. {' '}
  41. {following?.length} following{' '}
  42. </h3>
  43. </div>
  44. <h3> nick: {nick == null ? login : nick}</h3>
  45. <div
  46. style={{
  47. display: 'flex',
  48. flexWrap: 'wrap',
  49. padding: '20px',
  50. margin: '20px',
  51. }}
  52. >
  53. {(allPosts || [])?.map((item) => (
  54. <Card post={item} onPost={onPost} />
  55. ))}
  56. </div>
  57. {/* <h3> Created Account: {
  58. <div>
  59. <img
  60. src={backendURL + '/' + allPosts?.url}
  61. style={{ maxWidth: '200px', maxHeight: '200px' }}/>
  62. </div> date}
  63. </h3> */}
  64. </div>
  65. </section>
  66. )
  67. }
  68. export const CPageAboutUser = connect(
  69. (state) => ({
  70. aboutMe: state.promise?.aboutMe?.payload,
  71. allPosts: state.promise?.allPosts?.payload,
  72. }),
  73. { onPosts: actionAllPosts, onPost: actionOnePost,
  74. onAboutUser: actionAboutMe
  75. },
  76. )(PageAboutUser)