Reply.jsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React, { useState } from 'react'
  2. import { Input, Button } from 'antd'
  3. import { connect } from 'react-redux'
  4. import { actionAddSubCommentTypeSaga } from '../../actions/typeSaga/postActionSaga'
  5. import { ReplyButton } from './SpoilerButton'
  6. export const CommentAction = ({ commentId }) => {
  7. return (
  8. <>
  9. <div style={{ flexDirection: 'column' }}>
  10. <ReplyButton text={'Reply to'}
  11. style={{margin:'0 auto', padding:'0 auto'}}>
  12. <CCommentsForReply commentId={commentId} />
  13. </ReplyButton>
  14. </div>
  15. </>
  16. )
  17. }
  18. const CommentForReply = ({ addCommentReply, commentId}) => {
  19. const [newResult, setComment] = useState('')
  20. console.log('comment', newResult)
  21. return (
  22. <>
  23. <div
  24. style={{
  25. display: 'flex',
  26. flexDirection: 'row',
  27. width: '100%',
  28. padding: '5px',
  29. marginLeft: '10px',
  30. }}
  31. >
  32. <Input
  33. placeholder="Add a comment..."
  34. value={newResult}
  35. onChange={(e) => {
  36. setComment(e.target.value)
  37. }}
  38. />
  39. <Button
  40. disabled={newResult.length < 1}
  41. type="primary"
  42. onClick={(e) =>
  43. addCommentReply(commentId, newResult) &&
  44. setComment((e.target.value = ''))
  45. }
  46. >
  47. {' '}
  48. Publish{' '}
  49. </Button>
  50. </div>
  51. </>
  52. )
  53. }
  54. const CCommentsForReply = connect(null,
  55. {
  56. addCommentReply: actionAddSubCommentTypeSaga,
  57. },
  58. )(CommentForReply)