1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import {actionChangeSubscribeSaga} from '../actions/typeSaga/subscribeTypesSaga'
- import { Button} from 'antd'
- import { connect } from 'react-redux'
-
- const Subscribe = ({
- myId,
- deleteSubscribe,
- aboutMeFollowing = [],
- changeSubscribe,
- followId,
- }) => {
- const checkFollowId = aboutMeFollowing?.find(
- (follower) => follower?._id === followId,
- )?._id
- return (
- <>
- <div style={{ display: 'flex' }} onClick={()=>changeSubscribe(followId,checkFollowId)}>
- {checkFollowId ?
-
- (
- <Button style={{width:'120px'}}
- size="large" type="primary"
- danger
- >
- Unsubscribe
- </Button>
- ) : (
- <Button
- style={{width:'120px'}}
- size="large"
- type="primary"
- primary
- >
- Subscribe
- </Button>
- )}
- </div>
- </>
- )
- }
- export const CSubscribe = connect((state) => ({
- myId: state.auth?.payload?.sub?.id,
- aboutMeFollowing: state.myData?.aboutMe?.following,
- followId: state.userData?.aboutUser?._id,
- }),
- {
- changeSubscribe:actionChangeSubscribeSaga
- }
- )(Subscribe)
- export const CSubscribeLinkUser = connect((state) => ({
- myId: state.auth?.payload?.sub?.id,
- aboutMeFollowing: state.myData?.aboutMe?.following,
- }),
- {
- changeSubscribe:actionChangeSubscribeSaga
- }
- )(Subscribe)
|