Subscribe.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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)