cluedin-widget
Version:
This is the project for creating and managing widgets in CluedIn.
32 lines (27 loc) • 1.07 kB
JSX
import React, { Component } from 'react';
import Loader from './../generics/Loader.jsx';
import { FormattedMessage } from 'react-intl';
export default class FollowButton extends Component {
render() {
const { entity, isDoingFollowingRequest, allFollowers, onFollow, onUnFollow } = this.props;
if ( isDoingFollowingRequest ) {
return (<a className="cluedIn_btn cluedIn_btn-primary"><Loader></Loader></a>);
}
var hasFound = allFollowers.filter( ( f )=> {
return f.Entity.EntityId === entity.id;
} ).length;
if ( hasFound ) {
return (
<a className="cluedIn_btn cluedIn_btn-primary" onClick={onUnFollow}>
<FormattedMessage id='Generic.UnPin'></FormattedMessage>
</a>
);
} else {
return (
<a className="cluedIn_btn cluedIn_btn-primary" onClick={onFollow}>
<FormattedMessage id='Generic.Pin'></FormattedMessage>
</a>
);
}
}
}