12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import { actionChangeSubscribeSaga } from '../actions/typeSaga/subscribeTypesSaga'
- import { Button } from 'antd'
- import { connect } from 'react-redux'
- const Subscribe = ({ 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)
|