UNPKG

cluedin-widget

Version:

This is the project for creating and managing widgets in CluedIn.

42 lines (34 loc) 1.58 kB
import React, { Component } from 'react'; import FollowStats from './FollowStats.jsx'; import FollowButton from './Follow.jsx'; import { connect } from 'react-redux'; import { follow, unFollow } from '../../action/follow'; class FollowWidget extends Component { handleUnfollow() { const { entity } = this.props; this.props.dispatch( unFollow( entity ) ); } handleFollow() { const { entity } = this.props; this.props.dispatch( follow( entity ) ); } render() { const { entity, allFollowers, isDoingFollowingRequest, shouldAddFollowerEntityId, shouldRemoveFollowerEntityId } = this.props; return (<div className="cluedIn_following_area"> <FollowStats shouldAddFollowerEntityId={shouldAddFollowerEntityId} shouldRemoveFollowerEntityId={shouldRemoveFollowerEntityId} entity={entity}></FollowStats> <FollowButton onFollow={this.handleFollow.bind(this)} onUnFollow={this.handleUnfollow.bind(this)} isDoingFollowingRequest={isDoingFollowingRequest} allFollowers={allFollowers} entity={entity}></FollowButton> </div>); } } var select = ( state ) => { return { allFollowers: state.follow.allFollowers, isDoingFollowingRequest: state.follow.isDoingFollowingRequest, shouldAddFollowerEntityId: state.follow.shouldAddFollowerEntityId, shouldRemoveFollowerEntityId: state.follow.shouldRemoveFollowerEntityId }; }; export default connect( select )( FollowWidget );