Subscribe.jsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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' }} onClick={()=>changeSubscribe(followId,checkFollowId)}>
  22. {checkFollowId ?
  23. (
  24. <Button
  25. size="large" type="primary"
  26. danger
  27. >
  28. Unsubscribe
  29. </Button>
  30. ) : (
  31. <Button
  32. size="large"
  33. type="primary"
  34. primary
  35. >
  36. Subscribe
  37. </Button>
  38. )}
  39. </div>
  40. </>
  41. )
  42. }
  43. export const CSubscribe = connect((state) => ({
  44. myId: state.auth?.payload?.sub?.id,
  45. aboutMeFollowing: state.myData?.aboutMe?.following,
  46. followId: state.userData?.aboutUser?._id,
  47. }),
  48. {
  49. changeSubscribe:actionChangeSubscribeSaga
  50. }
  51. )(Subscribe)
  52. export const CSubscribeLinkUser = connect((state) => ({
  53. myId: state.auth?.payload?.sub?.id,
  54. aboutMeFollowing: state.myData?.aboutMe?.following,
  55. // followId: state.userData?.aboutUser?._id,
  56. }),
  57. {
  58. changeSubscribe:actionChangeSubscribeSaga
  59. }
  60. )(Subscribe)