Posts.jsx 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { connect } from "react-redux"
  2. import { Card, Col, Row } from 'antd'
  3. import postNoData from '../../images/profile-post-no.jpeg'
  4. import { Link } from "react-router-dom"
  5. import { backURL, CircularGalleryIcon, videoRegExp } from "../../helpers"
  6. import { PlayCircleOutlined } from "@ant-design/icons"
  7. const Posts = ({ posts }) =>
  8. <Row gutter={[15, 15]}>
  9. {Array.isArray(posts) && posts.map(p => <Col key={p._id} span={8}>
  10. <Link to={`/post/${p._id}`}>
  11. <Card className='Profile__post' hoverable>
  12. {p?.images && p?.images[0] && p.images[0]?.url
  13. ? videoRegExp.test(p.images[0]?.originalFileName)
  14. ? <div className='Profile__box' >
  15. <video>
  16. <source src={backURL + '/' + p.images[0]?.url} />
  17. </video>
  18. <PlayCircleOutlined className='Profile__box-icon--video' />
  19. </div>
  20. : p.images.length === 1
  21. ?
  22. <img src={backURL + '/' + p.images[0]?.url} />
  23. : <div className='Profile__box' >
  24. <CircularGalleryIcon className='Profile__box-icon' style={{ stroke: 'black' }} />
  25. <img src={(backURL + '/' + p?.images[0]?.url)} alt='post Img' />
  26. </div>
  27. : <img src={postNoData} />
  28. }
  29. </Card>
  30. </Link>
  31. </Col>)
  32. }
  33. </Row >
  34. export const CPosts = connect(state => ({ posts: state.postsFeed?.posts || [] }))(Posts)
  35. // const Posts = ({ posts }) =>
  36. // <Row gutter={[15, 15]}>
  37. // {Array.isArray(posts) && posts.map(p => <Col key={p._id} span={8}>
  38. // <Link to={`/post/${p._id}`}>
  39. // <Card className='Profile__post' hoverable>
  40. // {p?.url
  41. // ? videoRegExp.test(p?.originalFileName)
  42. // ? <div className='Profile__box' >
  43. // <video>
  44. // <source src={backURL + '/' + p?.url} />
  45. // </video>
  46. // <PlayCircleOutlined className='Profile__box-icon--video' />
  47. // </div>
  48. // : <img src={backURL + '/' + p?.url} />
  49. // : <img src={postNoData} />
  50. // }
  51. // </Card>
  52. // </Link>
  53. // </Col>)
  54. // }
  55. // </Row >
  56. // export const CPosts = connect(state => ({ posts: state.postsFeed?.posts || [] }))(Posts)