index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import { Link } from 'react-router-dom'
  2. import {
  3. actionAddSubFullComment,
  4. actionDeleteFullLike,
  5. actionAddFullLike,
  6. } from '../../actions'
  7. import { Avatar, Divider, Input, Button } from 'antd'
  8. import user from '../../materials/user.png'
  9. import { connect } from 'react-redux'
  10. import { Row, Col } from 'antd'
  11. import { CComments, CCommentsOnePost } from '../../components/comment/Comment'
  12. import { CPostEditor } from '../createAndEditPost'
  13. import AddComment from '../../components/comment/AddComment'
  14. import { actionFullOnePostSaga,actionAddFullCommentSaga } from '../../actions/typeSaga/postActionSaga'
  15. import { CLike} from '../../components/like/Like'
  16. import { ConstructorModal } from '../../helpers'
  17. import React, { useState, useEffect } from 'react'
  18. import {
  19. actionAddFullCommentFeed,
  20. } from '../../redux/saga'
  21. import { LinkToUser } from '../../components/LinkToUser'
  22. import { MyCarousel } from '../../components/post/Carousel'
  23. import {EditMyPostButton} from '../../components/EditPostButton'
  24. export const PagePost = ({
  25. my_Id,
  26. onePost,
  27. addComment,
  28. match: {
  29. params: { _id },
  30. },
  31. aboutUser = {},
  32. onPost,
  33. }) => {
  34. const [isModalVisible, setIsModalVisible] = useState(false)
  35. useEffect(() => {
  36. onPost(_id)
  37. console.log('ONE POST _ID', onePost?._id)
  38. }, [_id])
  39. return (
  40. <>
  41. <Row>
  42. <Col span={14} style={{marginTop:'100px'}}>
  43. <ConstructorModal
  44. title={'Edit post'}
  45. isModalVisible={isModalVisible}
  46. setIsModalVisible={setIsModalVisible}
  47. >
  48. <CPostEditor />
  49. </ConstructorModal>
  50. <MyCarousel key={onePost?._id}
  51. style={{ position: 'absolute' }}
  52. images={onePost?.images}
  53. />
  54. <h3 style={{ textAlign: 'center', padding: '10px' }}>
  55. Created Post:{' '}
  56. {new Intl.DateTimeFormat('en-GB').format(onePost?.createdAt)}
  57. </h3>
  58. </Col>
  59. <Col span={8}>
  60. <div style={{ display: 'flex', flexDirection: 'row', marginTop:'100px' }}>
  61. <LinkToUser
  62. _id={onePost?.owner?._id}
  63. login={onePost?.owner?.login}
  64. avatar={onePost?.owner?.avatar}
  65. key={_id}
  66. size={50} padding={'0px'} />
  67. <Row span={1}>
  68. {my_Id === onePost?.owner?._id && <EditMyPostButton _id={_id} />}
  69. </Row>
  70. </div>
  71. <Divider />
  72. <h2> Title: {onePost?.title || ''} </h2>
  73. <h2> Text: {onePost?.text || ''} </h2>
  74. <Divider>Comments</Divider>
  75. <div className="Scroll">
  76. {/* <CCommentsOnePost
  77. postId={onePost?._id}
  78. comments={onePost?.comments || []}
  79. /> */}
  80. <CCommentsOnePost/>
  81. </div>
  82. <div style={{ display: 'flex', margin: '20px 0px' }}>
  83. <CLike likes={onePost?.likes} postId={onePost?._id} />
  84. <AddComment addComment={addComment}
  85. style={{
  86. position: 'absolute',
  87. bottom: "120px", right: "30px"
  88. }}
  89. width={'40%'}
  90. postId={onePost?._id} />
  91. </div>
  92. </Col>
  93. </Row>
  94. </>
  95. )
  96. }
  97. export const CPost = connect(
  98. (state) => ({
  99. onePost: state?.post.onePost,
  100. my_Id: state.auth.payload?.sub?.id || '',
  101. aboutUser: state.userData?.aboutUser,
  102. }),
  103. {
  104. addComment: actionAddFullCommentSaga,
  105. // addCommentReply: actionAddSubFullComment,
  106. onPost: actionFullOnePostSaga,
  107. },
  108. )(PagePost)