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.

61 lines (49 loc) 1.29 kB
import React, { Component } from 'react'; import { fetchAggregationSearch } from '../../../core/action/search'; import { connect } from 'react-redux'; class FactMenu extends Component { render() { const {terms} = this.props; return ( <ul> {terms.map((t, i)=> { return (<li key={i}>{t.term} - {t.count}</li>); })} </ul> ); } } class AggregationForEntity extends Component { componentWillMount() { const { entity, } = this.props; console.log(entity); this.props.dispatch(fetchAggregationSearch(entity.id)); } render() { const { isFetchingAggregationSearch, aggregationSearchResult, } = this.props; if (isFetchingAggregationSearch) { return (<div>loading...</div>); } if (!aggregationSearchResult.Facets) { return (<div>loading...</div>); } return ( <div> <div>Related Information</div> <FactMenu terms={aggregationSearchResult.Facets.entityType.terms}/> </div> ); } } var select = (state) => { return { isFetchingAggregationSearch: state.search.isFetchingAggregationSearch, aggregationSearchResult: state.search.aggregationSearchResult, }; }; export default connect(select)(AggregationForEntity);