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.
72 lines (58 loc) • 1.77 kB
JSX
import React, { Component } from 'react';
import { connect } from 'react-redux';
import iso from '../../iso';
import { fetchEntityForSalesForce } from '../../core/action/entity';
import CluedInApp from '../../core/components/cluedinapp.jsx';
import Alert from '../../core/components/generics/alert.jsx';
const url = window.location.href;
class App extends Component {
constructor(props) {
super(props);
this.origin = iso.url.getParameterByName('origin', url);
this.type = iso.url.getParameterByName('type', url);
this.value = iso.url.getParameterByName('value', url);
}
componentWillMount() {
this.props.dispatch(fetchEntityForSalesForce(this.type, this.origin, this.value));
}
componentDidUpdate() {
const {
entity,
} = this.props;
//this.props.dispatch(goToLocation('entityWithTypeAndId', [this.type, entity]));
}
render() {
const { token, entityId, invalidSalesForceId } = this.props;
if (!this.origin || !this.type || !this.value) {
return (<div>Something Wrong With the Url</div>);
}
if (!token) {
return (<div>No token</div>);
}
if (invalidSalesForceId) {
return (
<div style={{margin:'15px'}}>
<Alert>
No information found on CluedIn.
</Alert>
</div>
);
}
return (
<CluedInApp
paramToListen={entityId}
type={this.type}
standAlone={true}
entityId={entityId}
/>);
}
}
var select = (state) => {
return {
entityId: state.entity.entityFromSalesForce,
isFetching: state.entity.isFetchingEntityFromSalesForce,
token: state.core.token,
invalidSalesForceId: state.entity.invalidSalesForceId,
};
};
export default connect(select)(App);