Subscribe.jsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import {actionChangeSubscribeSaga} from '../actions/typeSaga/subscribeTypesSaga'
  2. import { Button} from 'antd'
  3. import { connect } from 'react-redux'
  4. const Subscribe = ({
  5. myId,
  6. deleteSubscribe,
  7. aboutMeFollowing = [],
  8. changeSubscribe,
  9. followId,
  10. }) => {
  11. const checkFollowId = aboutMeFollowing?.find(
  12. (follower) => follower?._id === followId,
  13. )?._id
  14. return (
  15. <>
  16. <div style={{ display: 'flex' }} onClick={()=>changeSubscribe(followId,checkFollowId)}>
  17. {checkFollowId ?
  18. (
  19. <Button style={{width:'120px'}}
  20. size="large" type="primary"
  21. danger
  22. >
  23. Unsubscribe
  24. </Button>
  25. ) : (
  26. <Button
  27. style={{width:'120px'}}
  28. size="large"
  29. type="primary"
  30. primary
  31. >
  32. Subscribe
  33. </Button>
  34. )}
  35. </div>
  36. </>
  37. )
  38. }
  39. export const CSubscribe = connect((state) => ({
  40. myId: state.auth?.payload?.sub?.id,
  41. aboutMeFollowing: state.myData?.aboutMe?.following,
  42. followId: state.userData?.aboutUser?._id,
  43. }),
  44. {
  45. changeSubscribe:actionChangeSubscribeSaga
  46. }
  47. )(Subscribe)
  48. export const CSubscribeLinkUser = connect((state) => ({
  49. myId: state.auth?.payload?.sub?.id,
  50. aboutMeFollowing: state.myData?.aboutMe?.following,
  51. }),
  52. {
  53. changeSubscribe:actionChangeSubscribeSaga
  54. }
  55. )(Subscribe)