UNPKG

cluedin-widget

Version:

This project contains all the pages needed for browsing entities and searching them. The aim is to replace the CluedIn.Webapp project with this one when all the pages ( including the Admin page ) will be ported to REACT.

85 lines (73 loc) 2.24 kB
import React, { Component } from 'react'; import EntityAskForLead from './EntityAskForLead.jsx'; import EntityAskForLeadMessage from './EntityAskForLeadMessage.jsx'; import { saveAskForLead } from '../../action/askForLead'; import { connect } from 'react-redux'; class EntityAskForLeadWrapper extends Component { state = { isOpen: false, }; openDialogHandler = () => { this.setState({ isOpen: true, }); }; closeHandler = () => { this.setState({ isOpen: false, }); }; askLead = () => { const { entity, currentOrganization, currentUser } = this.props; this.props.dispatch(saveAskForLead({ entityName: entity.name, entityId: entity.id, orgName: currentOrganization.ClientId, userName: currentUser.Email, })); this.closeHandler(); }; render() { const { entity, askForLeads, type } = this.props; const connectivity = 0; if ( !entity || ( type.toLowerCase() !== '/organization'.toLocaleLowerCase() && type.toLowerCase() !== '/person'.toLocaleLowerCase() && type.toLowerCase() !== '/Infrastructure/User'.toLocaleLowerCase() && type.toLowerCase() !== '/user'.toLocaleLowerCase()) ) { return (<span></span>); } return ( <div> <EntityAskForLead isOpen={this.state.isOpen} closeHandler={this.closeHandler.bind(this)} entityName={entity.name} askForLeadHandler={this.askLead.bind(this)} /> <div style={{margin: '-5px -15px 0px -15px'}}> <EntityAskForLeadMessage inLine={true} entityName={entity.name} entityId={entity.id} askForLeads={askForLeads} connectivity={connectivity} onAskForLeadClick={this.openDialogHandler.bind(this)} /> </div> </div> ); } } function select(state) { return { entity: state.entity.selectedEntity, isFetchingEntity: state.entity.isFetchingEntity, currentOrganization: state.organization.currentOrganization, currentUser: state.user.currentUser.client, askForLeads: state.askForLead.askForLeads, }; } export default connect(select)(EntityAskForLeadWrapper);