Subscribe.jsx 1.6 KB

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