Reply.jsx 1.5 KB

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